Containers and Data Structures Flashcards
A collections framework is a unified architecture for representing and manipulating collections. All collections frameworks contain the following:
Interfaces:
Implementations:
Implementations: These are abstract data types that represent collections. Interfaces allow collections to be manipulated independently of the details of their representation. In object-oriented languages, interfaces generally form a hierarchy.
Implementations: These are the concrete implementations of the collection interfaces. In essence, they are reusable data structures.
Queue:
A collection used to hold multiple elements prior to processing. Besides basic Collection operations, a Queue provides additional insertion, extraction, and inspection operations.
Queues are like lines. They follow FIFO (first in first out); when you pop, you pop from the front, but when you push, you push from the back.
Deque:
Deque stands for double ended queue, which is also a collection used to hold multiple elements prior to processing. A collection used to hold multiple elements prior to processing. Besides basic Collection operations, a Deque provides additional insertion, extraction, and inspection operations.
Deque’s can be used both as FIFO (first-in, first-out) and LIFO (last-in, first-out). In a deque all new elements can be inserted, retrieved and removed at both ends.
A Collection represents a group of objects known as its elements. The Collection interface is used to pass around collections of objects where maximum abstraction is desired. For example, by convention all general-purpose collection implementations have a constructor that takes a Collection argument. This constructor, known as a conversion constructor, initializes the new collection to contain all of the elements in the specified collection, whatever the given collection’s subinterface or implementation type. In other words, it allows you to convert the collection’s type.
Suppose, for example, that you have a Collection c, which may be a List, a Set, or another kind of Collection. This line of code creates a new ArrayList (an implementation of the List interface), initially containing all the elements in c:
List list = new ArrayList(c);
Collection Type, Number of Elements Inserted/Removed (10,000), and Time Taken
LinkedList Priority Queue ArrayList Vector ArrayDeque Stack
Queue pQueue = new PriorityQueue();
List arrayList = new ArrayList();
List vectorList = new Vector();
Deque arrayDeque = new ArrayDeque();
Stack stack = new Stack();
Each collection has their specific syntac for “push” and “pop”. What are they?
ArrayList
Priority Queue
Deque
ArrayDeque
Stack
What are certain collections faster and slower than others?
Due to the underlying data structures, this affects how elements are accessed, removed, and the entire collection is restructured