Skip to content

Commit

Permalink
Merge pull request #21 from meokullu/new_version_0001
Browse files Browse the repository at this point in the history
v1.0.0-alpha-7 array of generic data type and parallelism.
  • Loading branch information
meokullu committed Apr 11, 2024
2 parents 6baae9b + c6e6852 commit 5d95170
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,5 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd
/desktop.ini
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
#### Removed
-->

### [1.0.0-alpha.7]
#### Added
* `ApplyScale<T>(T[] array, int width, int height, int customScale)` method is added.
* `AppleScale<T>(T[] array, int width, int height, int customScale, ParallelOptions parallelOptions)` method is added.

### [1.0.0-alpha.6]
#### Changed
* Fixing a bug on calculation of offset value on `GetCustomScaleIndex(int index, int width, int height, int customScale)` method.
Expand Down Expand Up @@ -48,4 +53,4 @@
* Icons are added for package and file.

### [1.0.0-alpha]
* Initial release.
* Initial release.
73 changes: 70 additions & 3 deletions GetScaleIndex/GetScaleIndex.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;

namespace GetScaleIndex
{
Expand Down Expand Up @@ -300,7 +300,7 @@ public static int[] GetCustomScalingIndex(int index, int width, int height, int
}

//
int offset = (index / width * (customScale * (customScale - 1)) * height) + (index * customScale);
int offset = (index / width * customScale * (customScale - 1) * height) + (index * customScale);

//
int[] scaledList = new int[customScale * customScale];
Expand Down Expand Up @@ -360,7 +360,7 @@ public static List<T> ApplyScale<T>(List<T> list, int width, int height, int cus
int[] scalingIndexList = GetCustomScalingIndex(index: i, width: width, height: height, customScale: customScale);

//
foreach (var item in scalingIndexList)
foreach (int item in scalingIndexList)
{
//
result[item] = list[i];
Expand All @@ -370,5 +370,72 @@ public static List<T> ApplyScale<T>(List<T> list, int width, int height, int cus
// Returning result
return result;
}

/// <summary>
/// Experimental method. [Do not use!]
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="customScale"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public static T[] ApplyScale<T>(T[] array, int width, int height, int customScale)
{
//
T[] result = new T[array.Length * customScale * customScale];

//
for (int i = 0; i < array.Length; i++)
{
//
int[] scalingIndexList = GetCustomScalingIndex(index: i, width: width, height: height, customScale: customScale);

//
for(int j = 0; j < scalingIndexList.Length; j++)
{
//
result[scalingIndexList[j]] = array[i];
}
}

//
return result;
}

/// <summary>
/// Experimental method. [Do not use!]
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="customScale"></param>
/// <param name="parallelOptions"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public static T[] ApplyScale<T>(T[] array, int width, int height, int customScale, ParallelOptions parallelOptions)
{
//
T[] result = new T[array.Length * customScale * customScale];

_ = Parallel.For(0, array.Length, parallelOptions: parallelOptions, x =>
{
//
int[] scalingIndexList = GetCustomScalingIndex(index: x, width: width, height: height, customScale: customScale);
//
for (int j = 0; j < scalingIndexList.Length; j++)
{
//
result[scalingIndexList[j]] = array[x];
}
});

//
return result;
}
}
}
}
11 changes: 5 additions & 6 deletions GetScaleIndex/GetScaleIndex.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@
<SignAssembly>False</SignAssembly>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>Get Scale Index</Title>
<Version>1.0.0-alpha.6</Version>
<Version>1.0.0-alpha.7</Version>
<Company>Enes Okullu</Company>
<Description>GetScaleIndex, integer based index finder for scaling.</Description>
<Copyright>Enes Okullu</Copyright>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes>
v1.0.0-alpha.6
* `ApplyScale&lt;T&gt;(List&lt;T&gt;list, int width, int height, int customScale)` method is added for generic list of generic data type.
* `width` and `height` values should be same for `ApplyScale&lt;T&gt;()` and `GetCustomScalingIndex()` methods. Temporarily value checking is added.
* `GetIndexFor4x(int index)` renamed as `GetScalingIndexFor4x(int index)`
* Variables renamed to enhance readability.
v1.0.0-alpha.7
* `ApplyScale&lt;T&gt;(T[] array, int width, int height, int customScale)` method is added for generic type array of generic data type.
* `ApplyScale&lt;T&gt;(T[] array, int width, int height, int customScale, ParallelOptions parallelOptions)` method is added for generic type array of generic data type with parallelism.

See changelog (https://github.com/meokullu/GetScaleIndex/blob/master/CHANGELOG.md)
</PackageReleaseNotes>
<AssemblyVersion>1.0.0</AssemblyVersion>
Expand Down

0 comments on commit 5d95170

Please sign in to comment.