Collections pod provides a set of general-purpose persistent collections. The key feature of these collections is that all of them are const clasess which return a copy on modification. The main trick is the fact, that no full copy is produced, still the old link continues to reference the old version of the collection, i.e. a partial copy takes place to boost the speed of operations.
The basic idea is taken from Clojure
Collection classes can be compiled to Javascript
This pod uses constArray pod with the simple native array class for the performance needs.
The base item is a const mixin ConstColl, it provides a lot of iterable list-like methods like each, findAll, exclude and so on.
Other collection mixins are ConstColl descendants.
ConstSeq is a mixin for a constant sequence of objects.
ConstList mixin provides constant list routings.
ConstMap is a mixin for constant maps. It has two implementations provided: ConstHashSet and ConstTreeSet.
And there is a constant set mixin ConstSet, it is based on ConstMap, and therefore has two implementations as well: ConstHashSet and ConstTreeSet
ilya Mon 17 Jan 2011
Overview
Collections pod provides a set of general-purpose persistent collections. The key feature of these collections is that all of them are const clasess which return a copy on modification. The main trick is the fact, that no full copy is produced, still the old link continues to reference the old version of the collection, i.e. a partial copy takes place to boost the speed of operations.
The basic idea is taken from Clojure
Collection classes can be compiled to Javascript
This pod uses
constArray
pod with the simple native array class for the performance needs.The base item is a const mixin
ConstColl
, it provides a lot of iterable list-like methods likeeach
,findAll
,exclude
and so on.Other collection mixins are
ConstColl
descendants.ConstSeq
is a mixin for a constant sequence of objects.ConstList
mixin provides constant list routings.ConstMap
is a mixin for constant maps. It has two implementations provided:ConstHashSet
andConstTreeSet
.ConstSet
, it is based onConstMap
, and therefore has two implementations as well:ConstHashSet
andConstTreeSet
Repositories:
Examples
ConstList
ConstMap
ConstSet