daily update on 20240206 by nitload youmu, token parser change to use regex generator

This commit is contained in:
Nitload
2025-02-06 07:45:06 +08:00
parent 4e5a1b0dfb
commit 7d0470d50b
104 changed files with 2752 additions and 3134 deletions
@@ -38,28 +38,26 @@ namespace StgSharp.Commom.Collections
{
internal class CapacityFixedList<T> : IList<T>
{
private T[] values;
private int capacity, _index;
public CapacityFixedList(int size)
public CapacityFixedList( int size )
{
values = new T[size];
}
public T this[int index]
public T this[ int index ]
{
get => index < _index ?
values[index] : throw new ArgumentOutOfRangeException(
nameof(index));
values[ index ] : throw new ArgumentOutOfRangeException(
nameof( index ) );
set
{
if (index < _index)
{
values[index] = value;
}
else
{
throw new ArgumentOutOfRangeException(nameof(index));
if( index < _index ) {
values[ index ] = value;
} else {
throw new ArgumentOutOfRangeException( nameof( index ) );
}
}
}
@@ -68,12 +66,11 @@ namespace StgSharp.Commom.Collections
public int Count => _index + 1;
public void Add(T item)
public void Add( T item )
{
if (_index < capacity - 1)
{
if( _index < capacity - 1 ) {
_index++;
this[_index] = item;
this[ _index ] = item;
}
}
@@ -83,52 +80,45 @@ namespace StgSharp.Commom.Collections
_index = 0;
}
public bool Contains(T item)
public bool Contains( T item )
{
for (int i = 0; i <= _index; i++)
{
if (item.Equals(values[i]))
{
for( int i = 0; i <= _index; i++ ) {
if( item.Equals( values[ i ] ) ) {
return true;
}
}
return false;
}
public void CopyTo(T[] array, int arrayIndex)
public void CopyTo( T[] array, int arrayIndex )
{
values.CopyTo(array, arrayIndex);
values.CopyTo( array, arrayIndex );
}
public IEnumerator<T> GetEnumerator()
{
for (int i = 0; i <= _index; i++)
{
yield return values[i];
for( int i = 0; i <= _index; i++ ) {
yield return values[ i ];
}
}
public int IndexOf(T item)
public int IndexOf( T item )
{
T v;
for (int i = 0; i <= _index; i++)
{
if ((v = values[i]) != null && v.Equals(item))
{
for( int i = 0; i <= _index; i++ ) {
if( ( v = values[ i ] ) != null && v.Equals( item ) ) {
return i;
}
}
return -1;
}
public bool Remove(T item)
public bool Remove( T item )
{
T v;
for (int i = 0; i <= _index; i++)
{
if ((v = values[i]) != null && v.Equals(item))
{
values[i] = values[_index];
for( int i = 0; i <= _index; i++ ) {
if( ( v = values[ i ] ) != null && v.Equals( item ) ) {
values[ i ] = values[ _index ];
_index--;
return true;
}
@@ -136,30 +126,27 @@ namespace StgSharp.Commom.Collections
return false;
}
public void RemoveAll(Predicate<T> predicate)
public void RemoveAll( Predicate<T> predicate )
{
for (int i = _index; i > 0; i--)
{
if (predicate(values[i]))
{
values[i] = values[_index];
for( int i = _index; i > 0; i-- ) {
if( predicate( values[ i ] ) ) {
values[ i ] = values[ _index ];
_index--;
}
}
}
public void RemoveAt(int index)
public void RemoveAt( int index )
{
if (index <= _index)
{
values[index] = values[_index];
if( index <= _index ) {
values[ index ] = values[ _index ];
_index--;
}
}
public void Resize(int newSize)
public void Resize( int newSize )
{
Array.Resize(ref values, newSize);
Array.Resize( ref values, newSize );
}
IEnumerator IEnumerable.GetEnumerator()
@@ -167,7 +154,7 @@ namespace StgSharp.Commom.Collections
yield return GetEnumerator();
}
void IList<T>.Insert(int index, T item)
void IList<T>.Insert( int index, T item )
{
throw new NotSupportedException();
}