Dictionary entry.
Exception thrown when an element access operation is performed on an empty ICollection object.
A handy shortcut for the EmptyCollection exception.
This is a subtype of Generic.Dictionary, which provides some additional functional-style methods to its base type.
Creates an empty hashtable
Creates an empty hashtable and sets its default capacity
Creates an empty hashtable and sets its default capacity and the load factor.
Creates a shallow copy of this hashtable
Clones this hashtable.
Returns `true' if the hashtable contains the specified key.
NOTE: this is the same as ContainsKey.
Folds a function over the key/value pairs.
Returns an optional value associated with the specified key.
Returns value associated with the specified key or new value. The new value obtain by call getNewValue(). The new value add to collection before return to caller. The getNewValue() called only if key not exists in collection. Example: def map = Hashtable(); Console.WriteLine(map.GetValue("1", () => 1)); // Write "1" Console.WriteLine(map.GetValue("1", () => 2)); // Write "1" Console.WriteLine(map["1"]); // Write "1"
Returns value associated with the specified key or default value (null for referece type and result of parameterless constractor for value type).
Returns value associated with the specified key or defaultValue.
Returns value associated with the specified key or result of call getDefaultValue(). The getDefaultValue() called only if key not exists in collection.
Iterates a function over the key/value pairs in the hashtable.
Maps a given function defined of key-value pairs to the contents of this hashtable. A new hashtable object is created, containing the results of the application.
This is different from add, which can fail if the key is already in the underlying Framework hashtable.
Returns a collection of the key/value pairs from this hashtable
General usage heap, can be used as priority queue.
Creates new heap that will initialy contain elements from array a. All the elements are copied into the heap, so later modifications of a do not influence the heap. This operation takes time O(n), where n is the number of elements in array a.
Creates new heap initially filled with elements from given collection
Creates a new empty heap with given initial capacity.
Private constructor, do not use from outside this class.
Builds the heap from elements stored in the m_heap array. This is done in time O (m_heap.Length).
Count is set to 0, and references to other objects from elements of the collection are also released.
Capacity remains unchanged.
Checks if given value is contained in heap. This is O(n) operation in worst case.
Copies elements from heap to given array, starting at specified index in target array
Returns the first (with maximal priority) element from the heap, removing it. Throws EmptyHeap exception.
Folds this heap's elements using the specified function and an initial value.
Grows the table that is used to store heap elements multiplying size by 2.
Repairs the heap structure starting from element at index i, moving down. For explanations see Cormen, Leiserson, Rivest "Introduction to algorithms".
Checks if the element at index k is greater than the element at index l.
Inserts a new element into the heap.
Calls the specified function for all elements of this heap.
Calculates the index of the left child of element at index i.
Creates new heap of elements of type 'b. New heap is totally independent, i.e. any changes in original heap do not influence the second one and vice versa.
Calculates the index of the parent of element at index i.
Calculates the index of the right child of element at index i.
Returns the first (with maximal priority) element from the heap without removing it. Throws EmptyHeap exception.
Returns the number of elements that this heap can store without the need to grow.
Returns number of elements in the heap.
Returns the number of elements that this heap can store without the need to grow.
Checks if the heap is empty.
Returns false.
The number of the elements that are in the heap right now
An array that stores the heap, elements are stored in heap[1]..heap[count]
The collection interface.
Creates a shallow copy of this collection.
Checks if there exists a member of collection that satisfies the supplied condition.
Filters the collection removing all elements that do not satisfy the supplied predicate.
Returns the first of the collection elements, if there is one. Throws EmptyCollection exception otherwise.
Folds the collection using the specified fold function and an initial value. Order in which the elements are folded is unspecified.
Checks if all the members of this collection satisfy the supplied predicate.
Calls the supplied function for all the elements of this collection.
Maps the supplied function to the elements of this collection, creating a new collection.
Partitions collection into two collections: elements that satisfy and elements that do not satisfy the supplied predicate.
Returns `true' if the collection is empty.
Dictionary interface. See System.Collections.IDictionary for reference.
Adds a key/value pair to the dictionary.
Clears the contents of the dictionary.
Checks if the dictionary contains a given key.
Returns an optional value associated with the specified key. This is the safe version of the default indexer property.
Returns an enumerator for this dictionary.
Removes the given key from this dictionary.
Provides access to the dictionary.
Returns a collection of the dictionary's keys.
Returns a collection of the dictionary's key/value pairs.
Returns a collection of the dictionary's values.
Dictionary enumerator interface.
Returns the dictionary entry currently pointed at by the enumerator.
Returns the key pointed at by the enumerator.
Returns the value pointed at by the enumerator.
OBSOLETE
Enumerable interface.
OBSOLETE
Enumerator interface.
Interface dedicated to be the only way to interact with Map object.
FIXME: why this isn't IDictionary?
Method returns a IMap ('a, 'b) with added pair (k, v)
Method returns an empty IMap ['a, 'b]
Method returns a copy of THIS IMap ['a, 'b]
Method returns true if and only if there exists such pair (X,Y) of THIS IMap ('a,'b) that FUNC(X,Y) is true
Method returns an IMAP that consists of THIS pair (X,Y) of THIS IMap that FUNC(X) is true
Method finds and returns a value associated with key K (if there is no such value then None is returned)
Method returns some value that is contained in IMap Note: This value depends on IMap manipulation
Method goes through each of THIS IMap pair and counts cumulative value of function FUNC with intial value INI
Method returns true if and only if for every pair (X,Y) of THIS IMap ('a,'b) FUNC(X,Y) is true
Returns the value associated with a key.
Method goes through each of THIS Imap pair (X,Y) and computes FUNC (X,Y)
Method return true if a key K is contained in THIS IMap
Method returns IMAP1 * IMAP2 where IMAP1 consists of this pair (X,Y) of IMAP1 that FUNC(X) is true and IMAP2 contains all this pairs of THIS IMap that are not in IMAP1.
Method returns THIS IMap with removed key K and associated value
Method returns THIS IMap with replaced pair (K,V)
Returns the number of elements in THIS IMap
Checks if there are any elements in the map.
Returns the number of elements in THIS IMap
Doubly linked mutable list.
Insert and Remove operations on this list require constant time irrespective of whether it is a single item or another LinkedList object, that is added.
Constructor initiliasing object with contents of a Nemerle list.
Adds item at the beginning of the list.
Append item to the list.
Append another list to an end. The source list will be cleared.
Returns shallow copy of the list.
Compares two lists item by item using Equals method of contained objects.
Compares two lists item by item using Equals method of contained objects.
Checks if there exists a member of list that satisfies the supplied condition.
Filters the list removing all elements that do not satisfy the supplied predicate.
Returns first element of the list as an option.
Folds the list using the specified fold function and an initial value. Elements are folded in order of appearance.
Checks if all the members of this list satisfy the supplied predicate.
Calls the supplied function for all the elements of the list.
Creates new list with elements from the original with supplied function applied.
Partitions list into two lists: elements that satisfy and elements that do not satisfy the supplied predicate.
Adds item at the beginning of the list.
Add given list at the beginning. The source will be cleared.
Remove all occurences of item from list
Reverses elements of the list. Complexity is O(n).
Returns string representing contents of the list.
Constructs string out of list contents using given argument as a separator.
String to use a separator - it will be put between each two items of the list.
Returns true, if the list is empty.
Returns list made from appending list y at end of list x. Original list are not modified. Works in time and memory O(length(x)).
Compare two lists lexicographically over the order defined on their elements. Returns [-1] if [l1] is smaller, [1] if [l2] is smaller, and [0] if they equal.
Compare two lists lexicographically over the order defined on their elements with function [cmp]. Returns [-1] if [l1] is smaller, [1] if [l2] is smaller, and [0] if they equal.
Makes list one level more flat, i.e. Concat([[1;2];[3;4]]) = [1;2;3;4]. Does not work deeper, i.e. Concat([[[1;2];[3]];[[4]]]) = [[1;2];[3];[4]].
List membership test, using the `Equals' method to compare objects.
This is an alias for the `Member' method.
List membership test, using the reference equality.
Returns true if and only if list [Collection] contains object with reference equal to [Obj] object
Returns a list without its last element and the list's last element
Tests equality of two lists. Uses Equal method of objects to test wether they are the same.
Returns 'true' if at least one of the 'l' list's elements satisfies the condition 'f'.
Example of use:
List.Exists (["a", "b", "abc", "d", "e"], fun (x) { x.Length > 2 })
evaluates to 'true' as there is one string of length 3 on the list.
Removes elements for which predicate is false
Returns the number of elements for which a predicate is true.
Finds the first elements for which a predicate is true.
This is an alias for ``Filter''
Alias for Concat(l).
Returns 'true' if all of the 'l' list's elements satisfy the condition 'f'.
Example of use:
List.ForAll ([2, 4, 6, 8], fun (x) { x % 2 == 0 })
evaluates to 'true' as all the list's elements are even.
Converts an array into a list.
Groups equal element into lists
Alias for Head(l).
Returns head (first element) of list. Given empty list throws System.ArgumentException.
Returns true if the given list is empty.
Returns last element of list. Given empty list throws InvalidArgument exception. Works in time O(n) and memory O(1).
Returns length of given list. Time O(n), Mem O(1).
List membership test, using the `Equals' method to compare objects.
Returns n-th element of list, where 0-th is head. Throws InvalidArgument exception when given too short list. Works in time O(n) and memory O(1).
Partitions a list into two sublists according to a predicate.
Assumes that [prod] is a product of n - 1 lists, and extends product by adding every possible element of [x] to these lists.
Returns a product of lists stored in list [list]. Elements of result are lists of the same length = List.Length (list).
E.g.: Product ([[1, 2], [3, 4, 5]]) = [[1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5]]
Product ([[1, 2], [3, 4, 5], []]) = []
Return a list of characters from 'a' to [end], excluding [end].
Return a list of characters, which values are incremented by [step], beginning with [beg], up/down to [end], excluding [end] itself.
Return a list of integers from 0 to [end], excluding [end].
Return a list of values incremented by [step], beginning with [beg], up/down to [end], excluding [end] itself.
Returns list l without elements equal to x.
Returns [l] with duplicates removed with respect to Equals method It is assumed that equal elements of [l] are next to each other, or that the list is sorted.
Example:
def result = RemoveDuplicates ([1, 2, 2, 3, 4, 4]); // result = [1, 2, 3, 4]
Return list consisting of [count] references to [elem].
Returns reversed list, i.e. Rev([1;2;3]) = [3;2;1]. Works in time and memory O(n).
Equivalent to Append(Rev(x),y).
Removes elements for which predicate is false. The resulting list is reversed (operation is faster this way).
Return list of all possible [n]-element subsets of set [list].
Return a list of all possible partitions of [set] into [count] subsets.
Returns tail (all elements except first one) of list.
Alias for Tail(l).
An enumerator for lists.
The state of a list enumerator.
OBSOLETE
just an alias for older API compatibility
An auxillary data-structure for RList used instead of a regular tuple (which is a struct) for performance reasons.
An auxillary data-structure for RList used instead of a regular tuple (which is a struct) for performance reasons.
Class representing first-in-first-out queue.
Create a new empty queue.
Alias for Enqueue.
Create a shallow copy of the queue.
Return true iff the queue contains an element that satisfies predicate f.
Remove from queue every element that does not satisfy predicate f.
Return some element from the queue, implements ICollection.First.
Fold elements of the queue with supplied function and initial value.
Return `true' iff every element of the queue satisfy predicate f.
Call supplied function for every element of the queue.
Map queue to a new queue using mapping f.
Partition the queue into two queues: first with elements that satisfy predicate f, second with the rest.
Alias for Take.
Alias for Enqueue.
Return the first element of the queue and remove it.
Alias for Peek.
Returns string representing contents of the queue.
Constructs string out of queue contents using given argument as a separator.
String to use a separator - it will be put between each two items of the list.
Transfer all elements of the queue q to the end of this queue.
Return `true` iff the queue is empty.
Alias for Count.
RList is short for Random Access List. It is a purely functional data-structure. This implementation is based on the SML sources found in Chris Okasaki's "Purely Functional Data Structures" (Cambridge University Press, 1999).
RList is short for Random Access List. It is a purely functional data-structure. This implementation is based on the SML sources found in Chris Okasaki's "Purely Functional Data Structures" (Cambridge University Press, 1999).
RList is short for Random Access List. It is a purely functional data-structure. This implementation is based on the SML sources found in Chris Okasaki's "Purely Functional Data Structures" (Cambridge University Press, 1999).
Returns an a new RList composed by appending [ys] at the end of [this]. Time complexity: roughly O (|this| * log (|this| + |ys|)).
An RListcomposed by appending [ys] at the end of [this].
The RList, which elements come second in the resulting RList.
Returns an a new RList composed by appending [ys] at the end of [xs]. Time complexity: roughly O (|xs| * log (|ys| + |xs|)).
An RList composed by appending [ys] at the end of [xs].
The RList, which elements come first in the resulting RList.
ys:The RList, which elements come second in the resulting RList.
Returns a new RList composed by adding [x], to the head of the RList [this]. Time complexity: O (log (|this|)).
A new RList composed of [x] as the new head and [this] as the new tail.
The element being added to the head of [this].
Returns a new RList composed by adding [x], to the head of the RList [xs]. Time complexity: O (log (|xs|)).
A new RList composed of [x] as the new head and [xs] as the new tail.
The element being added to the head of [xs].
xs:The RList, to which head [x] is being added.
Returns true if the element [elem] exists on the RList [this]. Time complexity: O (|this|). An alias for Member.
Returns true if for any element on the RList [this], element.Equals ([elem]), otherwise returns false.
The element, which existence on the RList [this] is being tested.
Returns true if the element [elem] exists on the RList [xs]. Time complexity: O (|xs|). An alias for Member.
Returns true if for any element on the RList [xs], element.Equals ([elem]), otherwise returns false.
The RList containing the tested elements.
elem:The element, which existence on the RList [xs] is being tested.
Checks, whether [this] and [ys] are equal RLists, by cheking if their respective elements are equal. Time complexity: O (min (|this|, |ys|)).
true if [this] and [ys] are equal, false otherwise.
The RList [this] is compared to.
Checks, whether two RLists are equal, by cheking if their respective elements are equal. Time complexity: O (min (|xs|, |ys|)).
true if [xs] and [ys] are equal, false otherwise.
The first compared RList.
ys:The second compared RList.
Checks, whether [this] and [ys] are equal RLists, by cheking if their respective elements are equal. Time complexity: O (min (|this|, |ys|)).
true if [this] and [ys] are equal, false otherwise.
The RList [this] is compared to.
Returns true if there exists an element on [this], that satisfies the predicate [f] (that is f (elem) == true). Time complexity: O (|xs|).
Returns true if for any element on the RList [this], applying [f] to that element returns true, otherwise returns false.
The predicate used during the tests.
Returns true if there exists an element on [xs], that satisfies the predicate [f] (that is f (elem) == true). Time complexity: O (|xs|).
Returns true if for any element on the RList [xs], applying [f] to that element returns true, otherwise returns false.
The RList containing the tested elements.
f:The predicate used during the tests.
Iterates over the RList [this] from left to right, composing the return value, by applying [f], to each of [this]' elements and the current [acc]. Time complexity: O (|this|).
Acc in it's final state at the last step of recursion
The accumulator being updated on each level of recursion, to finally become the return value of FoldLeft. The supplied value will be used by [f] in the first step.
f:The function being applied to ([RList-elem], [acc]) in each step.
Iterates over the RList [xs] from left to right, composing the return value, by applying [f], to each of [xs]'s elements and the current [acc]. Time complexity: O (|xs|).
Acc in it's final state at the last step of recursion
The RList over which FoldLeft is going to iterate.
acc:The accumulator being updated on each level of recursion, to finally become the return value of FoldLeft. The supplied value will be used by [f] in the first step.
f:The function being applied to ([RList-elem], [acc]) in each step.
Iterates over the RList [this] from right to left, composing the return value, by applying [f], to each of [this]' elements and the current [acc]. Time complexity: O (|this|).
The result of applying [f] to each element of [xs] and the current [acc].
The accumulator updated on each level of recursion and used by [f]. The supplied value will be used by [f] in the last step.
f:The function being applied to ([RList-elem], [acc]) in each step.
Iterates over the RList [xs] from right to left, composing the return value, by applying [f], to each of [xs]'s elements and the current [acc]. Time complexity: O (|xs|).
The result of applying [f] to each element of [xs] and the current [acc].
The RList over which FoldRight is going to iterate.
acc:The accumulator updated on each level of recursion and used by [f]. The supplied value will be used by [f] in the last step.
f:The function being applied to ([RList-elem], [acc]) in each step.
Returns an RList composed of the elements of list [xs]. Use RList (xs, |xs|) if |xs| is known. Time complexity: O (|xs|).
An RList composed of the elements of [xs].
The list used when composing the return value.
Returns an RList composed of the elements of list [xs], of length [i]. Time complexity: O (|xs|).
An RList composed of the elements of [xs].
The list used when composing the return value.
i:The length of [xs] and therefore of the return value as well.
Returns the head of the RList [xs]. Time complexity: O (log (|xs|)). An alias for Head.
Returns the head of the RList [this]. Time complexity: O (log (|this|)). An alias for Head.
The head of [xs].
The head of [this].
The RList, which head is going to be returned.
Returns the head of the RList [xs]. Time complexity: O (log (|xs|)).
Returns the head of the RList [this]. Time complexity: O (log (|this|)).
The head of [xs].
The head of [this].
The RList, which head is going to be returned.
Checks, whether the RList [xs] is empty. Time complexity: O (1).
Checks, whether [this] is an empty RList. Time complexity: O (1).
true if the [xs] is empty, false otherwise.
true if [this] is an empty RList, false otherwise.
The list to check for emptiness.
Iterates over [this] applying [f] to each of its elements. Time complexity: O (|this|).
The function being applied to every [this] element during iteration.
Iterates over [xs] applying [f] to each of its elements. Time complexity: O (|xs|).
The RList on which [f] is iterated.
f:The function being applied to every [xs] element during iteration.
Returns the last element of the RList [xs]. Time complexity: O (log (|xs|)).
Returns the last element of the RList [this]. Time complexity: O (log (|this|)).
The last element of [xs].
The last element of [this].
The RList, which last element is going to be returned.
Returns a new RList composed from [this] by applying [f] to every element on that RList. Time complexity: O (|this|).
A new RList composed from [this] by applying [f] to every element on that RList.
The function being applied to every [this] element. The values it returns will make up the new RList returned by Map.
Returns a new RList composed from [xs] by applying [f] to every element on that RList. Time complexity: O (|xs|).
A new RList composed from [xs] by applying [f] to every element on that RList.
The source RList from which the return RList is composed by applying [f] to each of its elements.
f:The function being applied to every [xs] element. The values it returns will make up the new RList returned by Map.
Returns true if the element [elem] exists on the RList [this]. Time complexity: O (|this|).
Returns true if for any element on the RList [this], element.Equals ([elem]), otherwise returns false.
The element, which existence on the RList [this] is being tested.
Returns true if the element [elem] exists on the RList [xs]. Time complexity: O (|xs|).
Returns true if for any element on the RList [xs], element.Equals ([elem]), otherwise returns false.
The RList containing the tested elements.
elem:The element, which existence on the RList [xs] is being tested.
Returns the [i]-th element of the RList [xs]. Time complexity: O (log (|xs|)).
The [i]-th element of [xs].
The RList, which [i]-th element is going to be returned.
i:The index under which the return element is located in [xs].
Returns the [i]-th element of the RList [this]. Time complexity: O (log (|this|)).
The [i]-th element of [this].
The index under which the return element is located in [this].
Returns an a new RList composed by appending [ys] at the end of [xs]. Time complexity: roughly O (|xs| * log (|ys| + |xs|)). An alias for Append.
An RList composed by appending [ys] at the end of [xs].
The RList, which elements come first in the resulting RList.
ys:The RList, which elements come second in the resulting RList.
Returns an RList composed by reversing [xs]. Time complexity: O (|xs| * log (|xs|)).
Returns an RList composed by reversing [this]. Time complexity: O (|this| * log (|this|)).
An RList composed by reversing [xs].
An RList composed by reversing [this].
The RList used when composing the return value.
Returns the tail of the RList [xs]. Time complexity: O (log (|xs|)).
Returns the tail of the RList [this]. Time complexity: O (log (|this|)).
The tail of [xs].
The tail of [this].
The RList, which tail is going to be returned.
Returns the tail of the RList [xs]. Time complexity: O (log (|xs|)). An alias for Tail.
Returns the tail of the RList [this]. Time complexity: O (log (|this|)). An alias fot Tail.
The tail of [xs].
The tail of [this].
The RList, which tail is going to be returned.
Returns a list of elements of the RList [xs] in the same order. Time complexity: O (|xs|).
Returns a list of elements of the RList [this] in the same order. Time complexity: O (|this|).
A list of elements of the RList [xs] in the same order.
A list of elements of the RList [this] in the same order.
The RList used when composing the return value.
Returns a string representation of the RList [xs]. Time complexity: O (|xs|).
Returns a string representation of the RList [this]. Time complexity: O (|this|).
A string representation of the RList [xs].
A string representation of the RList [this].
The RList used when composing the return value.
Separates and returns the head and tail of the RList [xs]. Time complexity: O (log (|xs|)).
Separates and returns the head and tail of the RList [this]. Time complexity: O (log (|this|)).
The head and tail of [xs].
The head and tail of [this].
The RList, which tail is going to be returned along with the separated head.
Returns a new RList composed by substituting the [i]-th element of the RList [this], with [x]. Time complexity: O (log (|this|)).
A new RList composed by substituting the [i]-th element of the RList [this], with [x].
The index under which the element to be substituted resides in [this].
Returns a new RList composed by substituting the [i]-th element of the RList [xs], with [x]. Time complexity: O (log (|xs|)).
A new RList composed by substituting the [i]-th element of the RList [xs], with [x].
The RList used in composing the return value.
i:The index under which the element to be substituted resides in [xs].
Returns the length of the RList [this]. Time complexity: O (log (|this|)).
The length of [this].
Returns an empty RList. Time complexity: O (1).
An empty RList.
A stack
Creates a shallow copy of this stack
See List.Exists.
See List.Filter.
Same as Peek, but does not throw an exception -- instead it returns an optional result.
See List.FoldLeft.
See List.ForAll.
See List.Iter.
See List.Map.
See List.Partition.
Returns string representing contents of the queue.
Constructs string out of queue contents using given argument as a separator.
String to use a separator - it will be put between each two items of the list.
An alias for `Count'.
Returns `true' iff the stack is empty.
An alias for `Count'.
When read -- peeks at the object on the top of the stack. When written -- replaces the topmost element with specified value (there has to be one).
OBSOLETE
just an alias for older API compatibility
A functional Red-Black Trees implementation
Internal functions used for tree balancing
Functions returns TREE1 * INT1 where TREE1 is a tree that contains this nodes X of TREE that FUNC(X) is true and INT1 is the size of TREE1
Function returns TREE1 * INT1 * TREE2 * INT2 where tree TREE1 consists of this nodes X of TREE that FUNC(X) is true and tree TREE2 contains all nodes of TREE that are not in TREE1. INT1 is the size of TREE1 and INT2 is the size of TREE2
Function returns a passed tree TREE with removed element ELEM. If element was not in the tree exception is thrown.
Function returns true if and only if there exists such node X of TREE that FUNC(X) is true
Functions returns a tree that contains this nodes X of TREE that FUNC(X) is true
Function goes through each TREE node and counts cumulative value of function FUNC with intial value INI
Function returns true if and only if for every node X of TREE FUNC(X) is true
Function finds a node and returns it (if any) as an option ['a]
Function returns a passed tree TREE with inserted element ELEM. If node is already present in tree either throw exception or replace node, depending on REPLACE.
Function returns TREE1 * TREE2 where tree TREE1 consists of this nodes X of TREE that FUNC(X) is true and tree TREE2 contains all nodes of TREE that are not in TREE1.
OBSOLETE
Just a little extension of System.Collections.Generic.List
OBSOLETE