- Compositions <A>
- Empty
- Tree
- Combine (Compositions<A> compy)
- WellFormed <EqA> ()
- Skip (int amount)
- Take (int amount)
- TakeComposed (int amount)
- SplitAt (int i)
- Composed ()
- Singleton (A value)
- Count ()
- FromList (IEnumerable<A> ma)
- Equals (Compositions<A> b)
- Equals (object? obj)
- == (Compositions<A> a, Compositions<A> b)
- != (Compositions<A> a, Compositions<A> b)
- GetHashCode ()
- ToSeq ()
- AsIterable ()
- GetEnumerator ()
- Node
- CompositionsExt
- Compositions
- wellFormed <EqA, A> (Compositions<A> ca)
- skip <A> (int amount, Compositions<A> compositions)
- take <A> (int amount, Compositions<A> compositions)
- takeComposed <A> (int amount, Compositions<A> compositions)
- splitAt <A> (int i, Compositions<A> c)
- composed <A> (Compositions<A> compositions)
- singleton <A> (A value)
- count <A> (Compositions<A> compositions)
- cons <A> (A x, Compositions<A> xs)
- fromList <A> (IEnumerable<A> ma)
- FoldCompositions <A>
struct Compositions <A> Source #
A compositions list or composition tree is a list data type where the elements are monoids, and the 'mconcat' of any contiguous sublist can be computed in logarithmic time.
A common use case of this type is in a wiki, version control system, or collaborative editor, where each change or delta would be stored in a list, and it is sometimes necessary to compute the composed delta between any two versions.
This version of a composition list is strictly biased to right-associativity, in that we only support efficient consing to the front of the list. This also means that the 'take' operation can be inefficient.
The append operation append(a, b)
performs O(a log (a + b))
element compositions, so you want
the left-hand list a
to be as small as possible.
method bool WellFormed <EqA> () Source #
Returns true if the given tree is appropriately right-biased.
method Compositions<A> Skip (int amount) Source #
Return the compositions list with the first k
elements removed, in O(log k)
time.
method Compositions<A> Take (int amount) Source #
Return the compositions list containing only the first k
elements
of the input. In the worst case, performs O(k log k)
element compositions,
in order to maintain the right-associative bias. If you wish to run composed
on the result of take
, use takeComposed
for better performance.
method A TakeComposed (int amount) Source #
Returns the composition of the first k
elements of the compositions list, doing only O(log k)
compositions.
Faster than simply using take
and then composed
separately.
method (Compositions<A> taken, Compositions<A> skipped) SplitAt (int i) Source #
A convenience alias for 'take' and 'skip'
Compose every element in the compositions list. Performs only O(log n)
compositions.
method Compositions<A> Singleton (A value) Source #
Construct a compositions list containing just one element.
method Compositions<A> FromList (IEnumerable<A> ma) Source #
Convert a compositions list into a list of elements. The other direction is provided in the 'Data.Foldable.Foldable' instance.This will perform O(n log n) element compositions.
method int GetHashCode () Source #
Get hash code
returns |
method Iterable<A> AsIterable () Source #
Convert to an enumerable
method IEnumerator<A> GetEnumerator () Source #
Get enumerator
class CompositionsExt Source #
class Compositions Source #
method bool wellFormed <EqA, A> (Compositions<A> ca) Source #
Returns true if the given tree is appropriately right-biased.
method Compositions<A> skip <A> (int amount, Compositions<A> compositions) Source #
Return the compositions list with the first k
elements removed, in O(log k)
time.
method Compositions<A> take <A> (int amount, Compositions<A> compositions) Source #
Return the compositions list containing only the first k
elements
of the input. In the worst case, performs O(k log k)
element compositions,
in order to maintain the right-associative bias. If you wish to run composed
on the result of take
, use takeComposed
for better performance.
method A takeComposed <A> (int amount, Compositions<A> compositions) Source #
Returns the composition of the first k
elements of the compositions list, doing only O(log k)
compositions.
Faster than simply using take
and then composed
separately.
method (Compositions<A> taken, Compositions<A> skipped) splitAt <A> (int i, Compositions<A> c) Source #
A convenience alias for 'take' and 'drop'
method A composed <A> (Compositions<A> compositions) Source #
Compose every element in the compositions list. Performs only O(log n)
compositions.
method Compositions<A> singleton <A> (A value) Source #
Construct a compositions list containing just one element.
method int count <A> (Compositions<A> compositions) Source #
Get the number of elements in the compositions list, in O(log n)
time.