-
-
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.
- Loading branch information
1 parent
ec5ff70
commit ea3f57f
Showing
5 changed files
with
205 additions
and
21 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
Docs/SuperLinq.Docs/apidoc/SuperLinq.SuperEnumerable.Segment.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,21 @@ | ||
--- | ||
uid: SuperLinq.SuperEnumerable.Segment``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean}) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to split a sequence based on a segment detector using `Segment`. | ||
[!code-csharp[](SuperLinq/Segment/Segment1.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.Segment``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Int32,System.Boolean}) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to split a sequence based on a segment detector using `Segment`. | ||
[!code-csharp[](SuperLinq/Segment/Segment2.linq#L6-)] | ||
|
||
--- | ||
uid: SuperLinq.SuperEnumerable.Segment``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``0,System.Int32,System.Boolean}) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to split a sequence based on a segment detector using `Segment`. | ||
[!code-csharp[](SuperLinq/Segment/Segment3.linq#L6-)] | ||
|
38 changes: 38 additions & 0 deletions
38
Docs/SuperLinq.Docs/apidoc/SuperLinq/Segment/Segment1.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,38 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = new[] | ||
{ | ||
(key: "jan", value: 123), | ||
(key: "Jan", value: 456), | ||
(key: "JAN", value: 789), | ||
(key: "feb", value: 987), | ||
(key: "Feb", value: 654), | ||
(key: "FEB", value: 321), | ||
(key: "mar", value: 789), | ||
(key: "Mar", value: 456), | ||
(key: "MAR", value: 123), | ||
(key: "jan", value: 123), | ||
(key: "Jan", value: 456), | ||
(key: "JAN", value: 781), | ||
}; | ||
|
||
// Group adjacent items | ||
var result = sequence | ||
.Segment( | ||
x => x.key[0] == 'm'); | ||
|
||
Console.WriteLine( | ||
"[" + Environment.NewLine + | ||
string.Join( | ||
", " + Environment.NewLine, | ||
result.Select(c => " [" + string.Join(", ", c) + "]")) + | ||
Environment.NewLine + "]"); | ||
|
||
// This code produces the following output: | ||
// [ | ||
// [(jan, 123), (Jan, 456), (JAN, 789), (feb, 987), (Feb, 654), (FEB, 321)], | ||
// [(mar, 789), (Mar, 456), (MAR, 123), (jan, 123), (Jan, 456), (JAN, 781)] | ||
// ] |
40 changes: 40 additions & 0 deletions
40
Docs/SuperLinq.Docs/apidoc/SuperLinq/Segment/Segment2.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,40 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = new[] | ||
{ | ||
(key: "jan", value: 123), | ||
(key: "Jan", value: 456), | ||
(key: "JAN", value: 789), | ||
(key: "feb", value: 987), | ||
(key: "Feb", value: 654), | ||
(key: "FEB", value: 321), | ||
(key: "mar", value: 789), | ||
(key: "Mar", value: 456), | ||
(key: "MAR", value: 123), | ||
(key: "jan", value: 123), | ||
(key: "Jan", value: 456), | ||
(key: "JAN", value: 781), | ||
}; | ||
|
||
// Group adjacent items | ||
var result = sequence | ||
.Segment( | ||
(x, i) => i % 3 == 0); | ||
|
||
Console.WriteLine( | ||
"[" + Environment.NewLine + | ||
string.Join( | ||
", " + Environment.NewLine, | ||
result.Select(c => " [" + string.Join(", ", c) + "]")) + | ||
Environment.NewLine + "]"); | ||
|
||
// This code produces the following output: | ||
// [ | ||
// [(jan, 123), (Jan, 456), (JAN, 789)], | ||
// [(feb, 987), (Feb, 654), (FEB, 321)], | ||
// [(mar, 789), (Mar, 456), (MAR, 123)], | ||
// [(jan, 123), (Jan, 456), (JAN, 781)] | ||
// ] |
40 changes: 40 additions & 0 deletions
40
Docs/SuperLinq.Docs/apidoc/SuperLinq/Segment/Segment3.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,40 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = new[] | ||
{ | ||
(key: "jan", value: 123), | ||
(key: "Jan", value: 456), | ||
(key: "JAN", value: 789), | ||
(key: "feb", value: 987), | ||
(key: "Feb", value: 654), | ||
(key: "FEB", value: 321), | ||
(key: "mar", value: 789), | ||
(key: "Mar", value: 456), | ||
(key: "MAR", value: 123), | ||
(key: "jan", value: 123), | ||
(key: "Jan", value: 456), | ||
(key: "JAN", value: 781), | ||
}; | ||
|
||
// Group adjacent items | ||
var result = sequence | ||
.Segment( | ||
(cur, prev, i) => !string.Equals(cur.key[..1], prev.key[..1], StringComparison.OrdinalIgnoreCase)); | ||
|
||
Console.WriteLine( | ||
"[" + Environment.NewLine + | ||
string.Join( | ||
", " + Environment.NewLine, | ||
result.Select(c => " [" + string.Join(", ", c) + "]")) + | ||
Environment.NewLine + "]"); | ||
|
||
// This code produces the following output: | ||
// [ | ||
// [(jan, 123), (Jan, 456), (JAN, 789)], | ||
// [(feb, 987), (Feb, 654), (FEB, 321)], | ||
// [(mar, 789), (Mar, 456), (MAR, 123)], | ||
// [(jan, 123), (Jan, 456), (JAN, 781)] | ||
// ] |
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