|
Table Class Reference#include <TableA.h>
List of all members.
Detailed Description
ADT table. Sorted array-based implementation. Assumption: A table contains at most one item with a given search key at any time.
Definition at line 31 of file TableA.h.
Constructor & Destructor Documentation
virtual Table::~Table |
( |
|
) |
[virtual] |
|
Member Function Documentation
virtual bool Table::tableIsEmpty |
( |
|
) |
const [virtual] |
|
|
Determines whether a table is empty. - Returns:
- True if the table is empty; otherwise returns false.
|
virtual int Table::tableLength |
( |
|
) |
const [virtual] |
|
|
Determines the length of a table. - Returns:
- The number of items in the table.
|
|
Inserts an item into a table in its proper sorted order according to the item's search key. - Precondition:
- The item to be inserted into the table is newItem, whose search key differs from all search keys presently in the table.
- Postcondition:
- If the insertion is successful, newItem is in its proper order in the table.
- Exceptions:
-
Definition at line 22 of file TableA.cpp.
References MAX_TABLE. |
|
Deletes an item with a given search key from a table. - Precondition:
- searchKey is the search key of the item to be deleted.
- Postcondition:
- If the item whose search key equals searchKey existed in the table, the item is deleted.
- Exceptions:
-
Definition at line 44 of file TableA.cpp. |
|
Retrieves an item with a given search key from a table. - Precondition:
- searchKey is the search key of the item to be retrieved.
- Postcondition:
- If the retrieval is successful, tableItem contains the retrieved item.
- Exceptions:
-
Definition at line 65 of file TableA.cpp. |
|
Traverses a table in sorted search-key order, calling function visit() once for each item. - Precondition:
- The function represented by visit() exists outside of the ADT implementation.
- Postcondition:
- visit()'s action occurs once for each item in the table.
- Note:
- visit() can alter the table.
Definition at line 81 of file TableA.cpp.
References items, and size. |
void Table::setSize |
( |
int |
newSize |
) |
[protected] |
|
|
Sets the private data member size to newSize. |
void Table::setItem |
( |
const TableItemType & |
newItem, |
|
|
int |
index |
|
) |
[protected] |
|
|
Sets items[index] to newItem. |
int Table::position |
( |
KeyType |
searchKey |
) |
const [protected] |
|
|
Finds the position of a table item or its insertion point. - Precondition:
- searchKey is the value of the search key sought in the table.
- Returns:
- The index (between 0 and size - 1) of the item in the table whose search key equals searchKey. If no such item exists, returns the position (between 0 and size) that the item would occupy if inserted into the table. The table is unchanged.
|
int Table::keyIndex |
( |
int |
first, |
|
|
int |
last, |
|
|
KeyType |
searchKey |
|
) |
const [private] |
|
|
Searches a particular portion of the private array items for a given search key by using a binary search. - Precondition:
- 0 <= first, last < MAX_TABLE, where MAX_TABLE = max size of the array, and the array items[first..last] is sorted in ascending order by search key.
- Returns:
- If searchKey is in the array, returns the index of the array element that contains searchKey; otherwise returns the index (between first and last) of the array element that the item would occupy if inserted into the array in its proper order. The array is unchanged.
|
Member Data Documentation
The documentation for this class was generated from the following files:
|