Skip to content

Commit

Permalink
Updated the documentation, did a bit of cleanup, updated nuspec
Browse files Browse the repository at this point in the history
  • Loading branch information
GregRos committed Jun 24, 2016
1 parent 49694c0 commit e5fa401
Show file tree
Hide file tree
Showing 20 changed files with 183 additions and 141 deletions.
3 changes: 2 additions & 1 deletion Imms/ExtraFunctional/ExtraFunctional/Option.fs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace ExtraFunctional
module Option =
let orValue (v : 'v) = function Some u -> u | None -> v
let orMaybe (v : 'v option) = function Some u -> Some u | None -> v
let asNull = Option.toObj
let cast<'a,'b> (opt : 'a option) : 'b option = opt |> Option.map (fun a -> a :> obj :?> 'b)
let asNull (opt : 'a option) = if opt.IsSome then opt.Value else null

[<AutoOpen>]
module OptionExt =
Expand Down
1 change: 1 addition & 0 deletions Imms/ExtraFunctional/ExtraFunctional/Seq.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type IterationControl<'v> =
| Stop
| Yield of 'v
| Ignore

let getEnumerator (a :_ seq) = a.GetEnumerator()

let rev (s :_ seq) =
Expand Down
4 changes: 2 additions & 2 deletions Imms/Imms.Abstract/Abstractions/Operators/AbstractSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ partial class AbstractSet<TElem, TSet>
partial class AbstractMap<TKey, TValue, TMap> {

/// <summary>
/// Adds the key-value pair to the map, overwriting any existing pair. Identical to <see cref="Set"/>.
/// Adds the key-value pair to the map, overwriting any existing pair. Identical to <see cref="Set(TKey,TValue)"/>.
/// </summary>
/// <param name="left">The map.</param>
/// <param name="kvp">The key-value pair.</param>
Expand Down Expand Up @@ -114,7 +114,7 @@ partial class AbstractMap<TKey, TValue, TMap> {
}

/// <summary>
/// Takes a sequence of key-value pairs and removes all keys present in the sequence from the map. Identical to <see cref="Subtract"/>.
/// Takes a sequence of key-value pairs and removes all keys present in the sequence from the map. Identical to <see cref="Subtract{T}"/>.
/// </summary>
/// <param name="left">The map.</param>
/// <param name="kvps">The key-value pairs.</param>
Expand Down
4 changes: 2 additions & 2 deletions Imms/Imms.Collections/Imms.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<licenseUrl>https://raw.githubusercontent.com/GregRos/Imms/master/license.md</licenseUrl>
<licenseUrl>https://raw.githubusercontent.com/Imms/Imms/master/license.md</licenseUrl>
<projectUrl>http://imms.github.io/</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<iconUrl>https://raw.githubusercontent.com/GregRos/Imms/master/Icon.png</iconUrl>
<iconUrl>https://raw.githubusercontent.com/Imms/Imms/master/Icon.png</iconUrl>
<summary>High-performance immutable collections for .NET.</summary>
<description>$description$</description>
<releaseNotes>A number of API changes and bug fixes.</releaseNotes>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Imms.Implementation {
#pragma warning disable 618
static partial class TrieVector<TValue> {
internal abstract partial class Node {
public static implicit operator ImmVector<TValue>(Node node) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using Imms.Implementation;
#pragma warning disable 44
#pragma warning disable 618
namespace Imms {
/// <summary>
/// Provides extension methods for converting between, to, and from Imm data structures.
Expand Down
76 changes: 54 additions & 22 deletions Imms/Imms.Collections/Wrappers/Immutable/List/Boilerplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ namespace Imms
using Imms;
using Imms.Abstract;

partial class ImmList<T> : AbstractSequential<T, ImmList<T>> {
partial class ImmList<T> : AbstractSequential<T, ImmList<T>>
{
private static readonly ImmList<T> Instance = new ImmList<T>();

private ImmList() {
private ImmList()
{
}


Expand All @@ -21,7 +23,8 @@ partial class ImmList<T> : AbstractSequential<T, ImmList<T>> {
/// <typeparam name="TRElem">The type of the result element.</typeparam>
/// <param name="selector">The selector.</param>
/// <returns></returns>
public ImmList<TRElem> Select<TRElem>(Func<T, TRElem> selector) {
public ImmList<TRElem> Select<TRElem>(Func<T, TRElem> selector)
{
return base._Select(GetPrototype<TRElem>(), selector);
}

Expand All @@ -32,7 +35,8 @@ partial class ImmList<T> : AbstractSequential<T, ImmList<T>> {
/// <typeparam name="TRElem">The type of the output collection element.</typeparam>
/// <param name="selector">The selector.</param>
/// <returns></returns>
public ImmList<TRElem> Select<TRElem>(Func<T, Optional<TRElem>> selector) {
public ImmList<TRElem> Select<TRElem>(Func<T, Optional<TRElem>> selector)
{
return base._Choose(GetPrototype<TRElem>(), selector);
}

Expand All @@ -43,7 +47,8 @@ partial class ImmList<T> : AbstractSequential<T, ImmList<T>> {
/// <typeparam name="TRElem">The type of the output collection element.</typeparam>
/// <param name="selector">The selector.</param>
/// <returns></returns>
public ImmList<TRElem> Choose<TRElem>(Func<T, Optional<TRElem>> selector) {
public ImmList<TRElem> Choose<TRElem>(Func<T, Optional<TRElem>> selector)
{
return base._Choose(GetPrototype<TRElem>(), selector);
}

Expand All @@ -54,15 +59,30 @@ partial class ImmList<T> : AbstractSequential<T, ImmList<T>> {
/// <typeparam name="TRElem">The type of the ouput collection elem.</typeparam>
/// <param name="selector">The selector.</param>
/// <returns></returns>
public ImmList<TRElem> SelectMany<TRElem>(Func<T, IEnumerable<TRElem>> selector) {
public ImmList<TRElem> SelectMany<TRElem>(Func<T, IEnumerable<TRElem>> selector)
{
return base._SelectMany(GetPrototype<TRElem>(), selector);
}



public ImmList<TResult> GroupJoin<TInner, TKey, TResult>(IEnumerable<TInner> inner, Func<T, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<T, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> eq = null) {
return base._GroupJoin(GetPrototype<TResult>(), inner, outerKeySelector, innerKeySelector, resultSelector, eq);
}
/// <summary>
/// Groups the elements of this collection and a sequence based on equality of keys, and groups the results. The specified equality comparer is used to compare keys, if provided.
/// </summary>
/// <typeparam name="TInner">The type of the input sequence.</typeparam>
/// <typeparam name="TKey">The type of the key used to join the results.</typeparam>
/// <typeparam name="TResult">The type of the result element.</typeparam>
/// <param name="inner">The input sequence.</param>
/// <param name="outerKeySelector">The key selector for the current collection.</param>
/// <param name="innerKeySelector">The key selector for the input sequence.</param>
/// <param name="resultSelector">The result selector that aggregates all the results.</param>
/// <param name="eq">An optional equality comparer. If null, the default is used.</param>
/// <returns></returns>
public ImmList<TResult> GroupJoin<TInner, TKey, TResult>(IEnumerable<TInner> inner, Func<T, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<T, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> eq = null)
{

return base._GroupJoin(GetPrototype<TResult>(), inner, outerKeySelector, innerKeySelector, resultSelector, eq);
}

/// <summary>
/// Applies an element selector on every element of the collection, yielding a sequence.
Expand All @@ -75,7 +95,8 @@ partial class ImmList<T> : AbstractSequential<T, ImmList<T>> {
/// <param name="rSelector">The result selector.</param>
/// <returns></returns>
public ImmList<TRElem> SelectMany<TElem2, TRElem>(Func<T, IEnumerable<TElem2>> selector,
Func<T, TElem2, TRElem> rSelector) {
Func<T, TElem2, TRElem> rSelector)
{
return base._SelectMany(GetPrototype<TRElem>(), selector, rSelector);
}

Expand All @@ -94,7 +115,8 @@ partial class ImmList<T> : AbstractSequential<T, ImmList<T>> {
/// <returns></returns>
public ImmList<TRElem> Join<TRElem, TInner, TKey>(IEnumerable<TInner> inner, Func<T, TKey> oKeySelector,
Func<TInner, TKey> iKeySelector, Func<T, TInner, TRElem> rSelector,
IEqualityComparer<TKey> eq = null) {
IEqualityComparer<TKey> eq = null)
{
return base._Join(GetPrototype<TRElem>(), inner, oKeySelector, iKeySelector, rSelector,
eq ?? EqualityComparer<TKey>.Default);
}
Expand All @@ -111,7 +133,8 @@ partial class ImmList<T> : AbstractSequential<T, ImmList<T>> {
/// <param name="eq"></param>
/// <returns></returns>
public ImmList<KeyValuePair<T, TInner>> Join<TInner, TKey>(IEnumerable<TInner> inner, Func<T, TKey> oKeySelector,
Func<TInner, TKey> iKeySelector, IEqualityComparer<TKey> eq = null) {
Func<TInner, TKey> iKeySelector, IEqualityComparer<TKey> eq = null)
{

return Join(inner, oKeySelector, iKeySelector, Kvp.Of, eq);
}
Expand All @@ -129,7 +152,8 @@ partial class ImmList<T> : AbstractSequential<T, ImmList<T>> {
/// <param name="eq">The equality comparer.</param>
/// <returns></returns>
public ImmList<TRElem> GroupBy<TRElem, TElem2, TKey>(Func<T, TKey> keySelector, Func<T, TElem2> valueSelector,
Func<TKey, IEnumerable<TElem2>, TRElem> rSelector, IEqualityComparer<TKey> eq = null) {
Func<TKey, IEnumerable<TElem2>, TRElem> rSelector, IEqualityComparer<TKey> eq = null)
{
return base._GroupBy(GetPrototype<TRElem>(), keySelector, valueSelector, rSelector,
eq ?? EqualityComparer<TKey>.Default);
}
Expand All @@ -150,7 +174,8 @@ partial class ImmList<T> : AbstractSequential<T, ImmList<T>> {
/// <param name="eq">The equality comparer.</param>
/// <returns></returns>
public ImmList<KeyValuePair<TKey, IEnumerable<TElem2>>> GroupBy<TKey, TElem2>(Func<T, TKey> keySelector, Func<T, TElem2> elementSelector,
IEqualityComparer<TKey> eq = null) {
IEqualityComparer<TKey> eq = null)
{
return GroupBy(keySelector, elementSelector, Kvp.Of, eq ?? EqualityComparer<TKey>.Default);
}

Expand All @@ -167,7 +192,8 @@ partial class ImmList<T> : AbstractSequential<T, ImmList<T>> {
/// <param name="eq">The equality comparer.</param>
/// <returns></returns>
public ImmList<KeyValuePair<TKey, IEnumerable<T>>> GroupBy<TKey>(Func<T, TKey> keySelector,
IEqualityComparer<TKey> eq = null) {
IEqualityComparer<TKey> eq = null)
{
return GroupBy(keySelector, x => x, Kvp.Of, eq ?? EqualityComparer<TKey>.Default);
}

Expand All @@ -176,7 +202,8 @@ partial class ImmList<T> : AbstractSequential<T, ImmList<T>> {
/// </summary>
/// <typeparam name="TRElem">The return element type.</typeparam>
/// <returns></returns>
public ImmList<TRElem> Cast<TRElem>() {
public ImmList<TRElem> Cast<TRElem>()
{
return base._Cast<TRElem, ImmList<TRElem>>(GetPrototype<TRElem>());
}

Expand All @@ -188,7 +215,8 @@ partial class ImmList<T> : AbstractSequential<T, ImmList<T>> {
/// <param name="initial">The initial value for the accumulator.</param>
/// <param name="accumulator">The accumulator.</param>
/// <returns></returns>
public ImmList<TRElem> Scan<TRElem>(TRElem initial, Func<TRElem, T, TRElem> accumulator) {
public ImmList<TRElem> Scan<TRElem>(TRElem initial, Func<TRElem, T, TRElem> accumulator)
{
return base._Scan(GetPrototype<TRElem>(), initial, accumulator);
}

Expand All @@ -200,7 +228,8 @@ partial class ImmList<T> : AbstractSequential<T, ImmList<T>> {
/// <param name="initial">The initial value for the accumulator.</param>
/// <param name="accumulator">The accumulator.</param>
/// <returns></returns>
public ImmList<TRElem> ScanBack<TRElem>(TRElem initial, Func<TRElem, T, TRElem> accumulator) {
public ImmList<TRElem> ScanBack<TRElem>(TRElem initial, Func<TRElem, T, TRElem> accumulator)
{
return base._ScanBack(GetPrototype<TRElem>(), initial, accumulator);
}

Expand All @@ -212,21 +241,24 @@ partial class ImmList<T> : AbstractSequential<T, ImmList<T>> {
/// <param name="other">The other collection. The right-hand parameter of the selector.</param>
/// <param name="selector">The selector used to select the result.</param>
/// <returns></returns>
public ImmList<TRElem> Zip<TElem2, TRElem>(IEnumerable<TElem2> other, Func<T, TElem2, TRElem> selector) {
public ImmList<TRElem> Zip<TElem2, TRElem>(IEnumerable<TElem2> other, Func<T, TElem2, TRElem> selector)
{
return base._Zip(GetPrototype<TRElem>(), other, selector);
}

/// <summary>
/// <summary>
/// Zips this collection with another one, returning a collection of pairs.
/// </summary>
/// <typeparam name="TElem2">The type of element of the 2nd collection.</typeparam>
/// <param name="other">The other collection. The right-hand parameter of the selector.</param>
/// <returns></returns>
public ImmList<Tuple<T, TElem2>> Zip<TElem2>(IEnumerable<TElem2> other) {
public ImmList<Tuple<T, TElem2>> Zip<TElem2>(IEnumerable<TElem2> other)
{
return Zip(other, Tuple.Create);
}

private ImmList<TElem2> GetPrototype<TElem2>() {
private ImmList<TElem2> GetPrototype<TElem2>()
{
return ImmList<TElem2>.Instance;
}
}
Expand Down

0 comments on commit e5fa401

Please sign in to comment.