Class TImmutableSet
Unit
Declaration
type generic TImmutableSet<TItem,TInfo> = class(specialize TReadOnlySet<TItem,TInfo>)
Description
Generic immutable set
Data in this set can be read (see ancestor TReadOnlySet) and modified by creating new sets.
Example:
type TImmutableSetString = specialize TImmutableSet<string, THAMTTypeInfo>; var set1, set2, set3: TImmutableSetString; p: TImmutableSetString.PItem; begin set1 := TImmutableSetString.create; set2 := set1.Insert('hello'); set3 := set2.insert('foo'); writeln(set1.contains('hello')); // false writeln(set1['foo']); // false writeln(set2.contains('hello')); // true writeln(set2['foo']); // false writeln(set3.contains('hello')); // true writeln(set3['foo']); // true //enumerate all for p in set3 do writeln(pˆ); set1.free; set2.free; set3.free; end.
Hierarchy
- TReadOnlyCustomSet
- TReadOnlySet
- TImmutableSet
Overview
Methods
constructor Create; |
|
constructor Create(other: specialize TReadOnlyCustomSet<TItem, TInfo>); |
|
function include(const item: TItem; allowOverride: boolean = true): TImmutableSet; inline; |
|
function exclude(const item: TItem): TImmutableSet; inline; |
|
function insert(const item: TItem): TImmutableSet; inline; |
|
function remove(const item: TItem): TImmutableSet; inline; |
|
function clone: TImmutableSet; |
Description
Methods
constructor Create; |
|
Creates an empty set |
constructor Create(other: specialize TReadOnlyCustomSet<TItem, TInfo>); |
|
Creates a set equal to other. No data is copied, till either set is modified (copy-on-write). |
function include(const item: TItem; allowOverride: boolean = true): TImmutableSet; inline; |
|
Creates a new set containing item ReturnsThe new set |
function exclude(const item: TItem): TImmutableSet; inline; |
|
Removes an item ReturnsThe new set without item |
function insert(const item: TItem): TImmutableSet; inline; |
|
Inserts an item, or raises an exception if the set already contains the item ReturnsThe new set |
function remove(const item: TItem): TImmutableSet; inline; |
|
Creates a new set without item, or raises an exception if the set did not contain item ReturnsThe new set without item |
function clone: TImmutableSet; |
|
Creates a new set equal to self. No data is copied, till either set is modified (copy-on-write). |
Generated by PasDoc 0.16.0.