Skip to content

Commit ac15ecb

Browse files
Merge pull request justcoding121#19 from justcoding121/master
Beta
2 parents 6dcd680 + 54d6038 commit ac15ecb

File tree

100 files changed

+621
-278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+621
-278
lines changed

Advanced.Algorithms.Tests/Distributed/AsyncQueue_Tests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void AsyncQueue_Test()
3131
//multi-threaded async producer
3232
tasks.AddRange(Enumerable.Range(1, testDataCount).Select(async x =>
3333
{
34-
await Task.Delay(random.Next(0, 2));
34+
await Task.Delay(random.Next(0, 1));
3535

3636
await producerLock.WaitAsync();
3737

@@ -46,7 +46,7 @@ public void AsyncQueue_Test()
4646
//multi-threaded async consumer
4747
tasks.AddRange(Enumerable.Range(1, testDataCount).Select(async x =>
4848
{
49-
await Task.Delay(random.Next(0, 2));
49+
await Task.Delay(random.Next(0, 1));
5050

5151
await consumerLock.WaitAsync();
5252

Advanced.Algorithms/DataStructures/Graph/AdjacencyList/DiGraph.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public void AddEdge(T source, T dest)
114114
}
115115

116116
/// <summary>
117-
/// Remove an existing edge between source & destination.
117+
/// Remove an existing edge between source and destination.
118118
/// Time complexity: O(1).
119119
/// </summary>
120120
public void RemoveEdge(T source, T dest)
@@ -218,7 +218,7 @@ public IEnumerator<T> GetEnumerator()
218218
}
219219

220220
/// <summary>
221-
/// DiGraph vertex.
221+
/// DiGraph vertex for adjacency list Graph implementation.
222222
/// IEnumerable enumerates all the outgoing edge destination vertices.
223223
/// </summary>
224224
public class DiGraphVertex<T> : IEnumerable<T>

Advanced.Algorithms/DataStructures/Graph/AdjacencyList/Graph.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public GraphVertex<T> AddVertex(T value)
6262
/// Remove an existing vertex from this graph.
6363
/// Time complexity: O(V) where V is the number of vertices.
6464
/// </summary>
65-
/// <param name="vertex"></param>
6665
public void RemoveVertex(T vertex)
6766
{
6867
if (vertex == null)
@@ -188,7 +187,7 @@ public IEnumerator<T> GetEnumerator()
188187
}
189188

190189
/// <summary>
191-
/// Graph vertex.
190+
/// Graph vertex for adjacency list Graph implementation.
192191
/// IEnumerable enumerates all the outgoing edge destination vertices.
193192
/// </summary>
194193
public class GraphVertex<T> : IEnumerable<T>

Advanced.Algorithms/DataStructures/Graph/AdjacencyList/WeightedDiGraph.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public IEnumerator<T> GetEnumerator()
224224
}
225225

226226
/// <summary>
227-
/// A weighted graph vertex.
227+
/// A weighted graph vertex for adjacency list Graph implementation.
228228
/// IEnumerable enumerates all the outgoing edge destination vertices.
229229
/// </summary>
230230
public class WeightedDiGraphVertex<T, TW> : IEnumerable<T> where TW : IComparable

Advanced.Algorithms/DataStructures/Graph/AdjacencyList/WeightedGraph.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ public IEnumerator<T> GetEnumerator()
181181
return Vertices.Select(x => x.Key).GetEnumerator();
182182
}
183183
}
184-
184+
185185
/// <summary>
186-
/// A weighted graph vertex.
186+
/// A weighted graph vertex for adjacency list Graph implementation.
187187
/// IEnumerable enumerates all the outgoing edge destination vertices.
188188
/// </summary>
189189
public class WeightedGraphVertex<T, TW> : IEnumerable<T> where TW : IComparable

Advanced.Algorithms/DataStructures/Graph/AdjacencyMatrix/DiGraph.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public void AddVertex(T value)
7474
/// Remove an existing vertex from graph
7575
/// Time complexity: O(V) where V is the number of vertices.
7676
/// </summary>
77-
/// <param name="value"></param>
7877
public void RemoveVertex(T value)
7978
{
8079
if (value == null)
@@ -112,8 +111,6 @@ public void RemoveVertex(T value)
112111
/// add an edge from source to destination vertex
113112
/// Time complexity: O(1).
114113
/// </summary>
115-
/// <param name="source"></param>
116-
/// <param name="dest"></param>
117114
public void AddEdge(T source, T dest)
118115
{
119116
if (source == null || dest == null)
@@ -137,7 +134,7 @@ public void AddEdge(T source, T dest)
137134
}
138135

139136
/// <summary>
140-
/// remove an existing edge between source & destination
137+
/// remove an existing edge between source and destination
141138
/// Time complexity: O(1).
142139
/// </summary>
143140
public void RemoveEdge(T source, T dest)

Advanced.Algorithms/DataStructures/Graph/AdjacencyMatrix/Graph.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4+
using System.Linq;
45

56
namespace Advanced.Algorithms.DataStructures.Graph.AdjacencyMatrix
67
{
@@ -9,7 +10,7 @@ namespace Advanced.Algorithms.DataStructures.Graph.AdjacencyMatrix
910
/// A directed graph implementation using dynamically growinng/shrinking adjacency matrix array.
1011
/// IEnumerable enumerates all vertices.
1112
/// </summary>
12-
public class Graph<T>
13+
public class Graph<T> : IEnumerable<T>
1314
{
1415
public int VerticesCount => usedSize;
1516

@@ -135,7 +136,7 @@ public void AddEdge(T source, T dest)
135136
}
136137

137138
/// <summary>
138-
/// Remove an existing edge between source & destination.
139+
/// Remove an existing edge between source and destination.
139140
/// Time complexity: O(1).
140141
/// </summary>
141142
public void RemoveEdge(T source, T dest)
@@ -298,5 +299,15 @@ private void halfMatrixSize()
298299
reverseVertexIndices = newReverseIndices;
299300
maxSize /= 2;
300301
}
302+
303+
IEnumerator IEnumerable.GetEnumerator()
304+
{
305+
return GetEnumerator();
306+
}
307+
308+
public IEnumerator<T> GetEnumerator()
309+
{
310+
return vertexIndices.Select(x => x.Key).GetEnumerator();
311+
}
301312
}
302313
}

Advanced.Algorithms/DataStructures/Graph/AdjacencyMatrix/WeightedDiGraph.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
4+
using System.Linq;
35

46
namespace Advanced.Algorithms.DataStructures.Graph.AdjacencyMatrix
57
{
68
/// <summary>
79
/// A weighted graph implementation using dynamically growinng/shrinking adjacency matrix array.
810
/// IEnumerable enumerates all vertices.
911
/// </summary>
10-
public class WeightedDiGraph<T, TW> where TW : IComparable
12+
public class WeightedDiGraph<T, TW> : IEnumerable<T> where TW : IComparable
1113
{
1214
public int VerticesCount => usedSize;
1315

@@ -301,5 +303,15 @@ private void halfMatrixSize()
301303
reverseVertexIndices = newReverseIndices;
302304
maxSize /= 2;
303305
}
306+
307+
IEnumerator IEnumerable.GetEnumerator()
308+
{
309+
return GetEnumerator();
310+
}
311+
312+
public IEnumerator<T> GetEnumerator()
313+
{
314+
return vertexIndices.Select(x => x.Key).GetEnumerator();
315+
}
304316
}
305317
}

Advanced.Algorithms/DataStructures/Graph/AdjacencyMatrix/WeightedGraph.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
4+
using System.Linq;
35

46
namespace Advanced.Algorithms.DataStructures.Graph.AdjacencyMatrix
57
{
68
/// <summary>
79
/// A weighted graph implementation using dynamically growinng/shrinking adjacency matrix array.
810
/// IEnumerable enumerates all vertices.
911
/// </summary>
10-
public class WeightedGraph<T, TW> where TW : IComparable
12+
public class WeightedGraph<T, TW> : IEnumerable<T> where TW : IComparable
1113
{
1214
public int VerticesCount => usedSize;
1315

@@ -288,5 +290,15 @@ private void halfMatrixSize()
288290
reverseVertexIndices = newReverseIndices;
289291
maxSize /= 2;
290292
}
293+
294+
IEnumerator IEnumerable.GetEnumerator()
295+
{
296+
return GetEnumerator();
297+
}
298+
299+
public IEnumerator<T> GetEnumerator()
300+
{
301+
return vertexIndices.Select(x => x.Key).GetEnumerator();
302+
}
291303
}
292304
}

Advanced.Algorithms/DataStructures/Heap/Max/BinomialMaxHeap.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ public void Merge(BinomialMaxHeap<T> binomialHeap)
135135
/// <summary>
136136
/// Time complexity: O(log(n)).
137137
/// </summary>
138-
/// <returns></returns>
139138
public T PeekMax()
140139
{
141140
if (heapForest.Head == null)
@@ -184,7 +183,7 @@ private void meld()
184183
cur = next;
185184
next = cur.Next;
186185
}
187-
//degress of cur & next are same
186+
//degress of cur and next are same
188187
else
189188
{
190189
//case 2 next degree equals next-next degree

Advanced.Algorithms/DataStructures/Heap/Max/FibornacciMaxHeap.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ private void cut(FibornacciHeapNode<T> node)
291291
/// <summary>
292292
/// Merges the given fibornacci node list to current Forest
293293
/// </summary>
294-
/// <param name="headPointer"></param>
295294
private void mergeForests(FibornacciHeapNode<T> headPointer)
296295
{
297296
var current = headPointer;

Advanced.Algorithms/DataStructures/Heap/Min/BinomialMinHeap.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ public void Merge(BinomialMinHeap<T> binomialHeap)
135135
/// <summary>
136136
/// Time complexity: O(log(n)).
137137
/// </summary>
138-
/// <returns></returns>
139138
public T PeekMin()
140139
{
141140
if (heapForest.Head == null)
@@ -184,7 +183,7 @@ private void meld()
184183
cur = next;
185184
next = cur.Next;
186185
}
187-
//degress of cur & next are same
186+
//degress of cur and next are same
188187
else
189188
{
190189
//case 2 next degree equals next-next degree
@@ -228,7 +227,7 @@ private void meld()
228227

229228
/// <summary>
230229
/// Merges the given sorted forest to current sorted Forest
231-
/// & returns the last inserted node (pointer required for decrement-key)
230+
/// and returns the last inserted node (pointer required for decrement-key)
232231
/// </summary>
233232
private void mergeSortedForests(DoublyLinkedList<BinomialHeapNode<T>> newHeapForest)
234233
{

Advanced.Algorithms/DataStructures/Heap/Min/FibornacciMinHeap.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ private void cut(FibornacciHeapNode<T> node)
288288
/// <summary>
289289
/// Merges the given fibornacci node list to current Forest
290290
/// </summary>
291-
/// <param name="headPointer"></param>
292291
private void mergeForests(FibornacciHeapNode<T> headPointer)
293292
{
294293
var current = headPointer;

Advanced.Algorithms/DataStructures/LinkedList/DoublyLinkedList.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public T DeleteFirst()
198198
/// Delete tail node.
199199
/// Time complexity: O(1)
200200
/// </summary>
201-
/// <returns></returns>
201+
///
202202
public T DeleteLast()
203203
{
204204
if (Tail == null)
@@ -344,7 +344,7 @@ internal void Union(DoublyLinkedList<T> newList)
344344
/// <summary>
345345
/// Time complexity: O(1).
346346
/// </summary>
347-
/// <returns></returns>
347+
///
348348
public bool IsEmpty() => Head == null;
349349

350350
/// <summary>

Advanced.Algorithms/DataStructures/LinkedList/SinglyLinkedList.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public void InsertLast(T data)
5151
/// <summary>
5252
/// Time complexity: O(1).
5353
/// </summary>
54-
/// <returns></returns>
5554
public T DeleteFirst()
5655
{
5756
if (Head == null)
@@ -69,7 +68,6 @@ public T DeleteFirst()
6968
/// <summary>
7069
/// Time complexity: O(n).
7170
/// </summary>
72-
/// <returns></returns>
7371
public T DeleteLast()
7472
{
7573
if (Head == null)

Advanced.Algorithms/DataStructures/List/ArrayList.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public ArrayList(IEnumerable<T> initial)
5656
/// Time complexity: O(1).
5757
/// </summary>
5858
/// <param name="index">The index to write or read.</param>
59-
/// <returns></returns>
6059
public T this[int index]
6160
{
6261
get => itemAt(index);
@@ -75,7 +74,6 @@ private T itemAt(int i)
7574
/// Add a new item to this array list.
7675
/// Time complexity: O(1) amortized.
7776
/// </summary>
78-
/// <param name="item"></param>
7977
public void Add(T item)
8078
{
8179
grow();

Advanced.Algorithms/DataStructures/List/SkipList.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ public SkipList(int maxHeight = 32)
4141
/// If item is not found default value of T will be returned.
4242
/// Time complexity: O(log(n)).
4343
/// </summary>
44-
/// <param name="value"></param>
45-
/// <returns></returns>
4644
public T Find(T value)
4745
{
4846
var current = Head;

Advanced.Algorithms/DataStructures/Queues/PriorityQueue/MaxPriorityQueue.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public void Enqueue(T item)
2323
/// <summary>
2424
/// Time complexity:O(log(n)).
2525
/// </summary>
26-
/// <returns></returns>
2726
public T Dequeue()
2827
{
2928
return maxHeap.ExtractMax();
@@ -32,7 +31,6 @@ public T Dequeue()
3231
/// <summary>
3332
/// Time complexity:O(1).
3433
/// </summary>
35-
/// <returns></returns>
3634
public T Peek()
3735
{
3836
return maxHeap.PeekMax();

Advanced.Algorithms/DataStructures/Queues/PriorityQueue/MinPriorityQueue.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public T Dequeue()
3131
/// <summary>
3232
/// Time complexity:O(1).
3333
/// </summary>
34-
/// <returns></returns>
3534
public T Peek()
3635
{
3736
return minHeap.PeekMin();

Advanced.Algorithms/DataStructures/Queues/Queue.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public Queue(QueueType type = QueueType.Array)
3131
/// <summary>
3232
/// Time complexity:O(1).
3333
/// </summary>
34-
/// <param name="item"></param>
3534
public void Enqueue(T item)
3635
{
3736
queue.Enqueue(item);
@@ -40,7 +39,6 @@ public void Enqueue(T item)
4039
/// <summary>
4140
/// Time complexity:O(1).
4241
/// </summary>
43-
/// <returns></returns>
4442
public T Dequeue()
4543
{
4644
return queue.Dequeue();

0 commit comments

Comments
 (0)