Repository navigation
Modern Map Map
Paul Squires edited this page Oct 19, 2026
·
5 revisions
Holds key and value pairs in a hash table, so you find a value by its key.
Map( of TK, TV )-
READING vs WRITING is the thing to know.
m[ k ]inserts a default-constructed value whenkis absent;TryGetandContainsdo not.m[ k ] += 1just working is why, andif m[ k ] = 0silently growing the map is the price. - The hash contract:
Kextendscontainers.Hashable(or is a built-in type),k = kmust compare, and equal keys must hash equal. - Open addressing with linear probing, power-of-two capacity, tombstones on removal, load factor 0.75. Open addressing rather than chaining means one allocation instead of one per entry, which matters more in a language with no garbage collector.
- Iteration order is unspecified and changes across insertions. It is not randomised per process -- stability within one unmodified map is more useful when debugging.
#import "std/containers"
using containers
dim ages as Map( of ustring, integer )
ages.Put( "ada", 36 )
print ages.Count '' 1
print ages[ "ada" ] '' 36
'' READING an absent key INSERTS it -- use Contains or TryGet to ask
print ages.Contains( "alan" ) '' false
print ages[ "alan" ] '' 0
print ages.Count '' 2 -- the read grew the map
'' OrderedMap is the sibling that iterates in key ordertiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing