Preliminary version. Changes are likely.
Data structures are vital to programming and linked lists are vital to data structures.
This chapter discusses how a linked list can be implemented in an object.
The LinkedList
class of this chapter implements an unordered linked list of integers.
Most of what can be done with a linked list of integers could just as easily be done
with an ArrayList
of Integers
,
but more complex data structures are hard to do using arrays.
In this chapter, the integers in the list may be in any order. Methods attach new nodes to the list without regard to order. 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?