Archive Map¶
An id-keyed container for the TArchive records of one index, laid out the same way TFileMap is.
Config archives can also be addressed by their EConfigArchive name.
TArchiveMap._Init¶
procedure TArchiveMap._Init(expectedCount: Integer);
Empties the map and sizes its hash table for roughly expectedCount entries.
The table is deliberately over-allocated - see MapHashSize - so that probing stays short; TArchiveMap._Grow doubles it again if it ever fills past 60%.
TArchiveMap._FindSlot¶
function TArchiveMap._FindSlot(key: Integer): Integer;
The hash slot belonging to key: either the one already holding it, or the first free one after
where it hashes to. Collisions walk forward one slot at a time and wrap around.
TArchiveMap._Grow¶
procedure TArchiveMap._Grow();
Doubles the hash table and reinserts every key into it. Entry order is untouched - only the slots that point at the entries are rebuilt.
ArchiveMap.Build¶
procedure TArchiveMap.Build(const keys: TIntegerArray; count: Integer);
Fills the map in one pass with an empty TArchive per key, sizing the key, value and hash arrays exactly once instead of regrowing them on every insert.
Only the first count entries of keys are used, so callers filling many maps in a row can
reuse one buffer. They must be in ascending order, which is how reference tables store them.
TArchiveMap.Exists¶
function TArchiveMap.Exists(key: Integer): Boolean;
Whether the map holds an entry with this id.
TArchiveMap.IndexOf¶
function TArchiveMap.IndexOf(key: Integer): Integer;
The position of this id in Values, or -1 if it is not in the map.
TArchiveMap.Value¶
property TArchiveMap.Value(key: Integer; const val: TArchive);
property TArchiveMap.Value(key: Integer): TArchive;
property TArchiveMap.Value(key: EConfigArchive; const val: TArchive);
property TArchiveMap.Value(key: EConfigArchive): TArchive;
Reads or writes the archive stored under key, which may be an id or, for the config index, an
EConfigArchive name. Reading an id the map does not hold raises.
Writing keeps Values sorted by id, with the same trade-off TFileMap.Value describes.
TArchiveMap.Clear¶
procedure TArchiveMap.Clear();
Drops every entry and the hash table with them, leaving the map as if it had never been used.