daily update on 20250210 by nitload youmu
This commit is contained in:
@@ -39,23 +39,23 @@ namespace StgSharp.Commom.Collections
|
||||
internal class CapacityFixedList<T> : IList<T>
|
||||
{
|
||||
|
||||
private T[] values;
|
||||
private T[] _values;
|
||||
private int capacity, _index;
|
||||
|
||||
public CapacityFixedList( int size )
|
||||
{
|
||||
values = new T[size];
|
||||
_values = new T[size];
|
||||
}
|
||||
|
||||
public T this[ int index ]
|
||||
{
|
||||
get => index < _index ?
|
||||
values[ index ] : throw new ArgumentOutOfRangeException(
|
||||
_values[ index ] : throw new ArgumentOutOfRangeException(
|
||||
nameof( index ) );
|
||||
set
|
||||
{
|
||||
if( index < _index ) {
|
||||
values[ index ] = value;
|
||||
_values[ index ] = value;
|
||||
} else {
|
||||
throw new ArgumentOutOfRangeException( nameof( index ) );
|
||||
}
|
||||
@@ -76,14 +76,14 @@ namespace StgSharp.Commom.Collections
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
values = new T[capacity];
|
||||
_values = new T[capacity];
|
||||
_index = 0;
|
||||
}
|
||||
|
||||
public bool Contains( T item )
|
||||
{
|
||||
for( int i = 0; i <= _index; i++ ) {
|
||||
if( item.Equals( values[ i ] ) ) {
|
||||
if( item.Equals( _values[ i ] ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -92,13 +92,13 @@ namespace StgSharp.Commom.Collections
|
||||
|
||||
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 ];
|
||||
yield return _values[ i ];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace StgSharp.Commom.Collections
|
||||
{
|
||||
T v;
|
||||
for( int i = 0; i <= _index; i++ ) {
|
||||
if( ( v = values[ i ] ) != null && v.Equals( item ) ) {
|
||||
if( ( v = _values[ i ] ) != null && v.Equals( item ) ) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -117,8 +117,8 @@ namespace StgSharp.Commom.Collections
|
||||
{
|
||||
T v;
|
||||
for( int i = 0; i <= _index; i++ ) {
|
||||
if( ( v = values[ i ] ) != null && v.Equals( item ) ) {
|
||||
values[ i ] = values[ _index ];
|
||||
if( ( v = _values[ i ] ) != null && v.Equals( item ) ) {
|
||||
_values[ i ] = _values[ _index ];
|
||||
_index--;
|
||||
return true;
|
||||
}
|
||||
@@ -129,8 +129,8 @@ namespace StgSharp.Commom.Collections
|
||||
public void RemoveAll( Predicate<T> predicate )
|
||||
{
|
||||
for( int i = _index; i > 0; i-- ) {
|
||||
if( predicate( values[ i ] ) ) {
|
||||
values[ i ] = values[ _index ];
|
||||
if( predicate( _values[ i ] ) ) {
|
||||
_values[ i ] = _values[ _index ];
|
||||
_index--;
|
||||
}
|
||||
}
|
||||
@@ -139,14 +139,14 @@ namespace StgSharp.Commom.Collections
|
||||
public void RemoveAt( int index )
|
||||
{
|
||||
if( index <= _index ) {
|
||||
values[ index ] = values[ _index ];
|
||||
_values[ index ] = _values[ _index ];
|
||||
_index--;
|
||||
}
|
||||
}
|
||||
|
||||
public void Resize( int newSize )
|
||||
{
|
||||
Array.Resize( ref values, newSize );
|
||||
Array.Resize( ref _values, newSize );
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
|
||||
Reference in New Issue
Block a user