Java Reference
In-Depth Information
A BSTRACT D ATA T YPE : S ORTED L IST
D ATA
A collection of objects in sorted order and having the same data type
The number of objects in the collection
O PERATIONS
P SEUDOCODE
UML
D ESCRIPTION
add(newEntry)
+add(newEntry: T): void
Task: Adds newEntry to the sorted list so
that the list remains sorted.
Input: newEntry is the object to be added.
Output: None.
remove(anEntry)
+remove(anEntry: T): boolean
Task: Removes the first or only occurrence
of anEntry from the sorted list.
Input: anEntry is the object to be
removed.
Output: Returns true if anEntry was
located and removed, or false if not.
In the latter case, the list remains
unchanged.
getPosition(anEntry)
+getPosition(anEntry: T): integer
Task: Gets the position of the first or only
occurrence of anEntry .
Input: anEntry is the object to be found.
Output: Returns the position of anEntry if
it occurs in the list. Otherwise,
returns the position where anEntry
would occur in the list, but as a
negative integer.
The following operations behave as they do for the ADT list and are described in Chapter 12:
getEntry(givenPosition)
contains(anEntry)
remove(givenPosition)
clear()
getLength()
isEmpty()
toArray()
 
Search WWH ::




Custom Search