# Archive Map An id-keyed container for the {ref}`TArchive` records of one index, laid out the same way {ref}`TFileMap` is. Config archives can also be addressed by their {ref}`EConfigArchive` name. - - - ## TArchiveMap._Init ```pascal procedure TArchiveMap._Init(expectedCount: Integer); ``` Empties the map and sizes its hash table for roughly `expectedCount` entries. The table is deliberately over-allocated - see {ref}`MapHashSize` - so that probing stays short; {ref}`TArchiveMap._Grow` doubles it again if it ever fills past 60%. - - - ## TArchiveMap._FindSlot ```pascal 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 ```pascal 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 ```pascal procedure TArchiveMap.Build(const keys: TIntegerArray; count: Integer); ``` Fills the map in one pass with an empty {ref}`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 ```pascal function TArchiveMap.Exists(key: Integer): Boolean; ``` Whether the map holds an entry with this id. - - - ## TArchiveMap.IndexOf ```pascal function TArchiveMap.IndexOf(key: Integer): Integer; ``` The position of this id in `Values`, or `-1` if it is not in the map. - - - ## TArchiveMap.Value ```pascal 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 {ref}`EConfigArchive` name. Reading an id the map does not hold raises. Writing keeps `Values` sorted by id, with the same trade-off {ref}`TFileMap.Value` describes. - - - ## TArchiveMap.Clear ```pascal procedure TArchiveMap.Clear(); ``` Drops every entry and the hash table with them, leaving the map as if it had never been used.