created: 04/30/2017;
Preliminary version. Changes are likely.
This chapter discusses how the idea of a linked list can be implemented in an object.
The LinkedList
class of this chapter implements an unordered linked list of integers.
Data structures are vital to programming and linked lists are vital to data structures.
Most of what can be done with a linked list of integers could just as easily be done
with an array of integers, but more complex data structures are very hard to do with
arrays.
In this chapter, the integers in the list may be in any order. The insert methods attach a new node at one end or the other without regard to the rest of the list. An ordered linked list keeps its data in ascending (or descending) order. The insert method for such a list must find the correct place in the list for a new node. This is the subject of the next chapter (not yet written).
Could an entire linked list be considered to be an object?