Object <- FixedList <- ClosedObjectHashTable |
|
|
AddEntryAndData AdjustTableSize ChangeEntryData Clear EntryDataAt FindEntryWithData Init |
LookUpEntry LookUpObject OptimalSize Reinsert RemoveEntryAt SafeReplaceHashTableEntries SetEntryDataAt |
|
Full NumDeletedEntries NumEntries Stride |
| Field | Type | |
|---|---|---|
| ClosedObjectHashTable: | numEntries: | Unsigned |
| numDeletedEntries: | Unsigned |
instance ClosedObjectHashTable tag; numEntries: 0; numDeletedEntries: 0; end instance;
Define Class ClosedObjectHashTable; inherits from FixedList; field numEntries: Unsigned, getter; // number of all occupied entries, including deleted ones field numDeletedEntries: Unsigned, getter; // of all the entries used, nuber of deleted ones attribute Full: Boolean, readOnly, safe; attribute NumEntries: Unsigned, safe, readOnly; attribute NumDeletedEntries: Unsigned, safe, readOnly; overrides Init; overrides Stride; overrides Clear; // nuke everything // hash table public calls operation LookUpObject(object: Object): Signed; operation AddEntryAndData(object: Object; data: Signed): Signed; operation RemoveEntryAt(index: Signed); operation EntryDataAt(index: Signed): Signed; operation SetEntryDataAt(index: Signed; data: Signed); operation AdjustTableSize(newSize: Unsigned; nearThis: Object): ClosedObjectHashTable; // If a table is too full or contains too many deleted entries, this is called // to create a new fresh copy of the table with only non-empty copies. // The caller has to delete the original hash table, after the new one is // safely referenced; this is to make the adjusting emergency shutdown proof. operation ChangeEntryData(oldData: Unsigned; newData: Unsigned); // used by the StringDictionary's compaction routine // hash table private calls operation OptimalSize(): Unsigned; // returns the size of table it thinks would be optimal for the // data it's containing operation LookUpEntry(key: Unsigned; newEntry: Boolean): Signed; // used for looking for existing and/or empty entries operation Reinsert(entry: ReadOnlyPointer); // used by AdjustTableSize to copy an entry from an old table to a new one operation FindEntryWithData(data: Signed): Signed; operation SafeReplaceHashTableEntries(other: ClosedObjectHashTable); // Used when we rehashed by making a new hash table in another // volume to copy the entries back in a reset-proof way. end class;