ArrayList
and LinkedList
are implementations of the List
abstraction. The first holds the elements of the list in an internal array which is automatically reallocated as necessary to make space for new elements. The second constructs a doubly linked list of holder cells, each of which refers to a list element. While the respective operations have identical semantics, they differ considerably in performance characteristics. For example:
The get(int)
operation on an ArrayList
takes constant time, but it takes time proportional to the length of the list for a LinkedList
.
Removing an element via the Iterator.remove()
takes constant time for a LinkedList
, but it takes time proportional to the length of the list for an ArrayList
.
The HashMap
and THashMap
are both implementations of the Map
abstraction that are use hash tables. The difference is in the form of hash table data structure used in each case. The HashMap
class uses closed addressing which means that each bucket in the table points to a separate linked list of elements. The THashMap
class uses open addressing which means that elements that hash to the same bucket are stored in the table itself. The net result is that THashMap
uses less memory and is faster than HashMap
for most operations, but is much slower if you need the map's set of key/value pairs.
For more detail, read a good textbook on data structures. Failing that, look up the concepts in Wikipedia. Finally, take a look at the source code of the respective classes.