Class TMutableMap
Unit
Declaration
type generic TMutableMap<TKey,TValue,TInfo> = class(specialize TReadOnlyMap<TKey,TValue,TInfo>)
Description
Generic mutable map
Data in this map can be read (see ancestor TReadOnlyMap) and modified.
Example:
type TMutableMapStringString = specialize TMutableMap<string, string, THAMTTypeInfo>; var map: TMutableMapStringString; p: TMutableMapStringString.PPair; begin map := TMutableMapStringString.create; map.Insert('hello', 'world'); map.insert('foo', 'bar'); map['abc'] := 'def'; writeln(map['hello']); // world writeln(map.get('foo')); // bar writeln(map.get('abc', 'default')); // def //enumerate all for p in map do writeln(pˆ.key, ': ', pˆ.value); map.free; end.
Hierarchy
- TReadOnlyCustomSet
- TReadOnlyMap
- TMutableMap
Overview
Methods
function include(const key: TKey; const value: TValue; allowOverride: boolean = true): boolean; inline; |
|
function exclude(const key: TKey): boolean; inline; |
|
procedure insert(const key: TKey; const value: TValue); inline; |
|
procedure remove(const key:TKey); inline; |
|
procedure clear; |
|
function clone: TMutableMap; |
Properties
property items[key: TKey]: TValue read get write includeItem; |
|
property mutable[key: TKey]: PValue read getRef; |
Description
Methods
function exclude(const key: TKey): boolean; inline; |
|
Removes a (key, value) pair ReturnsIf the map did contain key |
procedure insert(const key: TKey; const value: TValue); inline; |
|
Inserts a (key, value) pair, or raises an exception if the map did not contain key |
procedure remove(const key:TKey); inline; |
|
Removes key (and the associated value), or raises an exception if the map did not contain key |
procedure clear; |
|
Removes everything from the map; |
function clone: TMutableMap; |
|
Creates a new map equal to self. No data is copied, till either map is modified (copy-on-write). |
Properties
property items[key: TKey]: TValue read get write includeItem; |
|
Default parameter, so you can read or write elements with |
property mutable[key: TKey]: PValue read getRef; |
|
Pointer to value |
Generated by PasDoc 0.16.0.