daily update on 2024.03.18 by itload youmu
This commit is contained in:
@@ -1,4 +1,34 @@
|
||||
using StgSharp.Graphics;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ArrayList.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Graphics;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
@@ -14,6 +44,7 @@ namespace StgSharp.Logic
|
||||
[StructLayout(LayoutKind.Explicit, Size = 8)]
|
||||
internal struct LogSeperator
|
||||
{
|
||||
|
||||
[FieldOffset(0)] public ulong all;
|
||||
[FieldOffset(0)] public long all_s;
|
||||
|
||||
@@ -28,6 +59,7 @@ namespace StgSharp.Logic
|
||||
this.high = high;
|
||||
this.low = low;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -38,6 +70,7 @@ namespace StgSharp.Logic
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class DynamicArrayList<T>
|
||||
{
|
||||
|
||||
private List<T[]> arrayIndexList;
|
||||
private LogSeperator indexpair;
|
||||
private int lastMain = 0;
|
||||
@@ -139,10 +172,10 @@ namespace StgSharp.Logic
|
||||
{
|
||||
indexpair.all_s = index;
|
||||
if (
|
||||
indexpair.low_s > lastSub ||
|
||||
indexpair.high_s > lastMain ||
|
||||
indexpair.low_s < 0 ||
|
||||
indexpair.high_s < 0)
|
||||
(indexpair.low_s > lastSub) ||
|
||||
(indexpair.high_s > lastMain) ||
|
||||
(indexpair.low_s < 0) ||
|
||||
(indexpair.high_s < 0))
|
||||
{
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
@@ -152,10 +185,10 @@ namespace StgSharp.Logic
|
||||
{
|
||||
indexpair.all_s = index;
|
||||
if (
|
||||
indexpair.low_s > lastSub ||
|
||||
indexpair.high_s > lastMain ||
|
||||
indexpair.low_s < 0 ||
|
||||
indexpair.high_s < 0)
|
||||
(indexpair.low_s > lastSub) ||
|
||||
(indexpair.high_s > lastMain) ||
|
||||
(indexpair.low_s < 0) ||
|
||||
(indexpair.high_s < 0))
|
||||
{
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
@@ -163,30 +196,11 @@ namespace StgSharp.Logic
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyTo(DynamicArrayList<T> target)
|
||||
{
|
||||
target.arrayIndexList.Clear();
|
||||
int length = 1;
|
||||
foreach (T[] tList in target.arrayIndexList)
|
||||
{
|
||||
T[] newIndex = new T[length];
|
||||
Buffer.BlockCopy(tList, 0, newIndex, 0, length);
|
||||
target.arrayIndexList.Add(newIndex);
|
||||
length <<= 1;
|
||||
}
|
||||
|
||||
target.lastMain = lastMain;
|
||||
target.lastSub = lastSub;
|
||||
target.length = length;
|
||||
target.unusedMainIndex = new Queue<int>(unusedMainIndex.ToArray());
|
||||
target.unusedSubIndex = new Queue<int>(unusedSubIndex.ToArray());
|
||||
}
|
||||
|
||||
public T this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index + 1 > length || index < 0)
|
||||
if ((index + 1 > length) || (index < 0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
}
|
||||
@@ -195,7 +209,7 @@ namespace StgSharp.Logic
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index + 1 > length || index < 0)
|
||||
if ((index + 1 > length) || (index < 0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
}
|
||||
@@ -208,7 +222,7 @@ namespace StgSharp.Logic
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index + 1 > length || index < 0)
|
||||
if ((index + 1 > length) || (index < 0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
}
|
||||
@@ -217,7 +231,7 @@ namespace StgSharp.Logic
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index + 1 > length || index < 0)
|
||||
if ((index + 1 > length) || (index < 0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
}
|
||||
@@ -231,10 +245,7 @@ namespace StgSharp.Logic
|
||||
/// <summary>
|
||||
/// Length of this <see cref="DynamicArrayList{T}"/>
|
||||
/// </summary>
|
||||
public int Length
|
||||
{
|
||||
get { return length; }
|
||||
}
|
||||
public int Length => length;
|
||||
|
||||
public int Add(T item)
|
||||
{
|
||||
@@ -297,6 +308,25 @@ namespace StgSharp.Logic
|
||||
return false;
|
||||
}
|
||||
|
||||
public void CopyTo(DynamicArrayList<T> target)
|
||||
{
|
||||
target.arrayIndexList.Clear();
|
||||
int length = 1;
|
||||
foreach (T[] tList in target.arrayIndexList)
|
||||
{
|
||||
T[] newIndex = new T[length];
|
||||
Buffer.BlockCopy(tList, 0, newIndex, 0, length);
|
||||
target.arrayIndexList.Add(newIndex);
|
||||
length <<= 1;
|
||||
}
|
||||
|
||||
target.lastMain = lastMain;
|
||||
target.lastSub = lastSub;
|
||||
target.length = length;
|
||||
target.unusedMainIndex = new Queue<int>(unusedMainIndex.ToArray());
|
||||
target.unusedSubIndex = new Queue<int>(unusedSubIndex.ToArray());
|
||||
}
|
||||
|
||||
public int IndexOf(T item)
|
||||
{
|
||||
int index = 1;
|
||||
@@ -307,7 +337,7 @@ namespace StgSharp.Logic
|
||||
{
|
||||
if (i.Equals(item))
|
||||
{
|
||||
return index + subindex - 1;
|
||||
return (index + subindex) - 1;
|
||||
}
|
||||
subindex++;
|
||||
}
|
||||
@@ -328,11 +358,11 @@ namespace StgSharp.Logic
|
||||
if (i.Equals(item))
|
||||
{
|
||||
list[subindex] = default;
|
||||
if (subindex == lastSub && index == lastMain)
|
||||
if ((subindex == lastSub) && (index == lastMain))
|
||||
{
|
||||
if (lastSub == 0)
|
||||
{
|
||||
lastMain = lastMain == 0 ? 0 : lastMain - 1;
|
||||
lastMain = (lastMain == 0) ? 0 : (lastMain - 1);
|
||||
lastSub = arrayIndexList[lastMain].Length - 1;
|
||||
}
|
||||
else
|
||||
@@ -356,7 +386,7 @@ namespace StgSharp.Logic
|
||||
[Obsolete("This method is not same, you may read data form an empty index.", false)]
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
if (index > length || index < 0)
|
||||
if ((index > length) || (index < 0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
@@ -402,7 +432,7 @@ namespace StgSharp.Logic
|
||||
mainindex++;
|
||||
}
|
||||
indexpair.high_s = mainindex;
|
||||
indexpair.low >>= (int)(32 - mainindex);
|
||||
indexpair.low >>= 32 - mainindex;
|
||||
}
|
||||
|
||||
private void SeprateIndex(int longIndex)
|
||||
@@ -415,7 +445,8 @@ namespace StgSharp.Logic
|
||||
mainindex++;
|
||||
}
|
||||
indexpair.high_s = mainindex;
|
||||
indexpair.low >>= (int)(32 - mainindex);
|
||||
indexpair.low >>= 32 - mainindex;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user