Book Image

Mastering Dart

By : Sergey Akopkokhyants
Book Image

Mastering Dart

By: Sergey Akopkokhyants

Overview of this book

Table of Contents (19 chapters)
Mastering Dart
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Choosing the right collection


How do you choose the right collection for specific cases? I'm sure many of us have asked that question at least once. Let me try to help you to make the right choice:

  • The List, Set (such as LinkedHasSet), and Map (such as LinkedHashMap) classes are perfect choices for general purposes. They have enough functionality to cover all of your needs.

  • Choosing a class implements the minimum functionality that you require. Don't choose a class that supports sorting if you don't actually need it.

Here is a table that combines all the classes with the supported features:

Class

Order

Sort

Random access

Key-values

Duplicates

Null

List

Yes

Yes

Yes

No

Yes

Yes

LinkedList

Yes

No

No

No

Yes

Yes

Set or LinkedHashSet

Yes

No

No

No

No

No

HashSet

No

No

No

No

No

No

SplayTreeSet

Yes

Yes

No

No

No

No

Queue or ListQueue

Yes

Yes

No

No

Yes

Yes

Map or LinkedHashMap

Yes

No

Yes

Yes

No

Yes

HashMap

No

No

Yes

Yes

No

Yes...