add unicode figure
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="CapacityFixedList"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
// 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
|
||||
@@ -47,11 +47,13 @@ namespace StgSharp.Collections
|
||||
{
|
||||
|
||||
private T[] _values;
|
||||
private int capacity, _index;
|
||||
private readonly int _capacity;
|
||||
private int _index;
|
||||
|
||||
public CapacityFixedList(int size)
|
||||
{
|
||||
_values = new T[size];
|
||||
_capacity = size;
|
||||
}
|
||||
|
||||
public CapacityFixedList(ReadOnlySpan<T> values)
|
||||
@@ -62,16 +64,7 @@ namespace StgSharp.Collections
|
||||
public T this[int index]
|
||||
{
|
||||
get => index < _index ? _values[index] : throw new ArgumentOutOfRangeException(nameof(index));
|
||||
set
|
||||
{
|
||||
if (index < _index)
|
||||
{
|
||||
_values[index] = value;
|
||||
} else
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
}
|
||||
set => _values[index] = index < _index ? value : throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
public bool IsReadOnly => false;
|
||||
@@ -80,7 +73,7 @@ namespace StgSharp.Collections
|
||||
|
||||
public void Add(T item)
|
||||
{
|
||||
if (_index < capacity - 1)
|
||||
if (_index < _capacity - 1)
|
||||
{
|
||||
_index++;
|
||||
this[_index] = item;
|
||||
@@ -89,7 +82,7 @@ namespace StgSharp.Collections
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_values = new T[capacity];
|
||||
_values = new T[_capacity];
|
||||
_index = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// file="CapacityFixedStack"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
// 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
|
||||
@@ -57,7 +57,11 @@ namespace StgSharp.Collections
|
||||
|
||||
public int Capacity => _values.Length;
|
||||
|
||||
public ReadOnlySpan<T> AsSpan() => _values.AsSpan(0, _index);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ReadOnlySpan<T> AsSpan()
|
||||
{
|
||||
return _values.AsSpan(0, _index);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="NotEnumerableList"
|
||||
// file="NotEnumerableList.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
// 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.
|
||||
// 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.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -113,7 +116,10 @@ namespace StgSharp.Collections
|
||||
/// Returns a span over the live portion of the bag (0..Count-1).
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Span<T> AsSpan() => new Span<T>(_items, 0, Count);
|
||||
public Span<T> AsSpan()
|
||||
{
|
||||
return new Span<T>(_items, 0, Count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all elements and zeroes out references to avoid retention. Count becomes 0.
|
||||
@@ -130,7 +136,10 @@ namespace StgSharp.Collections
|
||||
/// released. Use only when you are certain old references can remain.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void FastClear() => Count = 0;
|
||||
public void FastClear()
|
||||
{
|
||||
Count = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of value (unordered). Does nothing if not found.
|
||||
|
||||
+13
-24
@@ -2,8 +2,8 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// file="Counter"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
// 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
|
||||
@@ -30,7 +30,7 @@ using System.Numerics;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public class Counter<T> where T : unmanaged, INumber<T>
|
||||
public class Counter<T> where T: unmanaged, INumber<T>
|
||||
{
|
||||
|
||||
internal dynamic _value;
|
||||
@@ -39,11 +39,7 @@ namespace StgSharp
|
||||
internal readonly T _defaultIncrement;
|
||||
internal readonly T _defaultValue;
|
||||
|
||||
public Counter(
|
||||
T defaultValue,
|
||||
T defaultIncrement,
|
||||
T defaultDecrement
|
||||
)
|
||||
public Counter(T defaultValue, T defaultIncrement, T defaultDecrement)
|
||||
{
|
||||
_value = defaultValue;
|
||||
_defaultValue = defaultValue;
|
||||
@@ -63,9 +59,7 @@ namespace StgSharp
|
||||
set => _value = value;
|
||||
}
|
||||
|
||||
public void Add(
|
||||
T value
|
||||
)
|
||||
public void Add(T value)
|
||||
{
|
||||
_value += value;
|
||||
}
|
||||
@@ -85,34 +79,29 @@ namespace StgSharp
|
||||
_value = _defaultValue;
|
||||
}
|
||||
|
||||
public void Sub(
|
||||
T value
|
||||
)
|
||||
public void Sub(T value)
|
||||
{
|
||||
_value -= value;
|
||||
}
|
||||
|
||||
public override string ToString() => Value.ToString();
|
||||
public override string ToString()
|
||||
{
|
||||
return Value.ToString() ?? string.Empty;
|
||||
}
|
||||
|
||||
public static Counter<T> operator --(
|
||||
Counter<T> counter
|
||||
)
|
||||
public static Counter<T> operator --(Counter<T> counter)
|
||||
{
|
||||
counter?.QuickSub();
|
||||
return counter;
|
||||
}
|
||||
|
||||
public static Counter<T> operator ++(
|
||||
Counter<T> counter
|
||||
)
|
||||
public static Counter<T> operator ++(Counter<T> counter)
|
||||
{
|
||||
counter?.QuickAdd();
|
||||
return counter;
|
||||
}
|
||||
|
||||
public static implicit operator T(
|
||||
Counter<T> counter
|
||||
)
|
||||
public static implicit operator T(Counter<T> counter)
|
||||
{
|
||||
return counter switch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user