Refactoring

pull/1/head
unknown 4 years ago
parent 9a7b90a061
commit b4f29e8d6f

@ -86,5 +86,33 @@ namespace ZeroLevel.CollectionUnitTests
Assert.True(fix.Count == 2);
Assert.True(CollectionComparsionExtensions.OrderingEquals(fix.Dump().ToArray(), new long[] { 4, 5 }));
}
[Fact]
public void ChunkifyTest()
{
// Arrange
var arr = new long[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
var empty_arr = new long[0];
// Act
var empty_chunks = empty_arr.Chunkify(3).ToArray();
var chunks_2 = arr.Chunkify(2).ToArray();
var chunks_3 = arr.Chunkify(3).ToArray();
// Assert
Assert.True(empty_chunks.Length == 0);
Assert.True(chunks_2.Length == 5);
Assert.True(chunks_3.Length == 3);
Assert.True(CollectionComparsionExtensions.OrderingEquals(chunks_3[0], new long[] { 1, 2, 3 }));
Assert.True(CollectionComparsionExtensions.OrderingEquals(chunks_3[1], new long[] { 4, 5, 6 }));
Assert.True(CollectionComparsionExtensions.OrderingEquals(chunks_3[2], new long[] { 7, 8, 9 }));
Assert.True(CollectionComparsionExtensions.OrderingEquals(chunks_2[0], new long[] { 1, 2 }));
Assert.True(CollectionComparsionExtensions.OrderingEquals(chunks_2[1], new long[] { 3, 4 }));
Assert.True(CollectionComparsionExtensions.OrderingEquals(chunks_2[2], new long[] { 5, 6 }));
Assert.True(CollectionComparsionExtensions.OrderingEquals(chunks_2[3], new long[] { 7, 8 }));
Assert.True(CollectionComparsionExtensions.OrderingEquals(chunks_2[4], new long[] { 9 }));
}
}
}

@ -15,8 +15,6 @@ namespace ZeroLevel.DataStructures
private double[] values;
private double power;
public SparceVector()
{
indexes = EmptyIndexes;

@ -71,10 +71,24 @@ namespace System.Linq
{
throw new ArgumentException("chunkSize must be greater than 0.");
}
while (source.Any())
T[] arr = new T[size];
int index = 0;
foreach (var obj in source)
{
yield return source.Take(size);
source = source.Skip(size);
arr[index] = obj;
index++;
if (index >= size)
{
yield return arr;
index = 0;
arr = new T[size];
}
}
if (index > 0)
{
var narr = new T[index];
Array.Copy(arr, narr, index);
yield return narr;
}
}
}

@ -89,7 +89,7 @@ namespace ZeroLevel.Services.FileSystem
/// <summary>
/// Moving a file to a temporary directory
/// </summary>
public string MoveToTemporary(string from)
private string MoveToTemporary(string from)
{
if (from == null)
{
@ -139,7 +139,7 @@ namespace ZeroLevel.Services.FileSystem
/// <summary>
/// Getting a list of files from the input directory
/// </summary>
public string[] GetFilesFromSource()
private string[] GetFilesFromSource()
{
string[] files = Directory.GetFiles(_sourceFolder, "*.*", SearchOption.TopDirectoryOnly);
Array.Sort<string>(files, FileNameSortCompare);

@ -26,12 +26,12 @@ namespace ZeroLevel.Network
/// <summary>
/// If during the specified period there was no network activity, send a ping-request
/// </summary>
internal const long HEARTBEAT_PING_PERIOD_TICKS = 1500 * TimeSpan.TicksPerMillisecond;
internal const long HEARTBEAT_PING_PERIOD_TICKS = 3000 * TimeSpan.TicksPerMillisecond;
/// <summary>
/// Connection check period
/// </summary>
internal const int MINIMUM_HEARTBEAT_UPDATE_PERIOD_MS = 7500;
internal const int MINIMUM_HEARTBEAT_UPDATE_PERIOD_MS = 15000;
/// <summary>
/// The period of the request, after which it is considered unsuccessful

@ -6,7 +6,7 @@
</Description>
<Authors>ogoun</Authors>
<Company>ogoun</Company>
<AssemblyVersion>3.3.4.0</AssemblyVersion>
<AssemblyVersion>3.3.4.2</AssemblyVersion>
<PackageReleaseNotes>Refactoring</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/ogoun/Zero/wiki</PackageProjectUrl>
<Copyright>Copyright Ogoun 2020</Copyright>
@ -14,8 +14,8 @@
<PackageIconUrl></PackageIconUrl>
<RepositoryUrl>https://github.com/ogoun/Zero</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<Version>3.3.4</Version>
<FileVersion>3.3.4.1</FileVersion>
<Version>3.3.4.2</Version>
<FileVersion>3.3.4.2</FileVersion>
<Platforms>AnyCPU;x64</Platforms>
<PackageIcon>zero.png</PackageIcon>
</PropertyGroup>

Loading…
Cancel
Save

Powered by TurnKey Linux.