-
-
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.
Update documentation for
DensePartialSort
- Loading branch information
1 parent
85272c5
commit a359722
Showing
11 changed files
with
630 additions
and
117 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
Docs/SuperLinq.Docs/apidoc/SuperLinq.SuperEnumerable.DensePartialSort.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,28 @@ | ||
--- | ||
uid: SuperLinq.SuperEnumerable.DensePartialSort``1(System.Collections.Generic.IEnumerable{``0},System.Int32) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to get the top N items of a sequence using `DensePartialSort`. | ||
[!code-csharp[](SuperLinq/DensePartialSort/DensePartialSort1.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.DensePartialSort``1(System.Collections.Generic.IEnumerable{``0},System.Int32,SuperLinq.OrderByDirection) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to get the top N items of a sequence using `DensePartialSort`. | ||
[!code-csharp[](SuperLinq/DensePartialSort/DensePartialSort2.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.DensePartialSort``1(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Collections.Generic.IComparer{``0}) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to get the top N items of a sequence using `DensePartialSort`. | ||
[!code-csharp[](SuperLinq/DensePartialSort/DensePartialSort3.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.DensePartialSort``1(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Collections.Generic.IComparer{``0},SuperLinq.OrderByDirection) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to get the top N items of a sequence using `DensePartialSort`. | ||
[!code-csharp[](SuperLinq/DensePartialSort/DensePartialSort4.linq#L6-)] | ||
|
28 changes: 28 additions & 0 deletions
28
Docs/SuperLinq.Docs/apidoc/SuperLinq.SuperEnumerable.DensePartialSortBy.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,28 @@ | ||
--- | ||
uid: SuperLinq.SuperEnumerable.DensePartialSortBy``2(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Func{``0,``1}) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to get the top N items of a sequence using `DensePartialSort`. | ||
[!code-csharp[](SuperLinq/DensePartialSortBy/DensePartialSortBy1.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.DensePartialSortBy``2(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Func{``0,``1},SuperLinq.OrderByDirection) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to get the top N items of a sequence using `DensePartialSort`. | ||
[!code-csharp[](SuperLinq/DensePartialSortBy/DensePartialSortBy2.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.DensePartialSortBy``2(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Func{``0,``1},System.Collections.Generic.IComparer{``1}) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to get the top N items of a sequence using `DensePartialSort`. | ||
[!code-csharp[](SuperLinq/DensePartialSortBy/DensePartialSortBy3.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.DensePartialSortBy``2(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Func{``0,``1},System.Collections.Generic.IComparer{``1},SuperLinq.OrderByDirection) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to get the top N items of a sequence using `DensePartialSort`. | ||
[!code-csharp[](SuperLinq/DensePartialSortBy/DensePartialSortBy4.linq#L6-)] | ||
|
47 changes: 47 additions & 0 deletions
47
Docs/SuperLinq.Docs/apidoc/SuperLinq/DensePartialSort/DensePartialSort1.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"), | ||
}; | ||
|
||
// Get the top N sets of items | ||
var result = sequence.DensePartialSort(3); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [(1, 9), (1, 10), (2, 7), (2, 8), (3, 5), (3, 6)] | ||
|
||
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})"; | ||
} |
47 changes: 47 additions & 0 deletions
47
Docs/SuperLinq.Docs/apidoc/SuperLinq/DensePartialSort/DensePartialSort2.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"), | ||
}; | ||
|
||
// Get the top N sets of items | ||
var result = sequence.DensePartialSort(3, OrderByDirection.Descending); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [(5, 1), (5, 2), (4, 3), (4, 4), (3, 5), (3, 6)] | ||
|
||
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/DensePartialSort/DensePartialSort3.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 | ||
.DensePartialSort( | ||
3, | ||
Comparer<(int key, string text)>.Create((x, y) => x.key.CompareTo(y.key))); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [(1, 9), (1, 10), (2, 7), (2, 8), (3, 5), (3, 6)] |
33 changes: 33 additions & 0 deletions
33
Docs/SuperLinq.Docs/apidoc/SuperLinq/DensePartialSort/DensePartialSort4.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 | ||
.DensePartialSort( | ||
3, | ||
Comparer<(int key, string text)>.Create((x, y) => x.key.CompareTo(y.key)), | ||
OrderByDirection.Descending); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [(5, 1), (5, 2), (4, 3), (4, 4), (3, 5), (3, 6)] |
32 changes: 32 additions & 0 deletions
32
Docs/SuperLinq.Docs/apidoc/SuperLinq/DensePartialSortBy/DensePartialSortBy1.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 | ||
.DensePartialSortBy( | ||
3, | ||
x => x.key); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [(1, 9), (1, 10), (2, 7), (2, 8), (3, 5), (3, 6)] |
33 changes: 33 additions & 0 deletions
33
Docs/SuperLinq.Docs/apidoc/SuperLinq/DensePartialSortBy/DensePartialSortBy2.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 | ||
.DensePartialSortBy( | ||
3, | ||
x => x.key, | ||
OrderByDirection.Descending); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [(5, 1), (5, 2), (4, 3), (4, 4), (3, 5), (3, 6)] |
33 changes: 33 additions & 0 deletions
33
Docs/SuperLinq.Docs/apidoc/SuperLinq/DensePartialSortBy/DensePartialSortBy3.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 | ||
.DensePartialSortBy( | ||
1, | ||
x => x.key, | ||
Comparer<int>.Create((x, y) => (x % 2).CompareTo(y % 2))); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [(4, 3), (4, 4), (2, 7), (2, 8)] |
34 changes: 34 additions & 0 deletions
34
Docs/SuperLinq.Docs/apidoc/SuperLinq/DensePartialSortBy/DensePartialSortBy4.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,34 @@ | ||
<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 | ||
.DensePartialSortBy( | ||
1, | ||
x => x.key, | ||
Comparer<int>.Create((x, y) => (x % 2).CompareTo(y % 2)), | ||
OrderByDirection.Descending); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [(5, 1), (5, 2), (3, 5), (3, 6), (1, 9), (1, 10)] |
Oops, something went wrong.