Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ChunkedListExtensions.cs
1using System.Text;
2
4{
8 public static class ChunkedListExtensions
9 {
15 public static void Append(this StringBuilder sb, ChunkedList<string> List)
16 {
17 sb.Append(List, null);
18 }
19
26 public static void Append(this StringBuilder sb, ChunkedList<string> List,
27 string Delimiter)
28 {
29 ChunkNode<string> Loop = List.FirstChunk;
30 bool HasDelimiter = !string.IsNullOrEmpty(Delimiter);
31 int i, c;
32 bool First = true;
33
34 while (!(Loop is null))
35 {
36 for (i = Loop.Start, c = Loop.Pos; i < c; i++)
37 {
38 if (HasDelimiter)
39 {
40 if (First)
41 First = false;
42 else
43 sb.Append(Delimiter);
44 }
45
46 sb.Append(Loop[i]);
47 }
48
49 Loop = Loop.Next;
50 }
51 }
52
58 public static string Concatenate(this ChunkedList<string> List)
59 {
60 return List.Concatenate(null);
61 }
62
69 public static string Concatenate(this ChunkedList<string> List, string Delimiter)
70 {
71 StringBuilder sb = new StringBuilder();
72 sb.Append(List, Delimiter);
73 return sb.ToString();
74 }
75 }
76}
Node referencing a chunk in a ChunkedList<T>
Definition: ChunkNode.cs:11
ChunkNode< T > Next
Next chunk
Definition: ChunkNode.cs:26
int Pos
Index after the last element in chunk.
Definition: ChunkNode.cs:51
int Start
Index of first element in chunk.
Definition: ChunkNode.cs:46
static void Append(this StringBuilder sb, ChunkedList< string > List, string Delimiter)
Appends the elements of a chunked list with string elements, to a string builder.
static string Concatenate(this ChunkedList< string > List)
Concatenates the string elements of a chunked list.
static string Concatenate(this ChunkedList< string > List, string Delimiter)
Concatenates the string elements of a chunked list.
static void Append(this StringBuilder sb, ChunkedList< string > List)
Appends the elements of a chunked list with string elements, to a string builder.
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54
ChunkNode< T > FirstChunk
First chunk
Definition: ChunkedList.cs:259