Collections
- A collection class (also called an abstract data type or container class) is a data type used to store and organize data in some form.
These are things like arrays, lists, maps, dictionaries, etc.
We start exploring collections and how to use them appropriately.
Later, we’ll analyze their efficiencies. For now, let’s just focus on how to use them.
Linear
Vector
About
- A Vector is a collection class representing a list of things.
- It’s similar to Java's ArrayList, JavaScript’s arrays, and Python’s lists.
- To make a Vector, use this syntax:
Vector <type> name
; - All elements of a Vector have to have the same type. You specify that type by placing it in
after the word Vector.
Stacks
About
- A Stack is a data structure representing a stack of things.
- Objects can be pushed on top of the stack or popped from the top of the stack.
Usage
Balancing Parentheses
Queues
About
- A Queue is a data structure representing a waiting line.
- Objects can be enqueued to the back of the line or dequeued from the front of the line.
- No other objects in the queue are visible.
Not Linear
Lexicon
-
Storing a collection of words.
-
A Lexicon is a container that stores a collection of words.
-
The Lexicon is designed to answer the following question efficiently:
-
Given a word, is it contained in the Lexicon?
-
The Lexicon does not support access by index. You can’t, for example, ask what the 137th English word is.
-
However, it does support questions of the form “does this word exist?” or “do any words have this as a prefix?”
Tautonyms
A tautonym is a word formed by repeating the same string twice.
For example: murmur, couscous, papa, etc.
Set
- Storing a group of whatever you’d like.