- AtomSeq <A>
- Empty
- AtomSeq (IEnumerable<A> ma)
- ToSeq ()
- Case
- Deconstruct (out A head, out Seq<A> tail)
- this []
- Swap (Func<Seq<A>, Seq<A>> swap)
- Add (A value)
- Concat (IEnumerable<A> items)
- Concat (Lst<A> items)
- Concat (Set<A> items)
- Concat (HashSet<A> items)
- Concat (Arr<A> items)
- Concat (Stck<A> items)
- Concat (IReadOnlyCollection<A> items)
- Concat (Seq<A> rhs)
- Head
- Tail
- Init
- HeadOrNone ()
- Last
- LastOrNone ()
- LastOrLeft <L> (L Left)
- LastOrLeft <L> (Func<L> Left)
- HeadOrLeft <L> (L left)
- HeadOrLeft <L> (Func<L> Left)
- IsEmpty
- Count
- Length
- AsIterable ()
- Match <B> (Func<B> Empty, Func<A, Seq<A>, B> Tail)
- Match <B> ( Func<B> Empty, Func<A, B> Head, Func<A, Seq<A>, B> Tail)
- Match <B> ( Func<B> Empty, Func<Seq<A>, B> Seq)
- Match <B> ( Func<B> Empty, Func<A, B> Head, Func<Seq<A>, B> Tail)
- Iter (Action<A> f)
- Map <B> (Func<A, B> f)
- MapInPlace (Func<A, A> f)
- Select <B> (Func<A, B> f)
- Bind <B> (Func<A, Seq<B>> f)
- BindInPlace <B> (Func<A, Seq<A>> f)
- SelectMany <B, C> (Func<A, Seq<B>> bind, Func<A, B, C> project)
- Filter (Func<A, bool> f)
- FilterInPlace (Func<A, bool> f)
- Where (Func<A, bool> f)
- Fold <S> (S state, Func<S, A, S> f)
- FoldBack <S> (S state, Func<S, A, S> f)
- Exists (Func<A, bool> f)
- ForAll (Func<A, bool> f)
- Any ()
- Intersperse (A value)
- GetHashCode ()
- CompareTo (object? obj)
- ToString ()
- ToFullString (string separator = ", ")
- ToFullArrayString (string separator = ", ")
- > (AtomSeq<A> x, AtomSeq<A> y)
- >= (AtomSeq<A> x, AtomSeq<A> y)
- < (AtomSeq<A> x, AtomSeq<A> y)
- <= (AtomSeq<A> x, AtomSeq<A> y)
- == (AtomSeq<A> x, AtomSeq<A> y)
- != (AtomSeq<A> x, AtomSeq<A> y)
- Equals (object? obj)
- Equals (Seq<A> rhs)
- Equals (AtomSeq<A>? rhs)
- Equals <EqA> (Seq<A> rhs)
- Equals <EqA> (AtomSeq<A> rhs)
- Skip (int amount)
- Take (int amount)
- TakeWhile (Func<A, bool> pred)
- TakeWhile (Func<A, int, bool> pred)
- Inits
- NonEmptyInits
- Tails
- NonEmptyTails
- CompareTo (Seq<A> rhs)
- CompareTo (AtomSeq<A>? rhs)
- CompareTo <OrdA> (Seq<A> rhs)
- CompareTo <OrdA> (AtomSeq<A> rhs)
- Strict ()
- GetEnumerator ()
- Cast <B> ()
- AtomSeqExtensions
Atoms provide a way to manage shared, synchronous, independent state without
locks. AtomSeq
wraps the language-ext Seq
, and makes sure all operations are atomic and thread-safe
without resorting to locking
See the concurrency section of the wiki for more info.
type | A | Item value type |
Head item in the sequence. NOTE: If IsEmpty
is true then Head
is undefined. Call HeadOrNone() if for maximum safety.
property bool IsEmpty Source #
Returns true if the sequence is empty
For lazy streams this will have to peek at the first item. So, the first item will be consumed.
Returns the number of items in the sequence
returns | Number of items in the sequence |
property Seq<Seq<A>> Inits Source #
Returns all initial segments of the sequence, shortest first
Including the empty sequence
returns | Initial segments of the sequence |
Seq("a", "b", "c").Inits
> Seq(Seq(), Seq("a"), Seq("a", "b"), Seq("a", "b", "c"))
property Seq<Seq<A>> NonEmptyInits Source #
Returns all initial segments of the sequence, shortest first.
Not including the empty sequence
returns | Initial segments of the sequence |
Seq("a", "b", "c").Inits
> Seq(Seq("a"), Seq("a", "b"), Seq("a", "b", "c"))
property Seq<Seq<A>> Tails Source #
Returns all final segments of the argument, longest first.
Including the empty sequence
returns | Initial segments of the sequence |
Seq("a", "b", "c").Tails
> Seq(Seq("a", "b", "c"), Seq("a", "b"), Seq("a"), Seq())
property Seq<Seq<A>> NonEmptyTails Source #
Returns all final segments of the argument, longest first.
Not including the empty sequence
returns | Initial segments of the sequence |
Seq("a", "b", "c").Tails
> Seq(Seq("a", "b", "c"), Seq("a", "b"), Seq("a"))
method Seq<A> ToSeq () Source #
Convert to an immutable sequence
This is effectively a zero cost operation, not even a single allocation
method void Deconstruct (out A head, out Seq<A> tail) Source #
method Unit Swap (Func<Seq<A>, Seq<A>> swap) Source #
Atomically swap the underlying Seq. Allows for multiple operations on the Seq in an entirely transactional and atomic way.
Any functions passed as arguments may be run multiple times if there are multiple threads competing to update this data structure. Therefore the functions must spend as little time performing the injected behaviours as possible to avoid repeated attempts
param | swap | Swap function, maps the current state of the AtomSeq to a new state |
method Unit Add (A value) Source #
Add an item to the end of the sequence
Forces evaluation of the entire lazy sequence so the item can be appended
method Unit Concat (IEnumerable<A> items) Source #
Add a range of items to the end of the sequence
Forces evaluation of the entire lazy sequence so the items can be appended.
method Unit Concat (Lst<A> items) Source #
Add a range of items to the end of the sequence
Forces evaluation of the entire lazy sequence so the items can be appended.
method Unit Concat (Set<A> items) Source #
Add a range of items to the end of the sequence
Forces evaluation of the entire lazy sequence so the items can be appended.
method Unit Concat (HashSet<A> items) Source #
Add a range of items to the end of the sequence
Forces evaluation of the entire lazy sequence so the items can be appended.
method Unit Concat (Arr<A> items) Source #
Add a range of items to the end of the sequence
Forces evaluation of the entire lazy sequence so the items can be appended.
method Unit Concat (Stck<A> items) Source #
Add a range of items to the end of the sequence
Forces evaluation of the entire lazy sequence so the items can be appended.
method Unit Concat (IReadOnlyCollection<A> items) Source #
Add a range of items to the end of the sequence
Forces evaluation of the entire lazy sequence so the items can be appended.
method Unit Concat (Seq<A> rhs) Source #
Add a range of items to the end of the sequence
Forces evaluation of the entire lazy sequence so the items can be appended.
method Option<A> HeadOrNone () Source #
Head of the sequence if this node isn't the empty node
method Option<A> LastOrNone () Source #
Last item in sequence.
method Either<L, A> LastOrLeft <L> (L Left) Source #
Last item in sequence.
method Either<L, A> LastOrLeft <L> (Func<L> Left) Source #
Last item in sequence.
method Either<L, A> HeadOrLeft <L> (L left) Source #
Head of the sequence if this node isn't the empty node or left
type | L | |
param | left | Left case |
returns | Head of the sequence or left |
method Either<L, A> HeadOrLeft <L> (Func<L> Left) Source #
Head of the sequence if this node isn't the empty node
method Iterable<A> AsIterable () Source #
Stream as an enumerable
method B Match <B> (Func<B> Empty, Func<A, Seq<A>, B> Tail) Source #
Match empty sequence, or multi-item sequence
type | B | Return value type |
param | Empty | Match for an empty list |
param | Tail | Match for a non-empty |
returns | Result of match function invoked |
method B Match <B> ( Func<B> Empty, Func<A, B> Head, Func<A, Seq<A>, B> Tail) Source #
Match empty sequence, or one item sequence, or multi-item sequence
type | B | Return value type |
param | Empty | Match for an empty list |
param | Tail | Match for a non-empty |
returns | Result of match function invoked |
method B Match <B> ( Func<B> Empty, Func<Seq<A>, B> Seq) Source #
Match empty sequence, or multi-item sequence
type | B | Return value type |
param | Empty | Match for an empty list |
param | Sequence | Match for a non-empty |
returns | Result of match function invoked |
method B Match <B> ( Func<B> Empty, Func<A, B> Head, Func<Seq<A>, B> Tail) Source #
Match empty sequence, or one item sequence, or multi-item sequence
type | B | Return value type |
param | Empty | Match for an empty list |
param | Tail | Match for a non-empty |
returns | Result of match function invoked |
method Unit Iter (Action<A> f) Source #
Impure iteration of the bound values in the structure
returns | Returns the original unmodified structure |
method Seq<B> Map <B> (Func<A, B> f) Source #
Map the sequence using the function provided
type | B | |
param | f | Mapping function |
returns | Mapped sequence |
method Unit MapInPlace (Func<A, A> f) Source #
Map the sequence using the function provided
Any functions passed as arguments may be run multiple times if there are multiple threads competing to update this data structure. Therefore the functions must spend as little time performing the injected behaviours as possible to avoid repeated attempts
type | B | |
param | f | Mapping function |
returns | Mapped sequence |
method Seq<B> Select <B> (Func<A, B> f) Source #
Map the sequence using the function provided
type | B | |
param | f | Mapping function |
returns | Mapped sequence |
method Seq<B> Bind <B> (Func<A, Seq<B>> f) Source #
Monadic bind (flatmap) of the sequence
type | B | Bound return value type |
param | f | Bind function |
returns | Flatmapped sequence |
method Unit BindInPlace <B> (Func<A, Seq<A>> f) Source #
Monadic bind (flatmap) of the sequence
Any functions passed as arguments may be run multiple times if there are multiple threads competing to update this data structure. Therefore the functions must spend as little time performing the injected behaviours as possible to avoid repeated attempts
type | B | Bound return value type |
param | f | Bind function |
returns | Flat-mapped sequence |
method Seq<C> SelectMany <B, C> (Func<A, Seq<B>> bind, Func<A, B, C> project) Source #
Monadic bind (flatmap) of the sequence
type | B | Bound return value type |
param | bind | Bind function |
returns | Flatmapped sequence |
method Seq<A> Filter (Func<A, bool> f) Source #
Filter the items in the sequence
param | f | Predicate to apply to the items |
returns | Filtered sequence |
method Unit FilterInPlace (Func<A, bool> f) Source #
Filter the items in the sequence
Any functions passed as arguments may be run multiple times if there are multiple threads competing to update this data structure. Therefore the functions must spend as little time performing the injected behaviours as possible to avoid repeated attempts
param | f | Predicate to apply to the items |
returns | Filtered sequence |
method Seq<A> Where (Func<A, bool> f) Source #
Filter the items in the sequence
param | f | Predicate to apply to the items |
returns | Filtered sequence |
method S Fold <S> (S state, Func<S, A, S> f) Source #
Fold the sequence from the first item to the last
type | S | State type |
param | state | Initial state |
param | f | Fold function |
returns | Aggregated state |
method S FoldBack <S> (S state, Func<S, A, S> f) Source #
Fold the sequence from the last item to the first. For sequences that are not lazy and are less than 5000 items long, FoldBackRec is called instead, because it is faster.
type | S | State type |
param | state | Initial state |
param | f | Fold function |
returns | Aggregated state |
method bool Exists (Func<A, bool> f) Source #
Returns true if the supplied predicate returns true for any item in the sequence. False otherwise.
param | f | Predicate to apply |
returns | True if the supplied predicate returns true for any item in the sequence. False otherwise. |
method bool ForAll (Func<A, bool> f) Source #
Returns true if the supplied predicate returns true for all items in the sequence. False otherwise. If there is an empty sequence then true is returned.
param | f | Predicate to apply |
returns | True if the supplied predicate returns true for all items in the sequence. False otherwise. If there is an empty sequence then true is returned. |
Returns true if the sequence has items in it
returns | True if the sequence has items in it |
method Unit Intersperse (A value) Source #
Inject a value in between each item in the sequence
type | A | Bound type |
param | ma | Sequence to inject values into |
param | value | Item to inject |
returns | A sequence with the values injected |
method int GetHashCode () Source #
Get the hash code for all of the items in the sequence, or 0 if empty
returns |
method string ToString () Source #
Format the collection as [a, b, c, ...]
The elipsis is used for collections over 50 items
To get a formatted string with all the items, use ToFullString
or ToFullArrayString
.
method string ToFullString (string separator = ", ") Source #
Format the collection as a, b, c, ...
method string ToFullArrayString (string separator = ", ") Source #
Format the collection as [a, b, c, ...]
method Unit TakeWhile (Func<A, bool> pred) Source #
Iterate the sequence, yielding items if they match the predicate provided, and stopping as soon as one doesn't
Any functions passed as arguments may be run multiple times if there are multiple threads competing to update this data structure. Therefore the functions must spend as little time performing the injected behaviours as possible to avoid repeated attempts
returns | A new sequence with the first items that match the predicate |
method Unit TakeWhile (Func<A, int, bool> pred) Source #
Iterate the sequence, yielding items if they match the predicate provided, and stopping as soon as one doesn't. An index value is also provided to the predicate function.
Any functions passed as arguments may be run multiple times if there are multiple threads competing to update this data structure. Therefore the functions must spend as little time performing the injected behaviours as possible to avoid repeated attempts
returns | A new sequence with the first items that match the predicate |
method int CompareTo <OrdA> (AtomSeq<A> rhs) Source #
Compare to another sequence
method IEnumerator<A> GetEnumerator () Source #
class AtomSeqExtensions Source #
method Validation<F, A> LastOrInvalid <F, A> (this AtomSeq<A> ma, F Fail) Source #
Last item in sequence.
method Validation<F, A> HeadOrInvalid <F, A> (this AtomSeq<A> ma, F Fail) Source #
Head of the sequence if this node isn't the empty node or fail
returns | Head of the sequence or fail |
method Validation<F, A> LastOrInvalid <F, A> (this AtomSeq<A> ma, Func<F> Fail) Source #
Last item in sequence.
method Validation<F, A> HeadOrInvalid <F, A> (this AtomSeq<A> ma, Func<F> Fail) Source #
Head of the sequence if this node isn't the empty node or fail
returns | Head of the sequence or fail |
method Validation<F, A> LastOrInvalid <F, A> (this AtomSeq<A> ma) Source #
Last item in sequence.
method Validation<F, A> HeadOrInvalid <F, A> (this AtomSeq<A> ma) Source #
Head of the sequence if this node isn't the empty node or fail
returns | Head of the sequence or fail |