-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds documentation and samples for new methods
- Loading branch information
1 parent
38a261e
commit 4bf5ae5
Showing
12 changed files
with
378 additions
and
37 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
Docs/SuperLinq.Docs/apidoc/SuperLinq.SuperEnumerable.DenseRank.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
uid: SuperLinq.SuperEnumerable.DenseRank``1(System.Collections.Generic.IEnumerable{``0}) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to rank the items in a sequence using `DenseRank`. | ||
[!code-csharp[](SuperLinq/DenseRank/DenseRank1.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.DenseRank``1(System.Collections.Generic.IEnumerable{``0},SuperLinq.OrderByDirection) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to rank the items in a sequence using `DenseRank`. | ||
[!code-csharp[](SuperLinq/DenseRank/DenseRank2.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.DenseRank``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IComparer{``0}) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to rank the items in a sequence using `DenseRank`. | ||
[!code-csharp[](SuperLinq/DenseRank/DenseRank3.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.DenseRank``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IComparer{``0},SuperLinq.OrderByDirection) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to rank the items in a sequence using `DenseRank`. | ||
[!code-csharp[](SuperLinq/DenseRank/DenseRank4.linq#L6-)] |
27 changes: 27 additions & 0 deletions
27
Docs/SuperLinq.Docs/apidoc/SuperLinq.SuperEnumerable.DenseRankBy.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
uid: SuperLinq.SuperEnumerable.DenseRankBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1}) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to rank the items in a sequence according to a key using `DenseRankBy`. | ||
[!code-csharp[](SuperLinq/DenseRankBy/DenseRankBy1.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.DenseRankBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},SuperLinq.OrderByDirection) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to rank the items in a sequence according to a key using `DenseRankBy`. | ||
[!code-csharp[](SuperLinq/DenseRankBy/DenseRankBy2.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.DenseRankBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IComparer{``1}) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to rank the items in a sequence according to a key using `DenseRankBy`. | ||
[!code-csharp[](SuperLinq/DenseRankBy/DenseRankBy3.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.DenseRankBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IComparer{``1},SuperLinq.OrderByDirection) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to rank the items in a sequence according to a key using `DenseRankBy`. | ||
[!code-csharp[](SuperLinq/DenseRankBy/DenseRankBy4.linq#L6-)] |
46 changes: 9 additions & 37 deletions
46
Docs/SuperLinq.Docs/apidoc/SuperLinq.SuperEnumerable.Rank.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,27 @@ | ||
--- | ||
uid: SuperLinq.SuperEnumerable.DenseRank``1(System.Collections.Generic.IEnumerable{``0}) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to rank the items in a sequence using `DenseRank`. | ||
[!code-csharp[](SuperLinq/DenseRank/DenseRank1.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.DenseRank``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IComparer{``0}) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to rank the items in a sequence using `DenseRank`. | ||
[!code-csharp[](SuperLinq/DenseRank/DenseRank3.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.DenseRankBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1}) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to rank the items in a sequence according to a key using `DenseRankBy`. | ||
[!code-csharp[](SuperLinq/DenseRankBy/DenseRankBy1.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.DenseRankBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IComparer{``1}) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to rank the items in a sequence according to a key using `DenseRankBy`. | ||
[!code-csharp[](SuperLinq/DenseRankBy/DenseRankBy3.linq#L6-)] | ||
|
||
---- | ||
---- | ||
uid: SuperLinq.SuperEnumerable.Rank``1(System.Collections.Generic.IEnumerable{``0}) | ||
example: [*content] | ||
---- | ||
The following code example demonstrates how to rank the items in a sequence using `Rank`. | ||
[!code-csharp[](SuperLinq/Rank/Rank1.linq#L6-)] | ||
|
||
---- | ||
uid: SuperLinq.SuperEnumerable.Rank``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IComparer{``0}) | ||
uid: SuperLinq.SuperEnumerable.Rank``1(System.Collections.Generic.IEnumerable{``0},SuperLinq.OrderByDirection) | ||
example: [*content] | ||
---- | ||
The following code example demonstrates how to rank the items in a sequence using `Rank`. | ||
[!code-csharp[](SuperLinq/Rank/Rank3.linq#L6-)] | ||
[!code-csharp[](SuperLinq/Rank/Rank2.linq#L6-)] | ||
|
||
---- | ||
uid: SuperLinq.SuperEnumerable.RankBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1}) | ||
uid: SuperLinq.SuperEnumerable.Rank``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IComparer{``0}) | ||
example: [*content] | ||
---- | ||
The following code example demonstrates how to rank the items in a sequence according to a key using `RankBy`. | ||
[!code-csharp[](SuperLinq/RankBy/RankBy1.linq#L6-)] | ||
The following code example demonstrates how to rank the items in a sequence using `Rank`. | ||
[!code-csharp[](SuperLinq/Rank/Rank3.linq#L6-)] | ||
|
||
---- | ||
uid: SuperLinq.SuperEnumerable.RankBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IComparer{``1}) | ||
uid: SuperLinq.SuperEnumerable.Rank``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IComparer{``0},SuperLinq.OrderByDirection) | ||
example: [*content] | ||
---- | ||
The following code example demonstrates how to rank the items in a sequence according to a key using `RankBy`. | ||
[!code-csharp[](SuperLinq/RankBy/RankBy3.linq#L6-)] | ||
The following code example demonstrates how to rank the items in a sequence using `Rank`. | ||
[!code-csharp[](SuperLinq/Rank/Rank4.linq#L6-)] |
27 changes: 27 additions & 0 deletions
27
Docs/SuperLinq.Docs/apidoc/SuperLinq.SuperEnumerable.RankBy.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
---- | ||
uid: SuperLinq.SuperEnumerable.RankBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1}) | ||
example: [*content] | ||
---- | ||
The following code example demonstrates how to rank the items in a sequence according to a key using `RankBy`. | ||
[!code-csharp[](SuperLinq/RankBy/RankBy1.linq#L6-)] | ||
|
||
---- | ||
uid: SuperLinq.SuperEnumerable.RankBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},SuperLinq.OrderByDirection) | ||
example: [*content] | ||
---- | ||
The following code example demonstrates how to rank the items in a sequence according to a key using `RankBy`. | ||
[!code-csharp[](SuperLinq/RankBy/RankBy2.linq#L6-)] | ||
|
||
---- | ||
uid: SuperLinq.SuperEnumerable.RankBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IComparer{``1}) | ||
example: [*content] | ||
---- | ||
The following code example demonstrates how to rank the items in a sequence according to a key using `RankBy`. | ||
[!code-csharp[](SuperLinq/RankBy/RankBy3.linq#L6-)] | ||
|
||
---- | ||
uid: SuperLinq.SuperEnumerable.RankBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IComparer{``1},SuperLinq.OrderByDirection) | ||
example: [*content] | ||
---- | ||
The following code example demonstrates how to rank the items in a sequence according to a key using `RankBy`. | ||
[!code-csharp[](SuperLinq/RankBy/RankBy4.linq#L6-)] |
47 changes: 47 additions & 0 deletions
47
Docs/SuperLinq.Docs/apidoc/SuperLinq/DenseRank/DenseRank2.linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = new Item[] | ||
{ | ||
new(key: 5, text: "1"), | ||
new(key: 5, text: "2"), | ||
new(key: 4, text: "3"), | ||
new(key: 4, text: "4"), | ||
new(key: 3, text: "5"), | ||
new(key: 3, text: "6"), | ||
new(key: 2, text: "7"), | ||
new(key: 2, text: "8"), | ||
new(key: 1, text: "9"), | ||
new(key: 1, text: "10"), | ||
}; | ||
|
||
// Rank the items in the sequence | ||
var result = sequence.DenseRank(OrderByDirection.Ascending); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [((1, 9), 1), ((1, 10), 1), ((2, 7), 2), ((2, 8), 2), ((3, 5), 3), ((3, 6), 3), ((4, 3), 4), ((4, 4), 4), ((5, 1), 5), ((5, 2), 5)] | ||
|
||
class Item : IComparable<Item> | ||
{ | ||
public Item(int key, string text) | ||
{ | ||
Key = key; | ||
Text = text; | ||
} | ||
|
||
public int Key { get; } | ||
public string Text { get; } | ||
|
||
public int CompareTo(Item other) => | ||
this.Key.CompareTo(other.Key); | ||
|
||
public override string ToString() => | ||
$"({this.Key}, {this.Text})"; | ||
} |
32 changes: 32 additions & 0 deletions
32
Docs/SuperLinq.Docs/apidoc/SuperLinq/DenseRank/DenseRank4.linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = new[] | ||
{ | ||
(key: 5, text: "1"), | ||
(key: 5, text: "2"), | ||
(key: 4, text: "3"), | ||
(key: 4, text: "4"), | ||
(key: 3, text: "5"), | ||
(key: 3, text: "6"), | ||
(key: 2, text: "7"), | ||
(key: 2, text: "8"), | ||
(key: 1, text: "9"), | ||
(key: 1, text: "10"), | ||
}; | ||
|
||
// Get the top N sets of items | ||
var result = sequence | ||
.DenseRank( | ||
Comparer<(int key, string text)>.Create((x, y) => x.key.CompareTo(y.key)), | ||
OrderByDirection.Ascending); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [((1, 9), 1), ((1, 10), 1), ((2, 7), 2), ((2, 8), 2), ((3, 5), 3), ((3, 6), 3), ((4, 3), 4), ((4, 4), 4), ((5, 1), 5), ((5, 2), 5)] |
32 changes: 32 additions & 0 deletions
32
Docs/SuperLinq.Docs/apidoc/SuperLinq/DenseRankBy/DenseRankBy2.linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = new[] | ||
{ | ||
(key: 5, text: "1"), | ||
(key: 5, text: "2"), | ||
(key: 4, text: "3"), | ||
(key: 4, text: "4"), | ||
(key: 3, text: "5"), | ||
(key: 3, text: "6"), | ||
(key: 2, text: "7"), | ||
(key: 2, text: "8"), | ||
(key: 1, text: "9"), | ||
(key: 1, text: "10"), | ||
}; | ||
|
||
// Get the top N sets of items | ||
var result = sequence | ||
.DenseRankBy( | ||
x => x.key, | ||
OrderByDirection.Ascending); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [((1, 9), 1), ((1, 10), 1), ((2, 7), 2), ((2, 8), 2), ((3, 5), 3), ((3, 6), 3), ((4, 3), 4), ((4, 4), 4), ((5, 1), 5), ((5, 2), 5)] |
33 changes: 33 additions & 0 deletions
33
Docs/SuperLinq.Docs/apidoc/SuperLinq/DenseRankBy/DenseRankBy4.linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = new[] | ||
{ | ||
(key: 5, text: "1"), | ||
(key: 5, text: "2"), | ||
(key: 4, text: "3"), | ||
(key: 4, text: "4"), | ||
(key: 3, text: "5"), | ||
(key: 3, text: "6"), | ||
(key: 2, text: "7"), | ||
(key: 2, text: "8"), | ||
(key: 1, text: "9"), | ||
(key: 1, text: "10"), | ||
}; | ||
|
||
// Get the top N sets of items | ||
var result = sequence | ||
.DenseRankBy( | ||
x => x.key, | ||
Comparer<int>.Create((x, y) => (x % 2).CompareTo(y % 2)), | ||
OrderByDirection.Ascending); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [((4, 3), 1), ((4, 4), 1), ((2, 7), 1), ((2, 8), 1), ((5, 1), 2), ((5, 2), 2), ((3, 5), 2), ((3, 6), 2), ((1, 9), 2), ((1, 10), 2)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = new Item[] | ||
{ | ||
new(key: 5, text: "1"), | ||
new(key: 5, text: "2"), | ||
new(key: 4, text: "3"), | ||
new(key: 4, text: "4"), | ||
new(key: 3, text: "5"), | ||
new(key: 3, text: "6"), | ||
new(key: 2, text: "7"), | ||
new(key: 2, text: "8"), | ||
new(key: 1, text: "9"), | ||
new(key: 1, text: "10"), | ||
}; | ||
|
||
// Rank the items in the sequence | ||
var result = sequence.Rank(OrderByDirection.Ascending); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [((1, 9), 1), ((1, 10), 1), ((2, 7), 3), ((2, 8), 3), ((3, 5), 5), ((3, 6), 5), ((4, 3), 7), ((4, 4), 7), ((5, 1), 9), ((5, 2), 9)] | ||
|
||
class Item : IComparable<Item> | ||
{ | ||
public Item(int key, string text) | ||
{ | ||
Key = key; | ||
Text = text; | ||
} | ||
|
||
public int Key { get; } | ||
public string Text { get; } | ||
|
||
public int CompareTo(Item other) => | ||
this.Key.CompareTo(other.Key); | ||
|
||
public override string ToString() => | ||
$"({this.Key}, {this.Text})"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = new[] | ||
{ | ||
(key: 5, text: "1"), | ||
(key: 5, text: "2"), | ||
(key: 4, text: "3"), | ||
(key: 4, text: "4"), | ||
(key: 3, text: "5"), | ||
(key: 3, text: "6"), | ||
(key: 2, text: "7"), | ||
(key: 2, text: "8"), | ||
(key: 1, text: "9"), | ||
(key: 1, text: "10"), | ||
}; | ||
|
||
// Rank the items in the sequence | ||
var result = sequence | ||
.Rank( | ||
Comparer<(int key, string text)>.Create((x, y) => x.key.CompareTo(y.key)), | ||
OrderByDirection.Ascending); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [((1, 9), 1), ((1, 10), 1), ((2, 7), 3), ((2, 8), 3), ((3, 5), 5), ((3, 6), 5), ((4, 3), 7), ((4, 4), 7), ((5, 1), 9), ((5, 2), 9)] |
Oops, something went wrong.