Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Algorithms/Crypto/Digests/AsconDigest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Runtime.CompilerServices;
using Algorithms.Crypto.Utils;

Expand Down
2 changes: 0 additions & 2 deletions Algorithms/Crypto/Digests/IDigest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Algorithms.Crypto.Digests;

/// <summary>
Expand Down
4 changes: 1 addition & 3 deletions Algorithms/Crypto/Digests/Md2Digest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Algorithms.Crypto.Digests;
namespace Algorithms.Crypto.Digests;

/// <summary>
/// MD2 is a cryptographic hash function that takes an input message and produces a 128-bit output, also called a message
Expand Down
2 changes: 0 additions & 2 deletions Algorithms/Crypto/Exceptions/CryptoException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Algorithms.Crypto.Exceptions;

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions Algorithms/Crypto/Exceptions/DataLengthException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Algorithms.Crypto.Exceptions;

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions Algorithms/Crypto/Exceptions/OutputLengthException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Algorithms.Crypto.Exceptions;

/// <summary>
Expand Down
4 changes: 1 addition & 3 deletions Algorithms/Crypto/Paddings/IBlockCipherPadding.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Algorithms.Crypto.Paddings;
namespace Algorithms.Crypto.Paddings;

/// <summary>
/// A common interface that all block cipher padding schemes should follow.
Expand Down
5 changes: 1 addition & 4 deletions Algorithms/Crypto/Paddings/Iso10126D2Padding.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Security.Cryptography;

namespace Algorithms.Crypto.Paddings;
namespace Algorithms.Crypto.Paddings;

/// <summary>
/// <para>
Expand Down
4 changes: 1 addition & 3 deletions Algorithms/Crypto/Paddings/Iso7816D4Padding.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Algorithms.Crypto.Paddings;
namespace Algorithms.Crypto.Paddings;

/// <summary>
/// <para>
Expand Down
4 changes: 1 addition & 3 deletions Algorithms/Crypto/Paddings/Pkcs7Padding.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Algorithms.Crypto.Paddings;
namespace Algorithms.Crypto.Paddings;

/// <summary>
/// <para>
Expand Down
4 changes: 1 addition & 3 deletions Algorithms/Crypto/Paddings/TbcPadding.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Algorithms.Crypto.Paddings;
namespace Algorithms.Crypto.Paddings;

/// <summary>
/// <para>
Expand Down
5 changes: 1 addition & 4 deletions Algorithms/Crypto/Paddings/X932Padding.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Security.Cryptography;

namespace Algorithms.Crypto.Paddings;
namespace Algorithms.Crypto.Paddings;

/// <summary>
/// <para>
Expand Down
1 change: 0 additions & 1 deletion Algorithms/Crypto/Utils/ByteEncodingUtils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Buffers.Binary;
using System.Runtime.CompilerServices;

Expand Down
2 changes: 0 additions & 2 deletions Algorithms/Crypto/Utils/LongUtils.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Numerics;

namespace Algorithms.Crypto.Utils;

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions Algorithms/Crypto/Utils/ValidationUtils.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Diagnostics;
using Algorithms.Crypto.Exceptions;

namespace Algorithms.Crypto.Utils;
Expand Down
3 changes: 0 additions & 3 deletions Algorithms/DataCompression/BurrowsWheelerTransform.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Linq;

namespace Algorithms.DataCompression;

/// <summary>
Expand Down
4 changes: 0 additions & 4 deletions Algorithms/DataCompression/HuffmanCompressor.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Algorithms.Sorters.Comparison;
using Utilities.Extensions;

namespace Algorithms.DataCompression;

Expand Down
3 changes: 0 additions & 3 deletions Algorithms/DataCompression/ShannonFanoCompressor.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using Algorithms.Knapsack;
using Utilities.Extensions;

namespace Algorithms.DataCompression;

Expand Down
3 changes: 0 additions & 3 deletions Algorithms/DataCompression/Translator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System.Collections.Generic;
using System.Text;

namespace Algorithms.DataCompression;

/// <summary>
Expand Down
9 changes: 2 additions & 7 deletions Algorithms/Encoders/AutokeyEncorder.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
using System;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;

namespace Algorithms.Encoders
{
/// <summary>
Expand All @@ -27,7 +22,7 @@ public string Encode(string plainText, string keyword)

StringBuilder cipherText = new StringBuilder();

for(int i = 0; i < plainText.Length; i++)
for (int i = 0; i < plainText.Length; i++)
{
char plainCharacter = plainText[i];
char keyCharacter = keyword[i];
Expand All @@ -53,7 +48,7 @@ public string Decode(string cipherText, string keyword)
StringBuilder plainText = new StringBuilder();
StringBuilder extendedKeyword = new StringBuilder(keyword);

for(int i = 0; i < cipherText.Length; i++)
for (int i = 0; i < cipherText.Length; i++)
{
char cipherCharacter = cipherText[i];
char keywordCharacter = extendedKeyword[i];
Expand Down
6 changes: 1 addition & 5 deletions Algorithms/Encoders/BlowfishEncoder.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Linq;
using System.Text;

namespace Algorithms.Encoders;
namespace Algorithms.Encoders;

/// <summary>
/// <para>
Expand Down
2 changes: 0 additions & 2 deletions Algorithms/Encoders/CaesarEncoder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Text;

namespace Algorithms.Encoders;

/// <summary>
Expand Down
10 changes: 3 additions & 7 deletions Algorithms/Encoders/FeistelCipher.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Algorithms.Encoders;

/// <summary>
Expand Down Expand Up @@ -101,7 +97,7 @@ public string Decode(string text, uint key)
ulong decodedBlock = leftSubblock;
decodedBlock = (decodedBlock << 32) | rightSubblock;

for(int i = 0; i < 8; i++)
for (int i = 0; i < 8; i++)
{
ulong a = (decodedBlock & 0xFF00000000000000) >> 56;

Expand All @@ -125,7 +121,7 @@ private static List<ulong> SplitTextToBlocks(string text)
List<ulong> blocksListPlain = new();
byte[] textArray = Encoding.ASCII.GetBytes(text);
int offset = 8;
for(int i = 0; i < text.Length; i += 8)
for (int i = 0; i < text.Length; i += 8)
{
// text not always has len%16 == 0, that's why the offset should be adjusted for the last part of the text
if (i > text.Length - 8)
Expand All @@ -144,7 +140,7 @@ private static List<ulong> SplitTextToBlocks(string text)
private static List<ulong> GetBlocksFromEncodedText(string text)
{
List<ulong> blocksListPlain = new();
for(int i = 0; i < text.Length; i += 16)
for (int i = 0; i < text.Length; i += 16)
{
ulong block = Convert.ToUInt64(text.Substring(i, 16), 16);
blocksListPlain.Add(block);
Expand Down
2 changes: 0 additions & 2 deletions Algorithms/Encoders/HillEncoder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Linq;
using Algorithms.Numeric;

namespace Algorithms.Encoders;
Expand Down
4 changes: 0 additions & 4 deletions Algorithms/Encoders/NysiisEncoder.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System.Globalization;
using System.Linq;
using System.Text;

namespace Algorithms.Encoders;

/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions Algorithms/Encoders/SoundexEncoder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System.Collections.Generic;
using System.Linq;

namespace Algorithms.Encoders;

/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions Algorithms/Encoders/VigenereEncoder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Text;

namespace Algorithms.Encoders;

/// <summary>
Expand Down
4 changes: 0 additions & 4 deletions Algorithms/Financial/PresentValue.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace Algorithms.Financial;

/// <summary>
Expand Down
21 changes: 21 additions & 0 deletions Algorithms/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// -----------------------------------------------------------------------------
// Global using directives for the C-Sharp solution.
// These namespaces are imported globally so they don’t need to be repeatedly declared
// in individual files, improving readability and reducing boilerplate.
//
// Guidelines:
// - Keep only the most commonly used namespaces here.
// - Add project-specific namespaces (e.g., Utilities.Extensions) only if they are
// required across the majority of files in the project.
// - Avoid placing rarely used namespaces here to maintain clarity.
// -----------------------------------------------------------------------------

global using System; // Core base classes and fundamental types
global using System.Collections.Generic; // Generic collection types (List, Dictionary, etc.)
global using System.Globalization; // Culture-related information (dates, numbers, formatting)
global using System.Linq; // LINQ query operators for collections
global using System.Numerics; // Numeric types such as BigInteger and Complex
global using System.Security.Cryptography; // Cryptographic services (hashing, encryption, random numbers)
global using System.Text; // Text encoding, StringBuilder, etc.
global using System.Text.RegularExpressions; // Regular expression support
global using Utilities.Extensions; // Common extension methods used across the solution
2 changes: 0 additions & 2 deletions Algorithms/Graph/BellmanFord.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using DataStructures.Graph;

namespace Algorithms.Graph;
Expand Down
2 changes: 0 additions & 2 deletions Algorithms/Graph/BreadthFirstSearch.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using DataStructures.Graph;

namespace Algorithms.Graph;
Expand Down
2 changes: 0 additions & 2 deletions Algorithms/Graph/BreadthFirstTreeTraversal.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using DataStructures.BinarySearchTree;

namespace Algorithms.Graph;
Expand Down
2 changes: 0 additions & 2 deletions Algorithms/Graph/DepthFirstSearch.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using DataStructures.Graph;

namespace Algorithms.Graph;
Expand Down
5 changes: 1 addition & 4 deletions Algorithms/Graph/Dijkstra/DijkstraAlgorithm.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DataStructures.Graph;

namespace Algorithms.Graph.Dijkstra;
Expand Down Expand Up @@ -31,7 +28,7 @@ public static DistanceModel<T>[] GenerateShortestPath<T>(DirectedWeightedGraph<T

while (visitedVertices.Count != distanceArray.Length && distanceRecord.Count != 0)
{
while(visitedVertices.Contains(distanceRecord.Peek().Vertex!))
while (visitedVertices.Contains(distanceRecord.Peek().Vertex!))
{
distanceRecord.Dequeue();
}
Expand Down
1 change: 0 additions & 1 deletion Algorithms/Graph/FloydWarshall.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using DataStructures.Graph;

namespace Algorithms.Graph;
Expand Down
1 change: 0 additions & 1 deletion Algorithms/Graph/IGraphSearch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using DataStructures.Graph;

namespace Algorithms.Graph;
Expand Down
2 changes: 0 additions & 2 deletions Algorithms/Graph/Kosaraju.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections.Generic;
using System.Linq;
using DataStructures.Graph;

namespace Algorithms.Graph;
Expand Down
4 changes: 1 addition & 3 deletions Algorithms/Graph/MinimumSpanningTree/Kruskal.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using DataStructures.DisjointSet;

namespace Algorithms.Graph.MinimumSpanningTree;
Expand Down Expand Up @@ -97,7 +95,7 @@ public static Dictionary<int, float>[] Solve(Dictionary<int, float>[] adjacencyL
{
nodes[i] = set.MakeSet(i);

foreach(var (node, weight) in adjacencyList[i])
foreach (var (node, weight) in adjacencyList[i])
{
edgeWeightList.Add(weight);
nodeConnectList.Add((i, node));
Expand Down
2 changes: 0 additions & 2 deletions Algorithms/Graph/MinimumSpanningTree/PrimMatrix.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Algorithms.Graph.MinimumSpanningTree;

/// <summary>
Expand Down
6 changes: 1 addition & 5 deletions Algorithms/Knapsack/BranchAndBoundKnapsackSolver.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace Algorithms.Knapsack;

/// <summary>
Expand Down Expand Up @@ -111,7 +107,7 @@ private static T[] GetItemsFromPath(T[] items, BranchAndBoundNode lastNodeOfPath
// only bogus initial node has no parent
for (var current = lastNodeOfPath; current.Parent is not null; current = current.Parent)
{
if(current.IsTaken)
if (current.IsTaken)
{
takenItems.Add(items[current.Level]);
}
Expand Down
3 changes: 0 additions & 3 deletions Algorithms/Knapsack/DynamicProgrammingKnapsackSolver.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;

namespace Algorithms.Knapsack;

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions Algorithms/Knapsack/IHeuristicKnapsackSolver.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Algorithms.Knapsack;

/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions Algorithms/Knapsack/NaiveKnapsackSolver.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;

namespace Algorithms.Knapsack;

/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions Algorithms/LinearAlgebra/Distances/Chebyshev.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Linq;

namespace Algorithms.LinearAlgebra.Distances;

/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions Algorithms/LinearAlgebra/Distances/Euclidean.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Linq;

namespace Algorithms.LinearAlgebra.Distances;

/// <summary>
Expand Down
Loading