Currently three different data structures are available, Data.SplayTree.Set, Data.SplayTree.Seq, and Data.SplayTree.RangeSet. 'Set' provides a set with standard operations. Not much time has been spent optimizing this library, but performance is competitive with unordered-containers for many operations (inserts can be quite slow though). Seq is a sequence type, similar to Data.Seq.
RangeSet is perhaps the most interesting of the available containers. Similar to an IntervalSet, a RangeSet is used for storing a list of Ranges. A RangeSet, however, guarantees that all ranges are non-overlapping. When a new range is inserted into the RangeSet, it is combined with any ranges currently in the set with which it overlaps.
Example (Note that a Range is a starting point and duration):
Prelude Data.SplayTree.RangeSet Data.Foldable> let rs = singleton (range 0 4)
Prelude Data.SplayTree.RangeSet Data.Foldable> toList rs
[Range {rMin = 0, rang = 4}]
Prelude Data.SplayTree.RangeSet Data.Foldable> toList $ insert rs (range 3 2)
[Range {rMin = 0, rang = 5}]
Prelude Data.SplayTree.RangeSet Data.Foldable>
Comments and patches welcome.
No comments:
Post a Comment