Collections

?
  • Created by: wreje035
  • Created on: 16-10-18 23:04
What are collections?
Containers for groups of elements. Non - persistent (a temporary storage mechanism). Collections allow you to store/retrieve/traverse/manage the elements
1 of 11
Arrays
Most common type of collection. Fixed size, indexed (access via index only). Usually quickest collection for indexed retrieval.
2 of 11
Lists
Also known as sequences. Grow dynamically (not fixed size). Elements retreived using index only. Most commonly used list = arraylist.
3 of 11
Sets
Only allow unique elements. No index. Most common in java = HashSet. Usually offer mathematical set operations(union, intersection, difference).
4 of 11
Bags / Multisets
Variant of a set that allows duplicates. Similar in functionality to lists. Some implemnetatiosn will add a counter for duplicates.
5 of 11
Stacks
No index. Traversal order is last in last out. Can only access the top of the colletion.
6 of 11
Queues
No index. Traversal order is FIFO.New elements are added to the end of the collection. Only the element at the top can be retrieved, which also removes it.Useful for applications that require elements to be processed in the order they are added.
7 of 11
Maps
Hashtables - they associate (map) keys with values. The key (unique) is an index to the value. To get the value you need to use the key. In java use HASHMAP. in project:
8 of 11
Multimaps
One to many relationships are common. Students have many papers. Majors have many students. Categories have many products. Eg - find all products for a category. Guava is a library that implements this data structure.
9 of 11
Tree
Used to implement sorted collections. Most common = Binary Search Tree (BST). Allows faster lookups via binary search strategy. Trees can become imbalanced over time.Java has TreeSet and TreeMap
10 of 11
Why use collections?
SPACE VS TIME VS EFFORT. Intelligent use of collections reduces processing time, reduces developer effort. reduces cost. Simpler code is easier to debug and maintain which further reduces cost.
11 of 11

Other cards in this set

Card 2

Front

Arrays

Back

Most common type of collection. Fixed size, indexed (access via index only). Usually quickest collection for indexed retrieval.

Card 3

Front

Lists

Back

Preview of the front of card 3

Card 4

Front

Sets

Back

Preview of the front of card 4

Card 5

Front

Bags / Multisets

Back

Preview of the front of card 5
View more cards

Comments

No comments have yet been made

Similar ICT resources:

See all ICT resources »See all Collections resources »