diff --git a/src/FSharpx.Collections.Experimental/AssemblyInfo.fs b/src/FSharpx.Collections.Experimental/AssemblyInfo.fs index aeed0d4d..329acac8 100644 --- a/src/FSharpx.Collections.Experimental/AssemblyInfo.fs +++ b/src/FSharpx.Collections.Experimental/AssemblyInfo.fs @@ -1,5 +1,6 @@ // Auto-Generated by FAKE; do not edit namespace System + open System.Reflection open System.Runtime.CompilerServices @@ -14,11 +15,27 @@ open System.Runtime.CompilerServices do () module internal AssemblyVersionInformation = - let [] AssemblyTitle = "FSharpx.Collections.Experimental" - let [] AssemblyProduct = "FSharpx.Collections" - let [] AssemblyDescription = "FSharpx.Collections is a collection of datastructures for use with F# and C#." - let [] InternalsVisibleTo = "FSharpx.Collections.Tests" - let [] InternalsVisibleTo_1 = "FSharpx.Collections.Experimental.Tests" - let [] AssemblyVersion = "3.1.0" - let [] AssemblyFileVersion = "3.1.0" - let [] AssemblyConfiguration = "Release" + [] + let AssemblyTitle = "FSharpx.Collections.Experimental" + + [] + let AssemblyProduct = "FSharpx.Collections" + + [] + let AssemblyDescription = + "FSharpx.Collections is a collection of datastructures for use with F# and C#." + + [] + let InternalsVisibleTo = "FSharpx.Collections.Tests" + + [] + let InternalsVisibleTo_1 = "FSharpx.Collections.Experimental.Tests" + + [] + let AssemblyVersion = "3.1.0" + + [] + let AssemblyFileVersion = "3.1.0" + + [] + let AssemblyConfiguration = "Release" diff --git a/src/FSharpx.Collections.Experimental/FlatList.fsi b/src/FSharpx.Collections.Experimental/FlatList.fsi index 9d50fa3b..4a3a6e38 100644 --- a/src/FSharpx.Collections.Experimental/FlatList.fsi +++ b/src/FSharpx.Collections.Experimental/FlatList.fsi @@ -1,123 +1,123 @@ -namespace FSharpx.Collections.Experimental +namespace FSharpx.Collections.Experimental [] type FlatList<'T> = - val internal array : 'T[] + val internal array: 'T[] interface System.Collections.Generic.IEnumerable<'T> interface System.Collections.IEnumerable /// O(1). Returns flatlist element at the index. - member Item : int -> 'T with get + member Item: int -> 'T with get /// O(1). Returns the number of items in the flatlist. - member Length : int + member Length: int /// O(1). Returns true if the flatlist has no elements. - member IsEmpty : bool + member IsEmpty: bool [] module FlatList = /// O(n). Creates a flatlist that contains the elements of one flatlist followed by the elements of another flatlist. - val append : FlatList<'T> -> FlatList<'T> -> FlatList<'T> + val append: FlatList<'T> -> FlatList<'T> -> FlatList<'T> ///O(n). Applies the supplied function to each element of a flatlist, concatenates the results, and returns the combined flatlist. - val collect : ('T -> FlatList<'T>) -> FlatList<'T> -> FlatList<'T> + val collect: ('T -> FlatList<'T>) -> FlatList<'T> -> FlatList<'T> /// O(n). Creates a flatlist that contains the elements of each of the supplied sequence of flatlists. - val concat : FlatList<'T []> -> FlatList<'T> + val concat: FlatList<'T[]> -> FlatList<'T> /// O(1). Returns flatlist of no elements. [] - val empty<'T> : FlatList<'T> + val empty<'T> : FlatList<'T> /// O(n) worst case. Tests whether any element of a flatlist satisfies the supplied predicate. - val exists : ('T -> bool) -> FlatList<'T> -> bool + val exists: ('T -> bool) -> FlatList<'T> -> bool /// O(n). Returns a flatlist that contains only the elements of the supplied flatlist for which the supplied condition returns true. - val filter : ('T -> bool) -> FlatList<'T> -> FlatList<'T> + val filter: ('T -> bool) -> FlatList<'T> -> FlatList<'T> - /// O(n). Applies a function to each element of a flatlist from left to right (first to last), threading an accumulator argument through the computation. - val fold : ('State -> 'T -> 'State) -> 'State -> FlatList<'T> -> 'State + /// O(n). Applies a function to each element of a flatlist from left to right (first to last), threading an accumulator argument through the computation. + val fold: ('State -> 'T -> 'State) -> 'State -> FlatList<'T> -> 'State /// O(n). Applies a function to pairs of elements from two supplied flatlists, left-to-right, threading an accumulator argument through the computation. The two input flatlists must have the same lengths; otherwise, ArgumentException is raised. - val fold2 : ('State -> 'T1 -> 'T2 -> 'State) -> 'State -> FlatList<'T1> -> FlatList<'T2> -> 'State - + val fold2: ('State -> 'T1 -> 'T2 -> 'State) -> 'State -> FlatList<'T1> -> FlatList<'T2> -> 'State + /// O(n). Applies a function to each element of a flatlist from right to left (last to first), threading an accumulator argument through the computation. - val foldBack : ('T -> 'State -> 'State) -> FlatList<'T> -> 'State -> 'State + val foldBack: ('T -> 'State -> 'State) -> FlatList<'T> -> 'State -> 'State /// O(n). Applies a function to pairs of elements from two supplied flatlists, right-to-left, threading an accumulator argument through the computation. The two input flatlists must have the same lengths; otherwise, ArgumentException is raised. - val foldBack2 : ('T1 -> 'T2 -> 'State -> 'State) -> FlatList<'T1> -> FlatList<'T2> -> 'State -> 'State + val foldBack2: ('T1 -> 'T2 -> 'State -> 'State) -> FlatList<'T1> -> FlatList<'T2> -> 'State -> 'State /// O(n). Tests whether all elements of a flatlist satisfy the supplied condition. - val forall : ('T -> bool) -> FlatList<'T> -> bool + val forall: ('T -> bool) -> FlatList<'T> -> bool /// O(n). Tests whether all corresponding elements of two supplied flatlists satisfy a supplied condition. - val forall2 : ('T1 -> 'T2 -> bool) -> FlatList<'T1> -> FlatList<'T2> -> bool + val forall2: ('T1 -> 'T2 -> bool) -> FlatList<'T1> -> FlatList<'T2> -> bool /// O(n). Uses a supplied function to create a flatlist of the supplied dimension. - val init : int -> f:(int -> 'T) -> FlatList<'T> - + val init: int -> f: (int -> 'T) -> FlatList<'T> + /// O(1). O(1). Returns true if the flatlist has no elements. - val isEmpty : FlatList<'T> -> bool - + val isEmpty: FlatList<'T> -> bool + /// O(n). Applies the supplied function to each element of a flatlist. - val iter : ('T -> unit) -> FlatList<'T> -> unit + val iter: ('T -> unit) -> FlatList<'T> -> unit /// O(n). Applies the supplied function to a pair of elements from matching indexes in two flatlists, also passing the index of the elements. The two flatlists must have the same lengths; otherwise, an ArgumentException is raised. - val iter2 : ('T1 -> 'T2 -> unit) -> FlatList<'T1> -> FlatList<'T2> -> unit + val iter2: ('T1 -> 'T2 -> unit) -> FlatList<'T1> -> FlatList<'T2> -> unit /// O(n). Applies the supplied function to each element of a flatlist. The integer passed to the function indicates the index of the element. - val iteri : (int -> 'T -> unit) -> FlatList<'T> -> unit + val iteri: (int -> 'T -> unit) -> FlatList<'T> -> unit /// O(1). Returns the number of items in the flatlist. - val length : FlatList<'T> -> int + val length: FlatList<'T> -> int /// O(n). Creates a flatlist whose elements are the results of applying the supplied function to each of the elements of a supplied flatlist. - val map : ('T1 -> 'T2) -> FlatList<'T1> -> FlatList<'T2> + val map: ('T1 -> 'T2) -> FlatList<'T1> -> FlatList<'T2> /// O(n). Creates a flatlist whose elements are the results of applying the supplied function to the corresponding elements of two supplied flatlists. The two input flatlists must have the same lengths; otherwise, ArgumentException is raised. - val map2 : ('T1 -> 'T2 -> 'T3) -> FlatList<'T1> -> FlatList<'T2> -> FlatList<'T3> + val map2: ('T1 -> 'T2 -> 'T3) -> FlatList<'T1> -> FlatList<'T2> -> FlatList<'T3> /// O(n). Creates a flatlist whose elements are the results of applying the supplied function to each of the elements of a supplied flatlist. An integer index passed to the function indicates the index of the element being transformed. - val mapi : (int -> 'T1 -> 'T2) -> FlatList<'T1> -> FlatList<'T2> + val mapi: (int -> 'T1 -> 'T2) -> FlatList<'T1> -> FlatList<'T2> /// O(n). Creates a flatlist from the supplied list. - val ofList : 'T list -> FlatList<'T> - + val ofList: 'T list -> FlatList<'T> + /// O(n). Creates a flatlist from the supplied enumerable object. - val ofSeq : seq<'T> -> FlatList<'T> + val ofSeq: seq<'T> -> FlatList<'T> /// O(n). Splits a flatlist into two flatlists, one containing the elements for which the supplied condition returns true, and the other containing those for which it returns false. - val partition : ('T -> bool) -> FlatList<'T> -> FlatList<'T> * FlatList<'T> + val partition: ('T -> bool) -> FlatList<'T> -> FlatList<'T> * FlatList<'T> /// O(1). True if the flatlists are reference-equal, false otherwise - val physicalEquality : FlatList<'T> -> FlatList<'T> -> bool + val physicalEquality: FlatList<'T> -> FlatList<'T> -> bool /// O(n). Reverses the order of the elements in a supplied array. - val rev : FlatList<'T> -> FlatList<'T> + val rev: FlatList<'T> -> FlatList<'T> /// O(1). Returns a flatlist of one element. - val singleton : 'T -> FlatList<'T> + val singleton: 'T -> FlatList<'T> /// O(n). Returns the sum of the elements in the flatlist. - val sum : FlatList -> int + val sum: FlatList -> int /// O(n). Returns the sum of the results generated by applying a function to each element of a flatlist. - val sumBy : ('T -> int) -> FlatList<'T> -> int + val sumBy: ('T -> int) -> FlatList<'T> -> int /// O(n). Converts the supplied flatlist to a list. - val toList : FlatList<'T> -> 'T list + val toList: FlatList<'T> -> 'T list /// O(n). Converts the supplied flatlist of tuple pairs to a map. - val toMap : FlatList<'Key * 'T> -> Map<'Key,'T> when 'Key : comparison + val toMap: FlatList<'Key * 'T> -> Map<'Key, 'T> when 'Key: comparison /// O(n). Returns the first element in the supplied flatlist for which the supplied function returns true. Returns None if no such element exists. - val tryFind : ('T -> bool) -> FlatList<'T> -> 'T option + val tryFind: ('T -> bool) -> FlatList<'T> -> 'T option /// O(n). Splits a flatlist of tuple pairs into a tuple of two flatlists. - val unzip : FlatList<'T1 * 'T2> -> FlatList<'T1> * FlatList<'T2> + val unzip: FlatList<'T1 * 'T2> -> FlatList<'T1> * FlatList<'T2> /// O(n). Combines two flatlists into a flatlist of tuples that have two elements. The two flatlists must have equal lengths; otherwise, ArgumentException is raised. - val zip : FlatList<'T1> -> FlatList<'T2> -> FlatList<'T1 * 'T2> \ No newline at end of file + val zip: FlatList<'T1> -> FlatList<'T2> -> FlatList<'T1 * 'T2> diff --git a/src/FSharpx.Collections/AssemblyInfo.fs b/src/FSharpx.Collections/AssemblyInfo.fs index bd6e200f..b156bd37 100644 --- a/src/FSharpx.Collections/AssemblyInfo.fs +++ b/src/FSharpx.Collections/AssemblyInfo.fs @@ -1,5 +1,6 @@ // Auto-Generated by FAKE; do not edit namespace System + open System.Reflection open System.Runtime.CompilerServices @@ -14,11 +15,27 @@ open System.Runtime.CompilerServices do () module internal AssemblyVersionInformation = - let [] AssemblyTitle = "FSharpx.Collections" - let [] AssemblyProduct = "FSharpx.Collections" - let [] AssemblyDescription = "FSharpx.Collections is a collection of datastructures for use with F# and C#." - let [] InternalsVisibleTo = "FSharpx.Collections.Tests" - let [] InternalsVisibleTo_1 = "FSharpx.Collections.Experimental.Tests" - let [] AssemblyVersion = "3.1.0" - let [] AssemblyFileVersion = "3.1.0" - let [] AssemblyConfiguration = "Release" + [] + let AssemblyTitle = "FSharpx.Collections" + + [] + let AssemblyProduct = "FSharpx.Collections" + + [] + let AssemblyDescription = + "FSharpx.Collections is a collection of datastructures for use with F# and C#." + + [] + let InternalsVisibleTo = "FSharpx.Collections.Tests" + + [] + let InternalsVisibleTo_1 = "FSharpx.Collections.Experimental.Tests" + + [] + let AssemblyVersion = "3.1.0" + + [] + let AssemblyFileVersion = "3.1.0" + + [] + let AssemblyConfiguration = "Release" diff --git a/src/FSharpx.Collections/CircularBuffer.fsi b/src/FSharpx.Collections/CircularBuffer.fsi index d9de8a54..42e0f896 100644 --- a/src/FSharpx.Collections/CircularBuffer.fsi +++ b/src/FSharpx.Collections/CircularBuffer.fsi @@ -9,22 +9,22 @@ type CircularBuffer<'T> = interface System.Collections.Generic.IReadOnlyCollection<'T> /// needs doc - new : bufferSize:int -> CircularBuffer<'T> + new: bufferSize: int -> CircularBuffer<'T> /// needs doc - member Dequeue : count:int -> 'T [] + member Dequeue: count: int -> 'T[] /// needs doc - member Enqueue : value:'T [] -> unit + member Enqueue: value: 'T[] -> unit #if !FABLE_COMPILER /// needs doc - member Enqueue : value:ArraySegment<'T> -> unit + member Enqueue: value: ArraySegment<'T> -> unit #endif /// needs doc - member Enqueue : value:'T -> unit + member Enqueue: value: 'T -> unit /// needs doc - member Enqueue : value:'T [] * offset:int -> unit + member Enqueue: value: 'T[] * offset: int -> unit /// needs doc - member Enqueue : value:'T [] * offset:int * count:int -> unit + member Enqueue: value: 'T[] * offset: int * count: int -> unit /// needs doc - member GetEnumerator : unit -> System.Collections.Generic.IEnumerator<'T> + member GetEnumerator: unit -> System.Collections.Generic.IEnumerator<'T> /// needs doc - member Count : int + member Count: int diff --git a/src/FSharpx.Collections/DList.fsi b/src/FSharpx.Collections/DList.fsi index 40160d61..b909221a 100644 --- a/src/FSharpx.Collections/DList.fsi +++ b/src/FSharpx.Collections/DList.fsi @@ -12,45 +12,45 @@ type DList<'T> = interface System.Collections.Generic.IReadOnlyCollection<'T> ///O(1). Returns the count of elememts. - member Length : int + member Length: int ///O(1). Returns a new DList with the element added to the front. - member Cons : 'T -> DList<'T> + member Cons: 'T -> DList<'T> ///O(log n). Returns the first element. - member Head : 'T + member Head: 'T ///O(log n). Returns option first element - member TryHead : 'T option + member TryHead: 'T option ///O(1). Returns true if the DList has no elements. - member IsEmpty : bool + member IsEmpty: bool ///O(1). Returns a new DList with the element added to the end. - member Conj : 'T -> DList<'T> + member Conj: 'T -> DList<'T> ///O(log n). Returns a new DList of the elements trailing the first element. - member Tail : DList<'T> + member Tail: DList<'T> ///O(log n). Returns option DList of the elements trailing the first element. - member TryTail : DList<'T> option + member TryTail: DList<'T> option ///O(log n). Returns the first element and tail. - member Uncons : 'T * DList<'T> + member Uncons: 'T * DList<'T> ///O(log n). Returns option first element and tail. - member TryUncons : ('T * DList<'T>) option + member TryUncons: ('T * DList<'T>) option [] module DList = //pattern discriminators (active pattern) - val (|Cons|Nil|) : DList<'T> -> Choice<('T * DList<'T>),unit> + val (|Cons|Nil|): DList<'T> -> Choice<('T * DList<'T>), unit> ///O(1). Returns a new DList of two lists. - val append : DList<'T> -> DList<'T> -> DList<'T> + val append: DList<'T> -> DList<'T> -> DList<'T> ///O(1). Returns a new DList with the element added to the beginning. - val cons : 'T -> DList<'T> -> DList<'T> + val cons: 'T -> DList<'T> -> DList<'T> ///O(1). Returns DList of no elements. [] @@ -58,48 +58,48 @@ module DList = ///O(n). Fold walks the DList using constant stack space. Implementation is from Norman Ramsey. /// See http://stackoverflow.com/questions/5324623/functional-o1-append-and-on-iteration-from-first-element-list-data-structure/5334068#5334068 - val foldBack : ('T -> 'State -> 'State) -> DList<'T> -> 'State -> 'State + val foldBack: ('T -> 'State -> 'State) -> DList<'T> -> 'State -> 'State - val fold : ('State -> 'T -> 'State) -> 'State -> DList<'T> -> 'State + val fold: ('State -> 'T -> 'State) -> 'State -> DList<'T> -> 'State ///O(log n). Returns the first element. - val inline head : DList<'T> -> 'T + val inline head: DList<'T> -> 'T ///O(log n). Returns option first element. - val inline tryHead : DList<'T> -> 'T option + val inline tryHead: DList<'T> -> 'T option ///O(1). Returns true if the DList has no elements. - val inline isEmpty : DList<'T> -> bool + val inline isEmpty: DList<'T> -> bool ///O(1). Returns the count of elememts. - val inline length : DList<'T> -> int + val inline length: DList<'T> -> int ///O(1). Returns DList of one elements. - val singleton : 'T -> DList<'T> + val singleton: 'T -> DList<'T> ///O(1). Returns a new DList with the element added to the end. - val inline conj : 'T -> DList<'T> -> DList<'T> + val inline conj: 'T -> DList<'T> -> DList<'T> ///O(log n). Returns a new DList of the elements trailing the first element. - val inline tail : DList<'T> -> DList<'T> + val inline tail: DList<'T> -> DList<'T> ///O(log n). Returns option DList of the elements trailing the first element. - val inline tryTail : DList<'T> -> DList<'T> option + val inline tryTail: DList<'T> -> DList<'T> option ///O(log n). Returns the first element and tail. - val inline uncons : DList<'T> -> 'T * DList<'T> + val inline uncons: DList<'T> -> 'T * DList<'T> ///O(log n). Returns option first element and tail. - val inline tryUncons : DList<'T> -> ('T * DList<'T>) option + val inline tryUncons: DList<'T> -> ('T * DList<'T>) option ///O(n). Returns a DList of the seq. - val ofSeq : seq<'T> -> DList<'T> + val ofSeq: seq<'T> -> DList<'T> ///O(n). Returns a list of the DList elements. - val inline toList : DList<'T> -> list<'T> + val inline toList: DList<'T> -> list<'T> ///O(n). Returns a seq of the DList elements. - val inline toSeq : DList<'T> -> seq<'T> + val inline toSeq: DList<'T> -> seq<'T> ///O(n). Returns a pairwise DList of elements. - val pairwise : DList<'T> -> DList<'T*'T> + val pairwise: DList<'T> -> DList<'T * 'T> diff --git a/src/FSharpx.Collections/Deque.fsi b/src/FSharpx.Collections/Deque.fsi index 6a3da772..e7b0fe14 100644 --- a/src/FSharpx.Collections/Deque.fsi +++ b/src/FSharpx.Collections/Deque.fsi @@ -12,136 +12,136 @@ type Deque<'T> = interface System.Collections.Generic.IReadOnlyCollection<'T> ///O(1). Returns a new deque with the element added to the end. - member Conj : 'T -> Deque<'T> + member Conj: 'T -> Deque<'T> ///O(1). Returns a new deque with the element added to the beginning. - member Cons : 'T -> Deque<'T> + member Cons: 'T -> Deque<'T> ///O(1) amortized, O(n), worst case. Returns the first element. - member Head : 'T + member Head: 'T ///O(1) amortized, O(n), worst case. Returns option first element. - member TryHead : 'T option + member TryHead: 'T option ///O(1) amortized, O(n), worst case. Returns a new deque of the elements before the last element. - member Initial : Deque<'T> + member Initial: Deque<'T> ///O(1) amortized, O(n), worst case. Returns a new deque of the elements before the last element. - member TryInitial : Deque<'T> option + member TryInitial: Deque<'T> option ///O(1). Returns true if the deque has no elements. - member IsEmpty : bool + member IsEmpty: bool ///O(1) amortized, O(n), worst case. Returns the last element. - member Last : 'T + member Last: 'T ///O(1) amortized, O(n), worst case. Returns option last element. - member TryLast : 'T option + member TryLast: 'T option ///O(1). Returns the count of elememts. - member Length : int + member Length: int ///O(1). Returns deque reversed. - member Rev : Deque<'T> + member Rev: Deque<'T> ///O(1) amortized, O(n), worst case. Returns a new deque of the elements trailing the first element. - member Tail : Deque<'T> + member Tail: Deque<'T> ///O(1) amortized, O(n), worst case. Returns option deque of the elements trailing the first element. - member TryTail : Deque<'T> option + member TryTail: Deque<'T> option ///O(1) amortized, O(n), worst case. Returns init and the last element. - member Unconj : Deque<'T> * 'T + member Unconj: Deque<'T> * 'T ///O(1) amortized, O(n), worst case. Returns option init and the last element. - member TryUnconj : (Deque<'T> * 'T) option + member TryUnconj: (Deque<'T> * 'T) option ///O(1) amortized, O(n), worst case. Returns the first element and tail. - member Uncons : 'T * Deque<'T> + member Uncons: 'T * Deque<'T> ///O(1) amortized, O(n), worst case. Returns option first element and tail. - member TryUncons : ('T * Deque<'T>) option + member TryUncons: ('T * Deque<'T>) option [] module Deque = //pattern discriminators - val (|Cons|Nil|) : Deque<'T> -> Choice<('T * Deque<'T>),unit> + val (|Cons|Nil|): Deque<'T> -> Choice<('T * Deque<'T>), unit> - val (|Conj|Nil|) : Deque<'T> -> Choice<(Deque<'T> * 'T),unit> + val (|Conj|Nil|): Deque<'T> -> Choice<(Deque<'T> * 'T), unit> ///O(1). Returns a new deque with the element added to the end. - val inline conj : 'T -> Deque<'T> -> Deque<'T> + val inline conj: 'T -> Deque<'T> -> Deque<'T> ///O(1). Returns a new deque with the element added to the beginning. - val inline cons : 'T -> Deque<'T> -> Deque<'T> + val inline cons: 'T -> Deque<'T> -> Deque<'T> ///O(1). Returns deque of no elements. [] val empty<'T> : Deque<'T> ///O(n). Applies a function to each element of the deque, threading an accumulator argument through the computation, left to right - val fold : ('State -> 'T -> 'State) -> 'State -> Deque<'T> -> 'State + val fold: ('State -> 'T -> 'State) -> 'State -> Deque<'T> -> 'State ///O(n). Applies a function to each element of the deque, threading an accumulator argument through the computation, right to left - val foldBack : ('T -> 'State -> 'State) -> Deque<'T> -> 'State -> 'State + val foldBack: ('T -> 'State -> 'State) -> Deque<'T> -> 'State -> 'State ///O(1) amortized, O(n), worst case. Returns the first element. - val inline head : Deque<'T> -> 'T + val inline head: Deque<'T> -> 'T ///O(1) amortized, O(n), worst case. Returns option first element. - val inline tryHead : Deque<'T> -> 'T option + val inline tryHead: Deque<'T> -> 'T option ///O(1) amortized, O(n), worst case. Returns a new deque of the elements before the last element. - val inline initial : Deque<'T> -> Deque<'T> + val inline initial: Deque<'T> -> Deque<'T> ///O(1) amortized, O(n), worst case. Returns option deque of the elements before the last element. - val inline tryInitial : Deque<'T> -> Deque<'T> option + val inline tryInitial: Deque<'T> -> Deque<'T> option ///O(1). Returns true if the deque has no elements. - val inline isEmpty : Deque<'T> -> bool + val inline isEmpty: Deque<'T> -> bool ///O(1) amortized, O(n), worst case. Returns the last element. - val inline last : Deque<'T> -> 'T + val inline last: Deque<'T> -> 'T ///O(1) amortized, O(n), worst case. Returns option last element. - val inline tryLast : Deque<'T> -> 'T option + val inline tryLast: Deque<'T> -> 'T option ///O(1). Returns the count of elememts. - val inline length : Deque<'T> -> int + val inline length: Deque<'T> -> int ///O(n), worst case. Returns a deque of the two lists concatenated. - val ofCatLists : 'T list -> 'T list -> Deque<'T> + val ofCatLists: 'T list -> 'T list -> Deque<'T> ///O(n), worst case. Returns a deque of the list. - val ofList : 'T list -> Deque<'T> + val ofList: 'T list -> Deque<'T> ///O(n), worst case. Returns a deque of the seq. - val ofSeq : seq<'T> -> Deque<'T> + val ofSeq: seq<'T> -> Deque<'T> ///O(1). Returns deque reversed. - val inline rev : Deque<'T> -> Deque<'T> + val inline rev: Deque<'T> -> Deque<'T> ///O(1). Returns a deque of one element. - val singleton : 'T -> Deque<'T> + val singleton: 'T -> Deque<'T> ///O(1) amortized, O(n), worst case. Returns a new deque of the elements trailing the first element. - val inline tail : Deque<'T> -> Deque<'T> + val inline tail: Deque<'T> -> Deque<'T> ///O(1) amortized, O(n), worst case. Returns option deque of the elements trailing the first element. - val inline tryTail : Deque<'T> -> Deque<'T> option + val inline tryTail: Deque<'T> -> Deque<'T> option ///O(1) amortized, O(n), worst case. Returns init and the last element. - val inline unconj : Deque<'T> -> Deque<'T> * 'T + val inline unconj: Deque<'T> -> Deque<'T> * 'T ///O(1) amortized, O(n), worst case. Returns option init and the last element. - val inline tryUnconj : Deque<'T> -> (Deque<'T> * 'T) option + val inline tryUnconj: Deque<'T> -> (Deque<'T> * 'T) option ///O(1) amortized, O(n), worst case. Returns the first element and tail. - val inline uncons : Deque<'T> -> 'T * Deque<'T> + val inline uncons: Deque<'T> -> 'T * Deque<'T> ///O(n). Views the given deque as a sequence. - val inline toSeq : Deque<'T> -> seq<'T> + val inline toSeq: Deque<'T> -> seq<'T> ///O(1) amortized, O(n), worst case. Returns option first element and tail. - val inline tryUncons : Deque<'T> -> ('T * Deque<'T>) option + val inline tryUncons: Deque<'T> -> ('T * Deque<'T>) option diff --git a/src/FSharpx.Collections/LazyList.fsi b/src/FSharpx.Collections/LazyList.fsi index d039e8d7..8c99f156 100644 --- a/src/FSharpx.Collections/LazyList.fsi +++ b/src/FSharpx.Collections/LazyList.fsi @@ -28,32 +28,32 @@ type LazyList<'T> = ///O(1). Test if a list is empty. Forces the evaluation of /// the first element of the stream if it is not already evaluated. - member IsEmpty : bool + member IsEmpty: bool ///O(1). Return the first element of the list. Forces the evaluation of /// the first cell of the list if it is not already evaluated. - member Head : 'T + member Head: 'T ///O(n). Return the length of the list - member Length : unit -> int + member Length: unit -> int ///O(1). Return option the first element of the list. Forces the evaluation of /// the first cell of the list if it is not already evaluated. - member TryHead : 'T option + member TryHead: 'T option ///O(1). Return the list corresponding to the remaining items in the sequence. /// Forces the evaluation of the first cell of the list if it is not already evaluated. - member Tail : LazyList<'T> + member Tail: LazyList<'T> ///O(1). Return option the list corresponding to the remaining items in the sequence. /// Forces the evaluation of the first cell of the list if it is not already evaluated. - member TryTail : LazyList<'T> option + member TryTail: LazyList<'T> option ///O(1). Returns tuple of head element and tail of the list. - member Uncons : 'T * LazyList<'T> + member Uncons: 'T * LazyList<'T> ///O(1). Returns option tuple of head element and tail of the list. - member TryUncons : ('T * LazyList<'T>) option + member TryUncons: ('T * LazyList<'T>) option [] module LazyList = @@ -64,141 +64,141 @@ module LazyList = ///O(1). Return the first element of the list. Forces the evaluation of /// the first cell of the list if it is not already evaluated. - val head : LazyList<'T> -> 'T + val head: LazyList<'T> -> 'T ///O(1). Return option the first element of the list. Forces the evaluation of /// the first cell of the list if it is not already evaluated. - val tryHead : LazyList<'T> -> 'T option + val tryHead: LazyList<'T> -> 'T option ///O(1). Return the list corresponding to the remaining items in the sequence. /// Forces the evaluation of the first cell of the list if it is not already evaluated. - val tail : LazyList<'T> -> LazyList<'T> + val tail: LazyList<'T> -> LazyList<'T> ///O(1). Return option the list corresponding to the remaining items in the sequence. /// Forces the evaluation of the first cell of the list if it is not already evaluated. - val tryTail : LazyList<'T> -> LazyList<'T> option + val tryTail: LazyList<'T> -> LazyList<'T> option ///O(1). Returns tuple of head element and tail of the list. - val uncons : LazyList<'T> -> 'T * LazyList<'T> + val uncons: LazyList<'T> -> 'T * LazyList<'T> ///O(1). Returns option tuple of head element and tail of the list. - val tryUncons : LazyList<'T> -> ('T * LazyList<'T>) option + val tryUncons: LazyList<'T> -> ('T * LazyList<'T>) option ///O(n), where n is count. Return the list which on consumption will consist of at most 'n' elements of /// the input list. - val take : count:int -> source:LazyList<'T> -> LazyList<'T> + val take: count: int -> source: LazyList<'T> -> LazyList<'T> ///O(n), where n is count. Return the list which on consumption will remove of at most 'n' elements of /// the input list. - val drop : count:int -> source:LazyList<'T> -> LazyList<'T> + val drop: count: int -> source: LazyList<'T> -> LazyList<'T> ///O(n), where n is count. Return the list which on consumption will consist of at most 'n' elements of /// the input list. - val tryTake : count:int -> source:LazyList<'T> -> LazyList<'T> option + val tryTake: count: int -> source: LazyList<'T> -> LazyList<'T> option ///O(n), where n is count. Return the list which on consumption will skip the first 'n' elements of /// the input list. - val skip : count:int -> source:LazyList<'T> -> LazyList<'T> + val skip: count: int -> source: LazyList<'T> -> LazyList<'T> ///O(n), where n is count. Return option the list which skips the first 'n' elements of /// the input list. - val trySkip : count:int -> source:LazyList<'T> -> LazyList<'T> option + val trySkip: count: int -> source: LazyList<'T> -> LazyList<'T> option ///O(n). /// it applies a function to each element of a list, /// passing an accumulating parameter from left to right, - val fold : f:('T1 -> 'T2 -> 'T1) -> s:'T1 -> l:LazyList<'T2> -> 'T1 + val fold: f: ('T1 -> 'T2 -> 'T1) -> s: 'T1 -> l: LazyList<'T2> -> 'T1 ///O(n). Behaves like a combination of map and fold; /// it applies a function to each element of a list, /// passing an accumulating parameter from left to right, /// and returning a final value of this accumulator together with the new list. - val mapAccum : f:('T1 -> 'T2 -> 'T1 * 'T3) -> s:'T1 -> l:LazyList<'T2> -> 'T1 * LazyList<'T3> + val mapAccum: f: ('T1 -> 'T2 -> 'T1 * 'T3) -> s: 'T1 -> l: LazyList<'T2> -> 'T1 * LazyList<'T3> ///O(n), worst case. Apply the given function to successive elements of the list, returning the first /// result where function returns Some(x) for some x. If the function never returns /// true, 'None' is returned. - val tryFind : predicate:('T -> bool) -> source:LazyList<'T> -> 'T option + val tryFind: predicate: ('T -> bool) -> source: LazyList<'T> -> 'T option ///O(n), worst case. Return the first element for which the given function returns true. /// Raise KeyNotFoundException if no such element exists. - val find : predicate:('T -> bool) -> source:LazyList<'T> -> 'T + val find: predicate: ('T -> bool) -> source: LazyList<'T> -> 'T ///O(1). Evaluates to the list that contains no items [] - val empty<'T> : LazyList<'T> + val empty<'T> : LazyList<'T> ///O(n). Return the length of the list - val length: list:LazyList<'T> -> int + val length: list: LazyList<'T> -> int ///O(1). Return a new list which contains the given item followed by the /// given list. - val cons : 'T -> LazyList<'T> -> LazyList<'T> + val cons: 'T -> LazyList<'T> -> LazyList<'T> ///O(1). Return a new list which on consumption contains the given item /// followed by the list returned by the given computation. The - val consDelayed : 'T -> (unit -> LazyList<'T>) -> LazyList<'T> + val consDelayed: 'T -> (unit -> LazyList<'T>) -> LazyList<'T> ///O(1). Return the list which on consumption will consist of an infinite sequence of /// the given item - val repeat : 'T -> LazyList<'T> + val repeat: 'T -> LazyList<'T> ///O(1). Return a list that is in effect the list returned by the given computation. /// The given computation is not executed until the first element on the list is /// consumed. - val delayed : (unit -> LazyList<'T>) -> LazyList<'T> + val delayed: (unit -> LazyList<'T>) -> LazyList<'T> ///O(1). Return a list that contains the elements returned by the given computation. /// The given computation is not executed until the first element on the list is /// consumed. The given argument is passed to the computation. Subsequent elements /// in the list are generated by again applying the residual 'b to the computation. - val unfold : ('State -> ('T * 'State) option) -> 'State -> LazyList<'T> + val unfold: ('State -> ('T * 'State) option) -> 'State -> LazyList<'T> ///O(1). Return the list which contains on demand the elements of the first list followed /// by the elements of the second list - val append : LazyList<'T> -> source:LazyList<'T> -> LazyList<'T> + val append: LazyList<'T> -> source: LazyList<'T> -> LazyList<'T> ///O(1). Return the list which contains on demand the pair of elements of the first and second list - val zip : LazyList<'T1> -> LazyList<'T2> -> LazyList<'T1 * 'T2> + val zip: LazyList<'T1> -> LazyList<'T2> -> LazyList<'T1 * 'T2> ///O(1). Return the list which contains on demand the list of elements of the list of lazy lists. - val concat : LazyList< LazyList<'T>> -> LazyList<'T> + val concat: LazyList> -> LazyList<'T> /// Splits the list at the gicen index. - val split : LazyList<'T> -> int -> ('T list * LazyList<'T>) + val split: LazyList<'T> -> int -> ('T list * LazyList<'T>) ///O(1). Return a new collection which on consumption will consist of only the elements of the collection /// for which the given predicate returns "true" - val filter : predicate:('T -> bool) -> source:LazyList<'T> -> LazyList<'T> + val filter: predicate: ('T -> bool) -> source: LazyList<'T> -> LazyList<'T> ///O(n). Apply the given function to each element of the collection. - val iter: action:('T -> unit) -> list:LazyList<'T>-> unit + val iter: action: ('T -> unit) -> list: LazyList<'T> -> unit ///O(1). Return a new list consisting of the results of applying the given accumulating function /// to successive elements of the list - val scan : folder:('State -> 'T -> 'State) -> 'State -> source:LazyList<'T> -> LazyList<'State> + val scan: folder: ('State -> 'T -> 'State) -> 'State -> source: LazyList<'T> -> LazyList<'State> ///O(1). Build a new collection whose elements are the results of applying the given function /// to each of the elements of the collection. - val map : mapping:('T -> 'U) -> source:LazyList<'T> -> LazyList<'U> + val map: mapping: ('T -> 'U) -> source: LazyList<'T> -> LazyList<'U> ///O(1). Build a new collection whose elements are the results of applying the given function /// to the corresponding elements of the two collections pairwise. - val map2 : mapping:('T1 -> 'T2 -> 'U) -> LazyList<'T1> -> LazyList<'T2> -> LazyList<'U> + val map2: mapping: ('T1 -> 'T2 -> 'U) -> LazyList<'T1> -> LazyList<'T2> -> LazyList<'U> ///O(1). Build a collection from the given array. This function will eagerly evaluate all of the /// list (and thus may not terminate). - val ofArray : 'T array -> LazyList<'T> + val ofArray: 'T array -> LazyList<'T> ///O(n). Build an array from the given collection - val toArray : LazyList<'T> -> 'T array + val toArray: LazyList<'T> -> 'T array ///O(1). Build a collection from the given list. This function will eagerly evaluate all of the /// list (and thus may not terminate). - val ofList : list<'T> -> LazyList<'T> + val ofList: list<'T> -> LazyList<'T> ///O(n). Build a non-lazy list from the given collection. This function will eagerly evaluate all of the /// list (and thus may not terminate). - val toList : LazyList<'T> -> list<'T> + val toList: LazyList<'T> -> list<'T> ///O(n). Return a view of the collection as an enumerable object val toSeq: LazyList<'T> -> seq<'T> @@ -211,14 +211,13 @@ module LazyList = ///O(n). Compares two lazy lists using the given comparison function, element by element. /// Both lists are evaluated until one of them is empty. - val compareWith : ('T -> 'T -> int) -> LazyList<'T> -> LazyList<'T> -> int + val compareWith: ('T -> 'T -> int) -> LazyList<'T> -> LazyList<'T> -> int ///O(n). Checks if two lazy lists are equal using the given equality function, element by element. /// Both lists are evaluated until one of them is empty. - val equalsWith : ('T -> 'T -> bool) -> LazyList<'T> -> LazyList<'T> -> bool + val equalsWith: ('T -> 'T -> bool) -> LazyList<'T> -> LazyList<'T> -> bool //-------------------------------------------------------------------------- // Lazy list active patterns - val (|Cons|Nil|) : LazyList<'T> -> Choice<('T * LazyList<'T>),unit> - + val (|Cons|Nil|): LazyList<'T> -> Choice<('T * LazyList<'T>), unit> diff --git a/src/FSharpx.Collections/NonEmptyList.fs b/src/FSharpx.Collections/NonEmptyList.fs index 4540ee7c..1d41d52d 100644 --- a/src/FSharpx.Collections/NonEmptyList.fs +++ b/src/FSharpx.Collections/NonEmptyList.fs @@ -121,3 +121,47 @@ module NonEmptyList = [] let zip list1 list2 = { List = List.zip list1.List list2.List } + + [] + let iter action list = + List.iter action list.List + + [] + let iteri action list = + List.iteri action list.List + + [] + let mapi mapping list = + { List = List.mapi mapping list.List } + + [] + let exists predicate list = + List.exists predicate list.List + + [] + let forall predicate list = + List.forall predicate list.List + + [] + let contains value list = + List.contains value list.List + + [] + let sortWith comparer list = + { List = List.sortWith comparer list.List } + + [] + let sortBy projection list = + { List = List.sortBy projection list.List } + + [] + let sort list = + { List = List.sort list.List } + + [] + let maxBy projection list = + List.maxBy projection list.List + + [] + let minBy projection list = + List.minBy projection list.List diff --git a/src/FSharpx.Collections/PersistentVector.fsi b/src/FSharpx.Collections/PersistentVector.fsi index 34f12296..0304ec54 100644 --- a/src/FSharpx.Collections/PersistentVector.fsi +++ b/src/FSharpx.Collections/PersistentVector.fsi @@ -13,144 +13,146 @@ type PersistentVector<'T> = interface System.Collections.Generic.IReadOnlyCollection<'T> /// O(1). Returns a new vector with the element added at the end. - member Conj : 'T -> PersistentVector<'T> + member Conj: 'T -> PersistentVector<'T> /// O(1) for all practical purposes; really O(log32n). Returns a new vector without the last item. If the collection is empty it throws an exception. - member Initial : PersistentVector<'T> + member Initial: PersistentVector<'T> /// O(1) for all practical purposes; really O(log32n). Returns option vector without the last item. - member TryInitial : PersistentVector<'T> option + member TryInitial: PersistentVector<'T> option /// O(1). Returns true if the vector has no elements. - member IsEmpty : bool + member IsEmpty: bool /// O(1). Returns a new PersistentVector with no elements. - static member Empty : unit -> PersistentVector<'T> + static member Empty: unit -> PersistentVector<'T> /// O(1) for all practical purposes; really O(log32n). Returns vector element at the index. - member Item : int -> 'T with get + member Item: int -> 'T with get /// O(1). Returns the last element in the vector. If the vector is empty it throws an exception. - member Last : 'T + member Last: 'T /// O(1). Returns option last element in the vector. - member TryLast : 'T option + member TryLast: 'T option /// O(1). Returns the number of items in the vector. - member Length : int + member Length: int /// O(n). Returns random access list reversed. - member Rev : unit -> PersistentVector<'T> + member Rev: unit -> PersistentVector<'T> /// O(1) for all practical purposes; really O(log32n). Returns tuple last element and vector without last item - member Unconj : PersistentVector<'T> * 'T + member Unconj: PersistentVector<'T> * 'T /// O(1) for all practical purposes; really O(log32n). Returns option tuple last element and vector without last item - member TryUnconj : (PersistentVector<'T> * 'T) option + member TryUnconj: (PersistentVector<'T> * 'T) option /// O(1) for all practical purposes; really O(log32n). Returns a new vector that contains the given value at the index. - member Update : int * 'T -> PersistentVector<'T> + member Update: int * 'T -> PersistentVector<'T> /// O(1) for all practical purposes; really O(log32n). Returns option vector that contains the given value at the index. - member TryUpdate : int * 'T -> PersistentVector<'T> option + member TryUpdate: int * 'T -> PersistentVector<'T> option /// Defines functions which allow to access and manipulate PersistentVectors. [] module PersistentVector = //pattern discriminators (active pattern) - val (|Conj|Nil|) : PersistentVector<'T> -> Choice<(PersistentVector<'T> * 'T),unit> + val (|Conj|Nil|): PersistentVector<'T> -> Choice<(PersistentVector<'T> * 'T), unit> /// O(n). Returns a new vector with the elements of the second vector added at the end. - val append : PersistentVector<'T> -> PersistentVector<'T> -> PersistentVector<'T> + val append: PersistentVector<'T> -> PersistentVector<'T> -> PersistentVector<'T> /// O(1). Returns a new vector with the element added at the end. - val inline conj : 'T -> PersistentVector<'T> -> PersistentVector<'T> + val inline conj: 'T -> PersistentVector<'T> -> PersistentVector<'T> /// O(1). Returns vector of no elements. [] val empty<'T> : PersistentVector<'T> /// O(m,n). Returns a seq from a vector of vectors. - val inline flatten : PersistentVector> -> seq<'T> + val inline flatten: PersistentVector> -> seq<'T> /// O(n). Returns a state from the supplied state and a function operating from left to right. - val inline fold : ('State -> 'T -> 'State) -> 'State -> PersistentVector<'T> -> 'State + val inline fold: ('State -> 'T -> 'State) -> 'State -> PersistentVector<'T> -> 'State /// O(n). Returns a state from the supplied state and a function operating from right to left. - val inline foldBack : ('T -> 'State -> 'State) -> PersistentVector<'T> -> 'State -> 'State + val inline foldBack: ('T -> 'State -> 'State) -> PersistentVector<'T> -> 'State -> 'State /// O(n). Returns a vector of the supplied length using the supplied function operating on the index. - val init : int -> (int -> 'T) -> PersistentVector<'T> + val init: int -> (int -> 'T) -> PersistentVector<'T> /// O(1) for all practical purposes; really O(log32n). Returns a new vector without the last item. If the collection is empty it throws an exception. - val inline initial : PersistentVector<'T> -> PersistentVector<'T> + val inline initial: PersistentVector<'T> -> PersistentVector<'T> /// O(1) for all practical purposes; really O(log32n). Returns option vector without the last item. - val inline tryInitial : PersistentVector<'T> -> PersistentVector<'T> option + val inline tryInitial: PersistentVector<'T> -> PersistentVector<'T> option /// O(1). Returns true if the vector has no elements. - val inline isEmpty : PersistentVector<'T> -> bool + val inline isEmpty: PersistentVector<'T> -> bool /// O(1). Returns the last element in the vector. If the vector is empty it throws an exception. - val inline last : PersistentVector<'T> -> 'T + val inline last: PersistentVector<'T> -> 'T /// O(1). Returns option last element in the vector. - val inline tryLast : PersistentVector<'T> -> 'T option + val inline tryLast: PersistentVector<'T> -> 'T option /// O(1). Returns the number of items in the vector. - val inline length : PersistentVector<'T> -> int + val inline length: PersistentVector<'T> -> int /// O(n). Returns a vector whose elements are the results of applying the supplied function to each of the elements of a supplied vector. - val map : ('T -> 'T1) -> PersistentVector<'T> -> PersistentVector<'T1> + val map: ('T -> 'T1) -> PersistentVector<'T> -> PersistentVector<'T1> /// O(n). Returns a vector whose elements are the results of applying the supplied function to each of the indices and elements of a supplied vector. - val mapi : (int -> 'T -> 'T1) -> PersistentVector<'T> -> PersistentVector<'T1> + val mapi: (int -> 'T -> 'T1) -> PersistentVector<'T> -> PersistentVector<'T1> /// O(1) for all practical purposes; really O(log32n). Returns the value at the index. If the index is out of bounds it throws an exception. - val inline nth : int -> PersistentVector<'T> -> 'T + val inline nth: int -> PersistentVector<'T> -> 'T /// O(log32(m,n)). Returns the value at the outer index, inner index. If either index is out of bounds it throws an exception. - val inline nthNth : int -> int -> PersistentVector> -> 'T + val inline nthNth: int -> int -> PersistentVector> -> 'T /// O(1) for all practical purposes; really O(log32n). Returns option value at the index. - val inline tryNth : int -> PersistentVector<'T> -> 'T option + val inline tryNth: int -> PersistentVector<'T> -> 'T option /// O(log32(m,n)). Returns option value at the indices. - val inline tryNthNth : int -> int -> PersistentVector> -> 'T option + val inline tryNthNth: int -> int -> PersistentVector> -> 'T option /// O(n). Returns a vector of the seq. - val ofSeq : seq<'T> -> PersistentVector<'T> + val ofSeq: seq<'T> -> PersistentVector<'T> /// O(n). Returns vector reversed. - val inline rev : PersistentVector<'T> -> PersistentVector<'T> + val inline rev: PersistentVector<'T> -> PersistentVector<'T> /// O(1). Returns a new vector of one element. - val inline singleton : 'T -> PersistentVector<'T> + val inline singleton: 'T -> PersistentVector<'T> /// O(n). Views a subset of the given vector. startIndex is inclusive, endIndex is exclusive. /// `rangedIterator 0 count` is the same as toSeq - val rangedIterator : int -> int -> PersistentVector<'T> -> seq<'T> + val rangedIterator: int -> int -> PersistentVector<'T> -> seq<'T> /// O(n). Views the given vector as a sequence. - val inline toSeq : PersistentVector<'T> -> seq<'T> + val inline toSeq: PersistentVector<'T> -> seq<'T> /// O(1) for all practical purposes; really O(log32n). Returns tuple last element and vector without last item - val inline unconj : PersistentVector<'T> -> PersistentVector<'T> * 'T + val inline unconj: PersistentVector<'T> -> PersistentVector<'T> * 'T /// O(1) for all practical purposes; really O(log32n). Returns option tuple last element and vector without last item - val inline tryUnconj : PersistentVector<'T> -> (PersistentVector<'T> * 'T) option + val inline tryUnconj: PersistentVector<'T> -> (PersistentVector<'T> * 'T) option /// O(1) for all practical purposes; really O(log32n). Returns a new vector that contains the given value at the index. - val inline update : int -> 'T -> PersistentVector<'T> -> PersistentVector<'T> + val inline update: int -> 'T -> PersistentVector<'T> -> PersistentVector<'T> /// O(log32(m,n)). Returns a new vector of vectors that contains the given value at the indices. - val inline updateNth : int -> int -> 'T -> PersistentVector> -> PersistentVector> + val inline updateNth: + int -> int -> 'T -> PersistentVector> -> PersistentVector> /// O(1) for all practical purposes; really O(log32n). Returns option vector that contains the given value at the index. - val inline tryUpdate : int -> 'T -> PersistentVector<'T> -> PersistentVector<'T> option + val inline tryUpdate: int -> 'T -> PersistentVector<'T> -> PersistentVector<'T> option /// O(log32(m,n)). Returns option vector that contains the given value at the indices. - val inline tryUpdateNth : int -> int -> 'T -> PersistentVector> -> PersistentVector> option + val inline tryUpdateNth: + int -> int -> 'T -> PersistentVector> -> PersistentVector> option /// O(n). Returns a vector of vectors of given length from the seq. Result may be a jagged vector. - val inline windowSeq : int -> seq<'T> -> PersistentVector> + val inline windowSeq: int -> seq<'T> -> PersistentVector> diff --git a/src/FSharpx.Collections/Queue.fsi b/src/FSharpx.Collections/Queue.fsi index f5d05014..c6736574 100644 --- a/src/FSharpx.Collections/Queue.fsi +++ b/src/FSharpx.Collections/Queue.fsi @@ -14,85 +14,85 @@ type Queue<'T> = interface System.Collections.Generic.IReadOnlyCollection<'T> ///O(1). Returns a new queue with the element added to the end. (Enqueue) - member Conj : 'T -> Queue<'T> + member Conj: 'T -> Queue<'T> ///O(1). Returns the first element. (Peek) - member Head : 'T + member Head: 'T ///O(1). Returns option first element - member TryHead : 'T option + member TryHead: 'T option ///O(1). Returns true if the queue has no elements. - member IsEmpty : bool + member IsEmpty: bool ///O(1). Returns the count of elememts. - member Length : int + member Length: int ///O(n). Returns queue reversed. - member Rev : unit -> Queue<'T> + member Rev: unit -> Queue<'T> ///O(1) amortized, O(n) worst-case. Returns a new queue of the elements trailing the first element. (Dequeue) - member Tail : Queue<'T> + member Tail: Queue<'T> ///O(1) amortized, O(n) worst-case. Returns option queue of the elements trailing the first element. - member TryTail : Queue<'T> option + member TryTail: Queue<'T> option ///O(1) amortized, O(n) worst-case. Returns the first element and tail. - member Uncons : 'T * Queue<'T> + member Uncons: 'T * Queue<'T> ///O(1) amortized, O(n) worst-case. Returns option first element and tail. - member TryUncons : ('T * Queue<'T>) option + member TryUncons: ('T * Queue<'T>) option [] module Queue = //pattern discriminators (active pattern) - val (|Cons|Nil|) : Queue<'T> -> Choice<('T * Queue<'T>),unit> + val (|Cons|Nil|): Queue<'T> -> Choice<('T * Queue<'T>), unit> ///O(1). Returns a new queue with the element added to the end. (enqueue) - val inline conj : 'T -> Queue<'T> -> Queue<'T> + val inline conj: 'T -> Queue<'T> -> Queue<'T> ///O(1). Returns queue of no elements. [] val empty<'T> : Queue<'T> ///O(n). Applies a function to each element of the queue, threading an accumulator argument through the computation, left to right. - val fold : ('State -> 'T -> 'State) -> 'State -> Queue<'T> -> 'State + val fold: ('State -> 'T -> 'State) -> 'State -> Queue<'T> -> 'State ///O(n). Applies a function to each element of the queue, threading an accumulator argument through the computation, right to left. - val foldBack : ('T -> 'State -> 'State) -> Queue<'T> -> 'State -> 'State + val foldBack: ('T -> 'State -> 'State) -> Queue<'T> -> 'State -> 'State ///O(1). Returns the first element. (peek) - val inline head : Queue<'T> -> 'T + val inline head: Queue<'T> -> 'T ///O(1). Returns option first element. - val inline tryHead : Queue<'T> -> 'T option + val inline tryHead: Queue<'T> -> 'T option ///O(1). Returns true if the queue has no elements. - val inline isEmpty : Queue<'T> -> bool + val inline isEmpty: Queue<'T> -> bool ///O(1). Returns the count of elememts. - val inline length : Queue<'T> -> int + val inline length: Queue<'T> -> int ///O(1). Returns a queue of the list - val ofList : list<'T> -> Queue<'T> + val ofList: list<'T> -> Queue<'T> ///O(n). Returns a queue of the seq. - val ofSeq : seq<'T> -> Queue<'T> + val ofSeq: seq<'T> -> Queue<'T> ///O(n). Returns queue reversed. - val inline rev : Queue<'T> -> Queue<'T> + val inline rev: Queue<'T> -> Queue<'T> ///O(1) amortized, O(n) worst-case. Returns a new queue of the elements trailing the first element. (dequeue) - val inline tail : Queue<'T> -> Queue<'T> + val inline tail: Queue<'T> -> Queue<'T> ///O(1) amortized, O(n) worst-case. Returns option queue of the elements trailing the first element - val inline tryTail : Queue<'T> -> Queue<'T> option + val inline tryTail: Queue<'T> -> Queue<'T> option ///O(n). Views the given queue as a sequence. - val inline toSeq : Queue<'T> -> seq<'T> + val inline toSeq: Queue<'T> -> seq<'T> ///O(1) amortized, O(n) worst-case. Returns the first element and tail. - val inline uncons : Queue<'T> -> 'T * Queue<'T> + val inline uncons: Queue<'T> -> 'T * Queue<'T> ///O(1) amortized, O(n) worst-case. Returns option first element and tail. - val inline tryUncons : Queue<'T> -> ('T * Queue<'T>) option + val inline tryUncons: Queue<'T> -> ('T * Queue<'T>) option diff --git a/src/FSharpx.Collections/RandomAccessList.fsi b/src/FSharpx.Collections/RandomAccessList.fsi index 4596bc49..bae870b0 100644 --- a/src/FSharpx.Collections/RandomAccessList.fsi +++ b/src/FSharpx.Collections/RandomAccessList.fsi @@ -1,4 +1,5 @@ namespace FSharpx.Collections + /// RandomAccessList is an ordered linear structure implementing the List signature /// (head, tail, cons), as well as inspection (lookup) and update (returning a new /// immutable instance) of any element in the structure by index. Length is O(1). Indexed @@ -16,140 +17,149 @@ type RandomAccessList<'T> = interface System.Collections.Generic.IReadOnlyList<'T> /// O(1). Returns a new random access list with the element added at the start. - member Cons : 'T -> RandomAccessList<'T> + member Cons: 'T -> RandomAccessList<'T> /// O(1). Returns true if the random access list has no elements. - member IsEmpty : bool + member IsEmpty: bool /// O(1) for all practical purposes; really O(log32n). Returns random access list element at the index. - member Item : int -> 'T with get + member Item: int -> 'T with get /// O(1). Returns the first element in the random access list. If the random access list is empty it throws an exception. - member Head : 'T + member Head: 'T /// O(1). Returns option first element in the random access list. - member TryHead : 'T option + member TryHead: 'T option /// O(1). Returns the number of items in the random access list. - member Length : int + member Length: int /// O(n). Returns random access list reversed. - member Rev : unit -> RandomAccessList<'T> + member Rev: unit -> RandomAccessList<'T> /// O(1) for all practical purposes; really O(log32n). Returns a new random access list without the first item. If the collection is empty it throws an exception. - member Tail : RandomAccessList<'T> + member Tail: RandomAccessList<'T> /// O(1) for all practical purposes; really O(log32n). Returns option random access list without the first item. - member TryTail : RandomAccessList<'T> option + member TryTail: RandomAccessList<'T> option /// O(1) for all practical purposes; really O(log32n). Returns tuple first element and random access list without first item - member Uncons : 'T * RandomAccessList<'T> + member Uncons: 'T * RandomAccessList<'T> /// O(1) for all practical purposes; really O(log32n). Returns option tuple first element and random access list without first item - member TryUncons : ('T * RandomAccessList<'T>) option + member TryUncons: ('T * RandomAccessList<'T>) option /// O(1) for all practical purposes; really O(log32n). Returns a new random access list that contains the given value at the index. - member Update : int * 'T -> RandomAccessList<'T> + member Update: int * 'T -> RandomAccessList<'T> /// O(1) for all practical purposes; really O(log32n). Returns option random access list that contains the given value at the index. - member TryUpdate : int * 'T -> RandomAccessList<'T> option + member TryUpdate: int * 'T -> RandomAccessList<'T> option /// Defines functions which allow to access and manipulate RandomAccessLists. [] module RandomAccessList = //pattern discriminators (active pattern) - val (|Cons|Nil|) : RandomAccessList<'T> -> Choice<('T * RandomAccessList<'T> ),unit> + val (|Cons|Nil|): RandomAccessList<'T> -> Choice<('T * RandomAccessList<'T>), unit> /// O(n). Returns a new random access list with the elements of the second random access list added at the end. - val append : RandomAccessList<'T> -> RandomAccessList<'T> -> RandomAccessList<'T> + val append: RandomAccessList<'T> -> RandomAccessList<'T> -> RandomAccessList<'T> /// O(1). Returns a new random access list with the element added at the start. - val inline cons : 'T -> RandomAccessList<'T> -> RandomAccessList<'T> + val inline cons: 'T -> RandomAccessList<'T> -> RandomAccessList<'T> /// O(1). Returns random access list of no elements. [] val empty<'T> : RandomAccessList<'T> /// O(n). Returns a state from the supplied state and a function operating from left to right. - val inline fold : ('State -> 'T -> 'State) -> 'State -> RandomAccessList<'T> -> 'State + val inline fold: ('State -> 'T -> 'State) -> 'State -> RandomAccessList<'T> -> 'State /// O(n). Returns a state from the supplied state and a function operating from right to left. - val inline foldBack : ('T -> 'State -> 'State) -> RandomAccessList<'T> -> 'State -> 'State + val inline foldBack: ('T -> 'State -> 'State) -> RandomAccessList<'T> -> 'State -> 'State /// O(n). Returns a random access list of the supplied length using the supplied function operating on the index. - val init : int -> (int -> 'T) -> RandomAccessList<'T> + val init: int -> (int -> 'T) -> RandomAccessList<'T> /// O(1). Returns true if the random access list has no elements. - val inline isEmpty : RandomAccessList<'T> -> bool + val inline isEmpty: RandomAccessList<'T> -> bool /// O(1). Returns the first element in the random access list. If the random access list is empty it throws an exception. - val inline head : RandomAccessList<'T> -> 'T + val inline head: RandomAccessList<'T> -> 'T /// O(1). Returns option first element in the random access list. - val inline tryHead : RandomAccessList<'T> -> 'T option + val inline tryHead: RandomAccessList<'T> -> 'T option /// O(1). Returns the number of items in the random access list. - val inline length : RandomAccessList<'T> -> int + val inline length: RandomAccessList<'T> -> int /// O(n). Returns a random access list whose elements are the results of applying the supplied function to each of the elements of a supplied random access list. - val map : ('T -> 'T1) -> RandomAccessList<'T> -> RandomAccessList<'T1> + val map: ('T -> 'T1) -> RandomAccessList<'T> -> RandomAccessList<'T1> /// O(1) for all practical purposes; really O(log32n). Returns the value at the index. - val inline nth : int -> RandomAccessList<'T> -> 'T + val inline nth: int -> RandomAccessList<'T> -> 'T /// O(1) for all practical purposes; really O(log32n). Returns option value at the index. - val inline tryNth : int -> RandomAccessList<'T> -> 'T option + val inline tryNth: int -> RandomAccessList<'T> -> 'T option /// O(log32(m,n)). Returns the value at the outer index, inner index. If either index is out of bounds it throws an exception. - val inline nthNth : int -> int -> RandomAccessList> -> 'T + val inline nthNth: int -> int -> RandomAccessList> -> 'T /// O(log32(m,n)). Returns option value at the indices. - val inline tryNthNth : int -> int -> RandomAccessList> -> 'T option + val inline tryNthNth: int -> int -> RandomAccessList> -> 'T option /// O(n). Returns a random access list of the seq. - val ofSeq : seq<'T> -> RandomAccessList<'T> + val ofSeq: seq<'T> -> RandomAccessList<'T> /// O(n). Returns new random access list reversed. - val inline rev : RandomAccessList<'T> -> RandomAccessList<'T> + val inline rev: RandomAccessList<'T> -> RandomAccessList<'T> /// O(1). Returns a new random access list of one element. - val inline singleton : 'T -> RandomAccessList<'T> + val inline singleton: 'T -> RandomAccessList<'T> /// O(1) for all practical purposes; really O(log32n). Returns a new random access list without the first item. If the collection is empty it throws an exception. - val inline tail : RandomAccessList<'T> -> RandomAccessList<'T> + val inline tail: RandomAccessList<'T> -> RandomAccessList<'T> /// O(1) for all practical purposes; really O(log32n). Returns option random access list without the first item. - val inline tryTail : RandomAccessList<'T> -> RandomAccessList<'T> option + val inline tryTail: RandomAccessList<'T> -> RandomAccessList<'T> option /// O(n). Views the given random access list as a sequence. - val inline toSeq : RandomAccessList<'T> -> seq<'T> + val inline toSeq: RandomAccessList<'T> -> seq<'T> /// O(1) for all practical purposes; really O(log32n). Returns tuple first element and random access list without first item - val inline uncons : RandomAccessList<'T> -> 'T * RandomAccessList<'T> + val inline uncons: RandomAccessList<'T> -> 'T * RandomAccessList<'T> /// O(1) for all practical purposes; really O(log32n). Returns option tuple first element and random access list without first item - val inline tryUncons : RandomAccessList<'T> -> ('T * RandomAccessList<'T>) option + val inline tryUncons: RandomAccessList<'T> -> ('T * RandomAccessList<'T>) option /// O(1) for all practical purposes; really O(log32n). Returns a new random access list that contains the given value at the index. - val inline update : int -> 'T -> RandomAccessList<'T> -> RandomAccessList<'T> + val inline update: int -> 'T -> RandomAccessList<'T> -> RandomAccessList<'T> /// O(log32(m,n)). Returns a new random access list of random access lists that contains the given value at the indices. - val inline updateNth : int -> int -> 'T -> RandomAccessList> -> RandomAccessList> + val inline updateNth: + int -> int -> 'T -> RandomAccessList> -> RandomAccessList> /// O(1) for all practical purposes; really O(log32n). Returns option random access list that contains the given value at the index. - val inline tryUpdate : int -> 'T -> RandomAccessList<'T> -> RandomAccessList<'T> option + val inline tryUpdate: int -> 'T -> RandomAccessList<'T> -> RandomAccessList<'T> option /// O(log32(m,n)). Returns option random access list that contains the given value at the indices. - val inline tryUpdateNth : int -> int -> 'T -> RandomAccessList> -> RandomAccessList> option + val inline tryUpdateNth: + int -> int -> 'T -> RandomAccessList> -> RandomAccessList> option /// O(n). Returns a random access list of random access lists of given length from the seq. Result may be a jagged random access list. - val inline windowSeq : int -> seq<'T> -> RandomAccessList> + val inline windowSeq: int -> seq<'T> -> RandomAccessList> /// O(n). Combines the two RandomAccessLists into a RandomAccessList of pairs. The two RandomAccessLists must have equal lengths, otherwise an ArgumentException is raised. - val zip : randomAccessList1 : RandomAccessList<'T> -> randomAccessList2 : RandomAccessList<'T2> -> RandomAccessList<'T * 'T2> + val zip: + randomAccessList1: RandomAccessList<'T> -> + randomAccessList2: RandomAccessList<'T2> -> + RandomAccessList<'T * 'T2> /// O(n). Applies a function to each element of the collection, threading an accumulator argument through the computation. This function first applies the function to the first two elements of the list. Then, it passes this result into the function along with the third element and so on. Finally, it returns the final result. If the input function is f and the elements are i0...iN, then it computes f (... (f i0 i1) i2 ...) iN. - val reduce : f: ('T -> 'T -> 'T) -> randomAccessList : RandomAccessList<'T> -> 'T + val reduce: f: ('T -> 'T -> 'T) -> randomAccessList: RandomAccessList<'T> -> 'T /// O(n). Builds a new collection whose elements are the results of applying the given function to the corresponding elements of the two collections pairwise. The two input arrays must have the same lengths, otherwise ArgumentException is raised. - val map2 : ('T1 -> 'T2 -> 'U) -> randomAccessList1 : RandomAccessList<'T1> -> randomAccessList2 : RandomAccessList<'T2> -> RandomAccessList<'U> \ No newline at end of file + val map2: + ('T1 -> 'T2 -> 'U) -> + randomAccessList1: RandomAccessList<'T1> -> + randomAccessList2: RandomAccessList<'T2> -> + RandomAccessList<'U> diff --git a/src/FSharpx.Collections/ResizeArray.fsi b/src/FSharpx.Collections/ResizeArray.fsi index cd850b8c..524187cc 100644 --- a/src/FSharpx.Collections/ResizeArray.fsi +++ b/src/FSharpx.Collections/ResizeArray.fsi @@ -1,10 +1,10 @@ -// First version copied from the F# Power Pack +// First version copied from the F# Power Pack // https://raw.github.com/fsharp/powerpack/master/src/FSharp.PowerPack/ResizeArray.fsi //========================================================================== // ResizeArray -// -// (c) Microsoft Corporation 2005-2008. +// +// (c) Microsoft Corporation 2005-2008. //=========================================================================== namespace FSharpx.Collections @@ -28,7 +28,7 @@ module ResizeArray = /// Create an array whose elements are all initially the given value. val create: int -> 'T -> ResizeArray<'T> - + /// Create an array by calling the given generator on each index. val init: int -> (int -> 'T) -> ResizeArray<'T> @@ -58,19 +58,19 @@ module ResizeArray = val ofList: 'T list -> ResizeArray<'T> /// Build and array from the given seq - val ofSeq : 'T seq -> ResizeArray<'T> + val ofSeq: 'T seq -> ResizeArray<'T> /// Apply a function to each element of the collection, threading an accumulator argument - /// through the computation. If the input function is f and the elements are i0...iN + /// through the computation. If the input function is f and the elements are i0...iN /// then computes f (... (f s i0)...) iN val fold: ('T -> 'State -> 'T) -> 'T -> ResizeArray<'State> -> 'T /// Apply a function to each element of the array, threading an accumulator argument - /// through the computation. If the input function is f and the elements are i0...iN then + /// through the computation. If the input function is f and the elements are i0...iN then /// computes f i0 (...(f iN s)). val foldBack: ('T -> 'State -> 'State) -> ResizeArray<'T> -> 'State -> 'State - /// Apply the given function to each element of the array. + /// Apply the given function to each element of the array. val iter: ('T -> unit) -> ResizeArray<'T> -> unit /// Build a new array whose elements are the results of applying the given function @@ -97,7 +97,7 @@ module ResizeArray = val mapi: (int -> 'T -> 'U) -> ResizeArray<'T> -> ResizeArray<'U> /// Test if any element of the array satisfies the given predicate. - /// If the input function is f and the elements are i0...iN + /// If the input function is f and the elements are i0...iN /// then computes p i0 or ... or p iN. val exists: ('T -> bool) -> ResizeArray<'T> -> bool @@ -110,9 +110,9 @@ module ResizeArray = /// for which the given predicate returns true val filter: ('T -> bool) -> ResizeArray<'T> -> ResizeArray<'T> - /// Split the collection into two collections, containing the + /// Split the collection into two collections, containing the /// elements for which the given predicate returns true and false - /// respectively + /// respectively val partition: ('T -> bool) -> ResizeArray<'T> -> ResizeArray<'T> * ResizeArray<'T> /// Apply the given function to each element of the array. Return @@ -139,100 +139,100 @@ module ResizeArray = val sort: ('T -> 'T -> int) -> ResizeArray<'T> -> unit /// Sort the elements using the key extractor and generic comparison on the keys - val sortBy: ('T -> 'Key) -> ResizeArray<'T> -> unit when 'Key : comparison + val sortBy: ('T -> 'Key) -> ResizeArray<'T> -> unit when 'Key: comparison /// Return a fixed-length array containing the elements of the input ResizeArray - val toArray : ResizeArray<'T> -> 'T[] + val toArray: ResizeArray<'T> -> 'T[] /// Build a ResizeArray from the given elements - val ofArray : 'T[] -> ResizeArray<'T> + val ofArray: 'T[] -> ResizeArray<'T> /// Return a view of the array as an enumerable object - val toSeq : ResizeArray<'T> -> seq<'T> + val toSeq: ResizeArray<'T> -> seq<'T> /// Test elements of the two arrays pairwise to see if any pair of element satisfies the given predicate. /// Raise ArgumentException if the arrays have different lengths. - val exists2 : ('T1 -> 'T2 -> bool) -> ResizeArray<'T1> -> ResizeArray<'T2> -> bool + val exists2: ('T1 -> 'T2 -> bool) -> ResizeArray<'T1> -> ResizeArray<'T2> -> bool /// Return the index of the first element in the array - /// that satisfies the given predicate. Raise KeyNotFoundException if + /// that satisfies the given predicate. Raise KeyNotFoundException if /// none of the elements satisfy the predicate. - val findIndex : ('T -> bool) -> ResizeArray<'T> -> int + val findIndex: ('T -> bool) -> ResizeArray<'T> -> int /// Return the index of the first element in the array - /// that satisfies the given predicate. Raise KeyNotFoundException if + /// that satisfies the given predicate. Raise KeyNotFoundException if /// none of the elements satisfy the predicate. - val findIndexi : (int -> 'T -> bool) -> ResizeArray<'T> -> int + val findIndexi: (int -> 'T -> bool) -> ResizeArray<'T> -> int /// Apply a function to each element of the array, threading an accumulator argument - /// through the computation. If the input function is f and the elements are i0...iN + /// through the computation. If the input function is f and the elements are i0...iN /// then computes f (... (f i0 i1)...) iN. Raises ArgumentException if the array has size zero. - val reduce : ('T -> 'T -> 'T) -> ResizeArray<'T> -> 'T + val reduce: ('T -> 'T -> 'T) -> ResizeArray<'T> -> 'T /// Apply a function to each element of the array, threading an accumulator argument - /// through the computation. If the input function is f and the elements are i0...iN then + /// through the computation. If the input function is f and the elements are i0...iN then /// computes f i0 (...(f iN-1 iN)). Raises ArgumentException if the array has size zero. - val reduceBack : ('T -> 'T -> 'T) -> ResizeArray<'T> -> 'T + val reduceBack: ('T -> 'T -> 'T) -> ResizeArray<'T> -> 'T - /// Apply a function to pairs of elements drawn from the two collections, + /// Apply a function to pairs of elements drawn from the two collections, /// left-to-right, threading an accumulator argument /// through the computation. The two input /// arrays must have the same lengths, otherwise an ArgumentException is /// raised. val fold2: ('State -> 'T1 -> 'T2 -> 'State) -> 'State -> ResizeArray<'T1> -> ResizeArray<'T2> -> 'State - /// Apply a function to pairs of elements drawn from the two collections, right-to-left, + /// Apply a function to pairs of elements drawn from the two collections, right-to-left, /// threading an accumulator argument through the computation. The two input /// arrays must have the same lengths, otherwise an ArgumentException is /// raised. - val foldBack2 : ('T1 -> 'T2 -> 'State -> 'State) -> ResizeArray<'T1> -> ResizeArray<'T2> -> 'State -> 'State + val foldBack2: ('T1 -> 'T2 -> 'State -> 'State) -> ResizeArray<'T1> -> ResizeArray<'T2> -> 'State -> 'State /// Test elements of the two arrays pairwise to see if all pairs of elements satisfy the given predicate. /// Raise ArgumentException if the arrays have different lengths. - val forall2 : ('T1 -> 'T2 -> bool) -> ResizeArray<'T1> -> ResizeArray<'T2> -> bool + val forall2: ('T1 -> 'T2 -> bool) -> ResizeArray<'T1> -> ResizeArray<'T2> -> bool /// Return true if the given array is empty, otherwise false - val isEmpty : ResizeArray<'T> -> bool + val isEmpty: ResizeArray<'T> -> bool /// Apply the given function to pair of elements drawn from matching indices in two arrays, - /// also passing the index of the elements. The two arrays must have the same lengths, + /// also passing the index of the elements. The two arrays must have the same lengths, /// otherwise an ArgumentException is raised. - val iteri2 : (int -> 'T1 -> 'T2 -> unit) -> ResizeArray<'T1> -> ResizeArray<'T2> -> unit + val iteri2: (int -> 'T1 -> 'T2 -> unit) -> ResizeArray<'T1> -> ResizeArray<'T2> -> unit /// Build a new collection whose elements are the results of applying the given function /// to the corresponding elements of the two collections pairwise. The two input /// arrays must have the same lengths, otherwise an ArgumentException is /// raised. - val mapi2 : (int -> 'T1 -> 'T2 -> 'U) -> ResizeArray<'T1> -> ResizeArray<'T2> -> ResizeArray<'U> + val mapi2: (int -> 'T1 -> 'T2 -> 'U) -> ResizeArray<'T1> -> ResizeArray<'T2> -> ResizeArray<'U> /// Like fold, but return the intermediary and final results - val scan : ('State -> 'T -> 'State) -> 'State -> ResizeArray<'T> -> ResizeArray<'State> + val scan: ('State -> 'T -> 'State) -> 'State -> ResizeArray<'T> -> ResizeArray<'State> /// Like foldBack, but return both the intermediary and final results - val scanBack : ('T -> 'State -> 'State) -> ResizeArray<'T> -> 'State -> ResizeArray<'State> + val scanBack: ('T -> 'State -> 'State) -> ResizeArray<'T> -> 'State -> ResizeArray<'State> /// Return an array containing the given element - val singleton : 'T -> ResizeArray<'T> - + val singleton: 'T -> ResizeArray<'T> + /// Return the index of the first element in the array /// that satisfies the given predicate. - val tryFindIndex : ('T -> bool) -> ResizeArray<'T> -> int option + val tryFindIndex: ('T -> bool) -> ResizeArray<'T> -> int option /// Return the index of the first element in the array /// that satisfies the given predicate. - val tryFindIndexi : (int -> 'T -> bool) -> ResizeArray<'T> -> int option + val tryFindIndexi: (int -> 'T -> bool) -> ResizeArray<'T> -> int option /// Combine the two arrays into an array of pairs. The two arrays must have equal lengths, otherwise an ArgumentException is /// raised.. - val zip : ResizeArray<'T1> -> ResizeArray<'T2> -> ResizeArray<'T1 * 'T2> + val zip: ResizeArray<'T1> -> ResizeArray<'T2> -> ResizeArray<'T1 * 'T2> /// Split an array of pairs into two arrays - val unzip : ResizeArray<'T1 * 'T2> -> ResizeArray<'T1> * ResizeArray<'T2> + val unzip: ResizeArray<'T1 * 'T2> -> ResizeArray<'T1> * ResizeArray<'T2> - /// Returns an array that contains no duplicate entries according to the + /// Returns an array that contains no duplicate entries according to the /// generic hash and equality comparisons on the keys returned by the given key-generating function. /// If an element occurs multiple times in the array then the later occurrences are discarded. - val distinctBy: ('T -> 'Key) -> ResizeArray<'T> -> ResizeArray<'T> when 'Key : equality + val distinctBy: ('T -> 'Key) -> ResizeArray<'T> -> ResizeArray<'T> when 'Key: equality /// Returns an array that contains no duplicate entries according to generic hash and /// equality comparisons on the entries. /// If an element occurs multiple times in the array then the later occurrences are discarded. - val distinct: ResizeArray<'T> -> ResizeArray<'T> when 'T : equality \ No newline at end of file + val distinct: ResizeArray<'T> -> ResizeArray<'T> when 'T: equality diff --git a/tests/FSharpx.Collections.Tests/NonEmptyListTests.fs b/tests/FSharpx.Collections.Tests/NonEmptyListTests.fs index acb77c36..b77fbd78 100644 --- a/tests/FSharpx.Collections.Tests/NonEmptyListTests.fs +++ b/tests/FSharpx.Collections.Tests/NonEmptyListTests.fs @@ -257,4 +257,149 @@ module NonEmptyListTests = (Prop.forAll(twoDifferentLengths()) <| fun (nel1, nel2) -> Expect.throwsT (sprintf "length %i; length %i" nel1.Length nel2.Length) (fun () -> - NonEmptyList.zip nel1 nel2 |> ignore)) ] + NonEmptyList.zip nel1 nel2 |> ignore)) + + testPropertyWithConfig + config10k + "cons prepends an element" + (Prop.forAll(NonEmptyListGen.NonEmptyList()) + <| fun nel -> + let consed = NonEmptyList.cons 42 nel + consed.Head = 42 && consed.Length = nel.Length + 1) + + testPropertyWithConfig config10k "appendList combines NonEmptyList with plain list" + <| fun (a: _ list) (b: _ list) -> + if a.IsEmpty then + true + else + let neA = NonEmptyList.create a.Head a.Tail + (NonEmptyList.appendList neA b).Length = neA.Length + b.Length + + testPropertyWithConfig + config10k + "toSeq yields all elements" + (Prop.forAll(NonEmptyListGen.NonEmptyList()) + <| fun nel -> Seq.forall2 (=) (NonEmptyList.toSeq nel) (NonEmptyList.toList nel)) + + testPropertyWithConfig + config10k + "iter visits all elements" + (Prop.forAll(NonEmptyListGen.NonEmptyList()) + <| fun nel -> + let visited = System.Collections.Generic.List() + NonEmptyList.iter visited.Add nel + Seq.toList visited = NonEmptyList.toList nel) + + testPropertyWithConfig + config10k + "iteri visits all elements with correct indices" + (Prop.forAll(NonEmptyListGen.NonEmptyList()) + <| fun nel -> + let pairs = System.Collections.Generic.List() + NonEmptyList.iteri (fun i x -> pairs.Add(i, x)) nel + let expected = nel |> NonEmptyList.toList |> List.mapi(fun i x -> i, x) + Seq.toList pairs = expected) + + testPropertyWithConfig + config10k + "mapi produces indexed values" + (Prop.forAll(NonEmptyListGen.NonEmptyList()) + <| fun nel -> + let actual = NonEmptyList.mapi (fun i x -> i, x) nel |> NonEmptyList.toList + let expected = nel |> NonEmptyList.toList |> List.mapi(fun i x -> i, x) + actual = expected) + + testPropertyWithConfig + config10k + "exists behaves like List.exists" + (Prop.forAll(NonEmptyListGen.NonEmptyList()) + <| fun nel -> + let list = NonEmptyList.toList nel + let predicate x = x % 2 = 0 + NonEmptyList.exists predicate nel = List.exists predicate list) + + testPropertyWithConfig + config10k + "forall behaves like List.forall" + (Prop.forAll(NonEmptyListGen.NonEmptyList()) + <| fun nel -> + let list = NonEmptyList.toList nel + let predicate x = x % 2 = 0 + NonEmptyList.forall predicate nel = List.forall predicate list) + + testPropertyWithConfig config10k "contains finds a present element" + <| fun (xs: int list) -> + if xs.IsEmpty then + true + else + let nel = NonEmptyList.create xs.Head xs.Tail + let containsPresent = NonEmptyList.contains xs.Head nel + let sentinel = System.Int32.MinValue + + let containsAbsent = + if List.contains sentinel xs then + true + else + not(NonEmptyList.contains sentinel nel) + + containsPresent && containsAbsent + + testPropertyWithConfig + config10k + "sort produces sorted output" + (Prop.forAll(neListOfInt()) + <| fun nel -> + let sorted = NonEmptyList.sort nel |> NonEmptyList.toList + let expected = nel |> NonEmptyList.toList |> List.sort + sorted = expected) + + testPropertyWithConfig + config10k + "sortBy with identity projection produces ascending sorted output" + (Prop.forAll(neListOfInt()) + <| fun nel -> + let sorted = NonEmptyList.sortBy id nel |> NonEmptyList.toList + let expected = nel |> NonEmptyList.toList |> List.sortBy id + sorted = expected) + + testPropertyWithConfig + config10k + "sortBy with negation projection produces descending sorted output" + (Prop.forAll(neListOfInt()) + <| fun nel -> + let sorted = NonEmptyList.sortBy (fun x -> -x) nel |> NonEmptyList.toList + let expected = nel |> NonEmptyList.toList |> List.sortBy(fun x -> -x) + sorted = expected) + + testPropertyWithConfig + config10k + "sortWith produces sorted output" + (Prop.forAll(neListOfInt()) + <| fun nel -> + let sorted = NonEmptyList.sortWith compare nel |> NonEmptyList.toList + let expected = nel |> NonEmptyList.toList |> List.sort + sorted = expected) + + testPropertyWithConfig + config10k + "maxBy with identity projection returns maximum element" + (Prop.forAll(neListOfInt()) + <| fun nel -> NonEmptyList.maxBy id nel = (nel |> NonEmptyList.toList |> List.max)) + + testPropertyWithConfig + config10k + "maxBy with negation projection returns minimum element" + (Prop.forAll(neListOfInt()) + <| fun nel -> NonEmptyList.maxBy (fun x -> -x) nel = (nel |> NonEmptyList.toList |> List.min)) + + testPropertyWithConfig + config10k + "minBy with identity projection returns minimum element" + (Prop.forAll(neListOfInt()) + <| fun nel -> NonEmptyList.minBy id nel = (nel |> NonEmptyList.toList |> List.min)) + + testPropertyWithConfig + config10k + "minBy with negation projection returns maximum element" + (Prop.forAll(neListOfInt()) + <| fun nel -> NonEmptyList.minBy (fun x -> -x) nel = (nel |> NonEmptyList.toList |> List.max)) ] diff --git a/tests/FSharpx.Collections.Tests/SeqTests.fs b/tests/FSharpx.Collections.Tests/SeqTests.fs index 1d334e63..66cdc9cd 100644 --- a/tests/FSharpx.Collections.Tests/SeqTests.fs +++ b/tests/FSharpx.Collections.Tests/SeqTests.fs @@ -244,4 +244,97 @@ module SeqTests = Expect.sequenceEqual "" a (a |> Seq.intersperse ',') } - testPropertyWithConfig config10k "I should interperse always 2n-1 elements" intersperse ] + testPropertyWithConfig config10k "I should interperse always 2n-1 elements" intersperse + + test "cons prepends an element to a seq" { + Seq.cons 0 [ 1; 2; 3 ] + |> Expect.sequenceEqual "cons" (List.toSeq [ 0; 1; 2; 3 ]) + } + + test "unCons returns None for empty seq" { Seq.unCons Seq.empty |> Expect.isNone "unCons" } + + test "unCons returns Some (head, tail) for non-empty seq" { + match Seq.unCons [ 1; 2; 3 ] with + | Some(head, tail) -> + Expect.equal "unCons head" 1 head + Expect.sequenceEqual "unCons tail" [ 2; 3 ] tail + | None -> failwith "Expected Some" + } + + test "findExactlyOne returns the single matching element" { + Expect.equal "findExactlyOne" 3 (Seq.findExactlyOne ((=) 3) [ 1; 2; 3; 4; 5 ]) + } + + test "findExactlyOne throws when no element matches" { + Expect.throws "findExactlyOne should throw when there are no matching elements" (fun () -> + Seq.findExactlyOne ((=) 42) [ 1; 2; 3 ] |> ignore) + } + + test "findExactlyOne throws when multiple elements match" { + Expect.throws "findExactlyOne should throw when there are multiple matching elements" (fun () -> + Seq.findExactlyOne (fun x -> x % 2 = 0) [ 1; 2; 3; 4 ] |> ignore) + } + + test "catOptions extracts Some values from a seq of options" { + let opts = [ Some 1; None; Some 2; None; Some 3 ] + + Seq.catOptions opts + |> Expect.sequenceEqual "catOptions" (List.toSeq [ 1; 2; 3 ]) + } + + test "catOptions returns empty seq when all are None" { + let opts: int option list = [ None; None ] + + Seq.catOptions opts + |> Expect.sequenceEqual "catOptions empty" Seq.empty + } + + test "choice1s extracts Choice1Of2 values" { + let choices = [ Choice1Of2 1; Choice2Of2 "a"; Choice1Of2 2; Choice2Of2 "b" ] + + Seq.choice1s choices + |> Expect.sequenceEqual "choice1s" (List.toSeq [ 1; 2 ]) + } + + test "choice2s extracts Choice2Of2 values" { + let choices = [ Choice1Of2 1; Choice2Of2 "a"; Choice1Of2 2; Choice2Of2 "b" ] + + Seq.choice2s choices + |> Expect.sequenceEqual "choice2s" (List.toSeq [ "a"; "b" ]) + } + + test "partitionChoices splits into two seqs" { + let choices = [ Choice1Of2 1; Choice2Of2 "a"; Choice1Of2 2; Choice2Of2 "b" ] + let c1s, c2s = Seq.partitionChoices choices + Expect.sequenceEqual "partitionChoices c1s" (List.toSeq [ 1; 2 ]) c1s + Expect.sequenceEqual "partitionChoices c2s" (List.toSeq [ "a"; "b" ]) c2s + } + + test "equalsWith returns true for equal seqs" { Expect.isTrue "equalsWith" (Seq.equalsWith (=) [ 1; 2; 3 ] [ 1; 2; 3 ]) } + + test "equalsWith returns false for unequal seqs" { Expect.isFalse "equalsWith" (Seq.equalsWith (=) [ 1; 2; 3 ] [ 1; 2; 4 ]) } + + test "equalsWith returns true for empty seqs" { + Expect.isTrue "equalsWith empty" (Seq.equalsWith (=) (Seq.empty) (Seq.empty)) + } + + test "groupNeighboursBy groups consecutive equal-key elements" { + let input = [ 1; 1; 2; 2; 1; 1 ] + let result = Seq.groupNeighboursBy id input |> Seq.toList + let keys = result |> List.map fst + Expect.equal "groupNeighboursBy keys" [ 1; 2; 1 ] keys + let groups = result |> List.map(snd >> Seq.toList) + Expect.equal "groupNeighboursBy groups" [ [ 1; 1 ]; [ 2; 2 ]; [ 1; 1 ] ] groups + } + + test "groupNeighboursBy on empty seq gives empty result" { + Seq.groupNeighboursBy id (Seq.empty) + |> Seq.isEmpty + |> Expect.isTrue "groupNeighboursBy empty" + } + + test "groupNeighboursBy on singleton gives one group" { + let result = Seq.groupNeighboursBy id [ 42 ] |> Seq.toList + Expect.equal "groupNeighboursBy singleton" 1 result.Length + Expect.equal "groupNeighboursBy singleton key" 42 (fst result.[0]) + } ]