Java Reference
In-Depth Information
FIGURE 12-1
A to-do list
I have so much to do this
weekend — I should make a list.
To Do
1. Read Chapter 12
2. Call home
3. Buy card for Sue
Specifications for the ADT List
12.1
Everyday lists such as to-do lists, gift lists, address lists, and grocery lists have entries that are
strings. What can you do to such lists?
Typically, you add a new entry at the end of the list.
Actually, you can add a new entry anywhere: at the beginning, the end, or in between items.
You can cross out an entry—that is, remove it.
You can remove all entries.
You can replace an entry.
You can look at any entry.
You can look at all of the entries.
You can find out whether the list contains a particular entry.
You can count the number of entries in the list.
You can see whether the list is empty .
When you work with a list, you determine where an entry is or should be. You probably are not
conscious of its exact position: Is it tenth? Fourteenth? However, when your program uses a list, a
convenient way to identify a particular entry is by the entry's position within the list. It could be
first, that is, at position 1, or second (position 2), and so on. This convention allows you to describe,
or specify, the operations on a list more precisely.
VideoNote
The ADT list
12.2
To specify the ADT list, we describe its data and specify the operations on that data. Unlike com-
mon lists whose entries are strings, the ADT list is more general and has entries that are objects of
the same type. The following is an initial specification of the ADT list:
 
 
Search WWH ::




Custom Search