daily update on 20241002 by nitload youmu, intrinsic function rebuild, syntax style arrange
This commit is contained in:
@@ -42,23 +42,22 @@ namespace StgSharp.Collections
|
||||
private T[] values;
|
||||
private int capacity, _index;
|
||||
|
||||
public SizeFixedList(int size)
|
||||
public SizeFixedList( 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));
|
||||
get => ( index < _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 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,12 +66,11 @@ namespace StgSharp.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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,56 +80,43 @@ namespace StgSharp.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 )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
for (int i = 0; i <= _index; i++)
|
||||
{
|
||||
if (values[i].Equals(item))
|
||||
{
|
||||
for( int i = 0; i <= _index; i++ ) {
|
||||
if( values[ i ].Equals( item ) ) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void IList<T>.Insert(int index, T item)
|
||||
public bool Remove( T item )
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool Remove(T item)
|
||||
{
|
||||
|
||||
for (int i = 0; i <= _index; i++)
|
||||
{
|
||||
if (values[i].Equals(item))
|
||||
{
|
||||
values[i] = values[_index];
|
||||
for( int i = 0; i <= _index; i++ ) {
|
||||
if( values[ i ].Equals( item ) ) {
|
||||
values[ i ] = values[ _index ];
|
||||
_index--;
|
||||
return true;
|
||||
}
|
||||
@@ -139,30 +124,27 @@ namespace StgSharp.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()
|
||||
@@ -170,5 +152,10 @@ namespace StgSharp.Collections
|
||||
yield return GetEnumerator();
|
||||
}
|
||||
|
||||
void IList<T>.Insert( int index, T item )
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
}//------------------------------------- End of Class ------------------------------------------
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user