Skip to content

Commit 5b85975

Browse files
committed
Merge branch 'master' into beta
2 parents e6e1c67 + 476f439 commit 5b85975

File tree

123 files changed

+313
-326
lines changed

Some content is hidden

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

123 files changed

+313
-326
lines changed

.build/build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Task Document -depends Build {
109109
git config --global credential.helper store
110110
Add-Content "$HOME\.git-credentials" "https://$($env:github_access_token):[email protected]`n"
111111
git config --global user.email $env:github_email
112-
git config --global user.name "buildbot121"
112+
git config --global user.name "buildbot171"
113113
git add . -A
114114
git commit -m "API documentation update by build server"
115115
git push origin master

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### Note:
22

3-
Please don't take effort to create pull requests for new algorithms/data structures. This is just a curiosity driven personal hobby and [was originally not intented to be a library](https://github.com/justcoding121/Advanced-Algorithms/issues/2). Feel free fork and modify to fit your need if that's what you are looking for. You can however open issues/fix bugs with pull requests here, I would be happy to take a look when I get time.
3+
Please don't take effort to create pull requests for new algorithms/data structures. This is just a curiosity-driven personal hobby and [was originally not intended to be a library](https://github.com/justcoding121/Advanced-Algorithms/issues/2). Feel free fork and modify to fit your need if that's what you are looking for. You can, however, open issues/fix bugs with pull requests here, I would be happy to take a look when I get time
44

55
## Advanced Algorithms
66

@@ -77,7 +77,7 @@ Supports
7777
- [X] Fibonacci heap ([implementation](https://github.com/justcoding121/Advanced-Algorithms/blob/master/src/Advanced.Algorithms/DataStructures/Heap/FibonacciHeap.cs) | [tests](https://github.com/justcoding121/Advanced-Algorithms/blob/master/tests/Advanced.Algorithms.Tests/DataStructures/Heap/FibonacciHeap_Tests.cs))
7878
- [X] Pairing heap ([implementation](https://github.com/justcoding121/Advanced-Algorithms/blob/master/src/Advanced.Algorithms/DataStructures/Heap/PairingHeap.cs) | [tests](https://github.com/justcoding121/Advanced-Algorithms/blob/master/tests/Advanced.Algorithms.Tests/DataStructures/Heap/PairingHeap_Tests.cs))
7979

80-
Note: It is observed that among the implementations here in practice, with the exclusion of UpdateKey (decrement/increment) operation regular Binary Heap & d-ary Heap outperforms other in theory superiors. Likely because it don't have pointer juggling overhead and hey arrays are faster!
80+
Note: It is observed that among the implementations here, in practice, with the exclusion of UpdateKey (decrement/increment) operation, regular Binary Heap & d-ary Heap outperforms other in theory superiors. Likely because it doesn't have pointer juggling overhead and hey arrays are faster!
8181

8282
### Tree
8383

appveyor.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ test: on
4040
skip_tags: true
4141

4242
skip_commits:
43-
author: buildbot121
43+
author: buildbot171
4444
files:
4545
- docs/*
4646
- README.md
@@ -58,11 +58,11 @@ artifacts:
5858

5959
environment:
6060
github_access_token:
61-
secure: BGdKiI7FwHGkFt+/OmgZDkE1hzLqLrTxcc9c+joVqGyO4LvesHb1sR6hzisVwVPm
61+
secure: mZLeq0GTB9kb5b6+HnVpJB6hhiYMJIQ2+Zf/DwZ/LEIyxJaYB1nx36aGHXE9q1cN
6262
github_email:
63-
secure: wvYod3JLufbIBkavRXlCP724wJkhqR2RRuLLaPnqfps=
63+
secure: iBJZGqxyiHVNeYI0uIW+MdGd3I3pg8brJtETNRkKe/A=
6464
nuget_access_token:
65-
secure: ZbRmjOcp+TDllRV1wxqLZjdRV7hld388rXlWVJuGGiQleomP9Ku+Nsy3a75E7/9k
65+
secure: 65rklofkoUWJzPPja621kXlxrruHemmbREnIX7QgXK0cydW412yYMZJQsN42Js27
6666
deploy:
6767
- provider: GitHub
6868
auth_token: $(github_access_token)

src/Advanced.Algorithms/Binary/BaseConversion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Text;
33

44
namespace Advanced.Algorithms.Binary
5-
{
5+
{
66
/// <summary>
77
/// Base conversion implementation.
88
/// </summary>

src/Advanced.Algorithms/Compression/HuffmanCoding.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using System;
1+
using Advanced.Algorithms.DataStructures;
2+
using System;
23
using System.Collections.Generic;
3-
using Advanced.Algorithms.DataStructures;
44

55
namespace Advanced.Algorithms.Compression
66
{
@@ -53,7 +53,7 @@ public Dictionary<T, byte[]> Compress(T[] input)
5353
/// </summary>
5454
private void dfs(FrequencyWrap currentNode, List<byte> pathStack, Dictionary<T, byte[]> result)
5555
{
56-
if(currentNode.IsLeaf)
56+
if (currentNode.IsLeaf)
5757
{
5858
result.Add(currentNode.Item, pathStack.ToArray());
5959
return;
@@ -114,7 +114,7 @@ public FrequencyWrap(T item, int frequency)
114114

115115
public int CompareTo(object obj)
116116
{
117-
return Frequency.CompareTo(((FrequencyWrap) obj).Frequency);
117+
return Frequency.CompareTo(((FrequencyWrap)obj).Frequency);
118118
}
119119
}
120120

src/Advanced.Algorithms/DataStructures/Dictionary/Dictionary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Advanced.Algorithms.DataStructures.Foundation
99
/// </summary>
1010
/// <typeparam name="K">The key datatype.</typeparam>
1111
/// <typeparam name="V">The value datatype.</typeparam>
12-
public class Dictionary<K, V> : IEnumerable<KeyValuePair<K, V>>
12+
public class Dictionary<K, V> : IEnumerable<KeyValuePair<K, V>>
1313
{
1414
private readonly IDictionary<K, V> dictionary;
1515

src/Advanced.Algorithms/DataStructures/Dictionary/OpenAddressDictionary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Advanced.Algorithms.DataStructures.Foundation
66
{
7-
internal class OpenAddressDictionary<TK, TV> : IDictionary<TK, TV>
7+
internal class OpenAddressDictionary<TK, TV> : IDictionary<TK, TV>
88
{
99
private DictionaryKeyValuePair<TK, TV>[] hashArray;
1010
private int bucketSize => hashArray.Length;
@@ -368,7 +368,7 @@ internal DictionaryKeyValuePair(K key, V value)
368368
}
369369
}
370370

371-
internal class OpenAddressDictionaryEnumerator<TK, TV> : IEnumerator<KeyValuePair<TK, TV>>
371+
internal class OpenAddressDictionaryEnumerator<TK, TV> : IEnumerator<KeyValuePair<TK, TV>>
372372
{
373373
internal DictionaryKeyValuePair<TK, TV>[] HashArray;
374374

src/Advanced.Algorithms/DataStructures/Dictionary/SeparateChainingDictionary.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Advanced.Algorithms.DataStructures.Foundation
66
{
7-
internal class SeparateChainingDictionary<K, V> : IDictionary<K, V>
7+
internal class SeparateChainingDictionary<K, V> : IDictionary<K, V>
88
{
99
private const double tolerance = 0.1;
1010

@@ -15,7 +15,7 @@ internal class SeparateChainingDictionary<K, V> : IDictionary<K, V>
1515

1616
public int Count { get; private set; }
1717

18-
18+
1919
public SeparateChainingDictionary(int initialBucketSize = 3)
2020
{
2121
this.initialBucketSize = initialBucketSize;
@@ -301,7 +301,7 @@ public IEnumerator<KeyValuePair<K, V>> GetEnumerator()
301301

302302
}
303303

304-
internal class SeparateChainingDictionaryEnumerator<TK, TV> : IEnumerator<KeyValuePair<TK, TV>>
304+
internal class SeparateChainingDictionaryEnumerator<TK, TV> : IEnumerator<KeyValuePair<TK, TV>>
305305
{
306306
internal DoublyLinkedList<KeyValuePair<TK, TV>>[] HashList;
307307

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class WeightedGraph<T, TW> : IGraph<T>, IEnumerable<T> where TW : ICompar
2222
private Dictionary<T, WeightedGraphVertex<T, TW>> vertexObjects;
2323

2424
public int VerticesCount => usedSize;
25-
public bool IsWeightedGraph => true;
25+
public bool IsWeightedGraph => true;
2626

2727
public WeightedGraph()
2828
{
@@ -203,7 +203,7 @@ public bool HasEdge(T source, T dest)
203203
return false;
204204
}
205205

206-
public IEnumerable<KeyValuePair<T,TW>> Edges(T vertex)
206+
public IEnumerable<KeyValuePair<T, TW>> Edges(T vertex)
207207
{
208208
if (!vertexIndices.ContainsKey(vertex))
209209
{
@@ -214,7 +214,7 @@ public IEnumerable<KeyValuePair<T,TW>> Edges(T vertex)
214214

215215
for (int i = 0; i < maxSize; i++)
216216
{
217-
if (!matrix[i,index].Equals(default(TW)))
217+
if (!matrix[i, index].Equals(default(TW)))
218218
{
219219
yield return new KeyValuePair<T, TW>(reverseVertexIndices[i], matrix[i, index]);
220220
}
@@ -302,7 +302,7 @@ private void halfMatrixSize()
302302
{
303303
for (int j = i; j < maxSize; j++)
304304
{
305-
if (!matrix[i, j].Equals(default(TW)) && !matrix[j,i].Equals(default(TW))
305+
if (!matrix[i, j].Equals(default(TW)) && !matrix[j, i].Equals(default(TW))
306306
&& reverseVertexIndices.ContainsKey(i)
307307
&& reverseVertexIndices.ContainsKey(j))
308308
{
@@ -320,7 +320,7 @@ private void halfMatrixSize()
320320
reverseVertexIndices = newReverseIndices;
321321
}
322322

323-
public IEnumerable<IGraphVertex<T>> VerticesAsEnumberable => vertexObjects.Select(x=>x.Value);
323+
public IEnumerable<IGraphVertex<T>> VerticesAsEnumberable => vertexObjects.Select(x => x.Value);
324324

325325
IEnumerator IEnumerable.GetEnumerator()
326326
{

src/Advanced.Algorithms/DataStructures/Graph/IDiGraph.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Advanced.Algorithms.DataStructures.Graph
77
/// Directed graph.
88
/// </summary>
99
/// <typeparam name="T"></typeparam>
10-
public interface IDiGraph<T>
10+
public interface IDiGraph<T>
1111
{
1212
bool IsWeightedGraph { get; }
1313

@@ -19,7 +19,7 @@ public interface IDiGraph<T>
1919

2020
bool HasEdge(T source, T destination);
2121

22-
IDiGraph<T> Clone();
22+
IDiGraph<T> Clone();
2323
}
2424

2525
public interface IDiGraphVertex<T>

src/Advanced.Algorithms/DataStructures/Graph/IGraph.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
63

74
namespace Advanced.Algorithms.DataStructures.Graph
85
{

src/Advanced.Algorithms/DataStructures/HashSet/HashSet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Advanced.Algorithms.DataStructures.Foundation
88
/// A hash table implementation.
99
/// </summary>
1010
/// <typeparam name="T">The value datatype.</typeparam>
11-
public class HashSet<T> : IEnumerable<T>
11+
public class HashSet<T> : IEnumerable<T>
1212
{
1313
private readonly IHashSet<T> hashSet;
1414

src/Advanced.Algorithms/DataStructures/HashSet/OpenAddressHashSet.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
namespace Advanced.Algorithms.DataStructures.Foundation
66
{
7-
internal class OpenAddressHashSet<T> : IHashSet<T>
7+
internal class OpenAddressHashSet<T> : IHashSet<T>
88
{
99
private HashSetNode<T>[] hashArray;
1010
private int bucketSize => hashArray.Length;
1111
private readonly int initialBucketSize;
1212

1313
public int Count { get; private set; }
14-
14+
1515
internal OpenAddressHashSet(int initialBucketSize = 2)
1616
{
1717
this.initialBucketSize = initialBucketSize;
@@ -281,7 +281,7 @@ internal HashSetNode(T value)
281281
}
282282
}
283283

284-
internal class OpenAddressHashSetEnumerator<V> : IEnumerator<V>
284+
internal class OpenAddressHashSetEnumerator<V> : IEnumerator<V>
285285
{
286286
internal HashSetNode<V>[] hashArray;
287287

src/Advanced.Algorithms/DataStructures/HashSet/OrderedHashSet.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public int IndexOf(T key)
8383
/// </summary>
8484
public int Remove(T key)
8585
{
86-
return binarySearchTree.Delete(key);
86+
return binarySearchTree.Delete(key);
8787
}
8888

8989
/// <summary>
@@ -92,7 +92,7 @@ public int Remove(T key)
9292
/// </summary>
9393
public T RemoveAt(int index)
9494
{
95-
return binarySearchTree.RemoveAt(index);
95+
return binarySearchTree.RemoveAt(index);
9696
}
9797

9898
/// <summary>

src/Advanced.Algorithms/DataStructures/HashSet/SeparateChainingHashSet.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Advanced.Algorithms.DataStructures.Foundation
66
{
7-
internal class SeparateChainingHashSet<T> : IHashSet<T>
7+
internal class SeparateChainingHashSet<T> : IHashSet<T>
88
{
99
private const double tolerance = 0.1;
1010
private DoublyLinkedList<HashSetNode<T>>[] hashArray;
@@ -267,7 +267,7 @@ public IEnumerator<T> GetEnumerator()
267267

268268
}
269269

270-
internal class SeparateChainingHashSetEnumerator<T> : IEnumerator<T>
270+
internal class SeparateChainingHashSetEnumerator<T> : IEnumerator<T>
271271
{
272272
internal DoublyLinkedList<HashSetNode<T>>[] hashList;
273273

src/Advanced.Algorithms/DataStructures/Heap/BHeap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private void bulkInitRecursive(int i, T[] initial)
8686
var left = 2 * i + 1;
8787
var right = 2 * i + 2;
8888

89-
var minMax = left < initial.Length && right < initial.Length ?
89+
var minMax = left < initial.Length && right < initial.Length ?
9090
comparer.Compare(initial[left], initial[right]) < 0 ? left : right
9191
: left < initial.Length ? left
9292
: right < initial.Length ? right : -1;

src/Advanced.Algorithms/DataStructures/Heap/FibonacciHeap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void Insert(T newItem)
5252
}
5353

5454
addMapping(newItem, newNode);
55-
55+
5656
Count++;
5757
}
5858

src/Advanced.Algorithms/DataStructures/Heap/Shared/FibornacciHeapNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal FibonacciHeapNode(T value)
2222

2323
public int CompareTo(object obj)
2424
{
25-
return Value.CompareTo(((FibonacciHeapNode<T>) obj).Value);
25+
return Value.CompareTo(((FibonacciHeapNode<T>)obj).Value);
2626
}
2727
}
2828

src/Advanced.Algorithms/DataStructures/Heap/Shared/PairingHeapNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal PairingHeapNode(T value)
1919

2020
public int CompareTo(object obj)
2121
{
22-
return Value.CompareTo(((PairingHeapNode<T>) obj).Value);
22+
return Value.CompareTo(((PairingHeapNode<T>)obj).Value);
2323
}
2424
}
2525

src/Advanced.Algorithms/DataStructures/Heap/d-aryHeap.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
2-
using System.Linq;
3-
using System.Collections.Generic;
42
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Linq;
55

66
namespace Advanced.Algorithms.DataStructures
77
{
@@ -48,7 +48,7 @@ public DaryHeap(int k, SortDirection sortDirection = SortDirection.Ascending, IE
4848

4949
Count = initArray.Length;
5050
bulkInit(initArray);
51-
51+
5252
}
5353
else
5454
{
@@ -152,7 +152,7 @@ public T Extract()
152152
//init to left-most child
153153
var minMaxChildIndex = findMinMaxChildIndex(currentParent, heapArray);
154154

155-
if (minMaxChildIndex!=-1 &&
155+
if (minMaxChildIndex != -1 &&
156156
comparer.Compare(heapArray[currentParent], heapArray[minMaxChildIndex]) > 0)
157157
{
158158
var tmp = heapArray[minMaxChildIndex];
@@ -245,7 +245,7 @@ private void doubleArray()
245245
IEnumerator IEnumerable.GetEnumerator()
246246
{
247247
return GetEnumerator();
248-
248+
249249
}
250250

251251
public IEnumerator<T> GetEnumerator()

src/Advanced.Algorithms/DataStructures/LinkedList/DoublyLinkedList.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Advanced.Algorithms.DataStructures
77
/// <summary>
88
/// A doubly linked list implementation.
99
/// </summary>
10-
public class DoublyLinkedList<T> :IEnumerable<T>
10+
public class DoublyLinkedList<T> : IEnumerable<T>
1111
{
1212
public DoublyLinkedListNode<T> Head;
1313
public DoublyLinkedListNode<T> Tail;
@@ -38,7 +38,7 @@ public DoublyLinkedListNode<T> InsertFirst(T data)
3838
return newNode;
3939
}
4040

41-
internal void InsertFirst(DoublyLinkedListNode<T> newNode)
41+
internal void InsertFirst(DoublyLinkedListNode<T> newNode)
4242
{
4343
if (Head != null)
4444
{
@@ -337,7 +337,7 @@ internal void Union(DoublyLinkedList<T> newList)
337337
newList.Tail.Next = Head;
338338

339339
Head = newList.Head;
340-
340+
341341

342342
}
343343

@@ -387,7 +387,7 @@ public DoublyLinkedListNode(T data)
387387
}
388388
}
389389

390-
internal class DoublyLinkedListEnumerator<T> : IEnumerator<T>
390+
internal class DoublyLinkedListEnumerator<T> : IEnumerator<T>
391391
{
392392
internal DoublyLinkedListNode<T> headNode;
393393
internal DoublyLinkedListNode<T> currentNode;

0 commit comments

Comments
 (0)