Class TImmutableMap
Unit
Declaration
type generic TImmutableMap<TKey,TValue,TInfo> = class(specialize TReadOnlyMap<TKey,TValue,TInfo>)
Description
Generic immutable map
Data in this map can be read (see ancestor TReadOnlyMap) and modified by creating new maps.
Example:
type TImmutableMapStringString = specialize TImmutableMap<string, string, THAMTTypeInfo>; var map, map2, map3: TImmutableMapStringString; p: TImmutableMapStringString.PPair; begin map := TImmutableMapStringString.create; map2 := map.Insert('hello', 'world'); map3 := map2.insert('foo', 'bar'); writeln(map.get('hello', 'default')); // default writeln(map.get('foo', 'default')); // default writeln(map2.get('hello')); // world writeln(map2.get('foo', 'default')); // default writeln(map3['hello']); // world writeln(map3['foo']); // bar //enumerate all for p in map3 do writeln(pˆ.key, ': ', pˆ.value); map.free; map2.free; map3.free; end.
Hierarchy
- TReadOnlyCustomSet
- TReadOnlyMap
- TImmutableMap
Overview
Methods
function include(const key: TKey; const value: TValue; allowOverride: boolean = true): TImmutableMap; inline; overload; |
|
function exclude(const key: TKey): TImmutableMap; inline; |
|
function insert(const key: TKey; const value: TValue): TImmutableMap; inline; |
|
function remove(const key:TKey): TImmutableMap; inline; |
|
function clone: TImmutableMap; |
Description
Methods
function include(const key: TKey; const value: TValue; allowOverride: boolean = true): TImmutableMap; inline; overload; |
|
Creates a new map containing (key, value). If the map does not contain key or allowOverride is true, the value associated with the key is ReturnsThe new map |
function exclude(const key: TKey): TImmutableMap; inline; |
|
Creates a new map without key and its associated value ReturnsThe new map |
function insert(const key: TKey; const value: TValue): TImmutableMap; inline; |
|
Creates a new map containing (key, value), or raises an exception if the map already contained key ReturnsThe new map |
function remove(const key:TKey): TImmutableMap; inline; |
|
Creates a new map without key and its associated value, or raises an exception if the map did not contain key ReturnsThe new map |
function clone: TImmutableMap; |
|
Creates a new map equal to self. No data is copied, till either map is modified (copy-on-write). |
Generated by PasDoc 0.16.0.