2024-08-04 09:08:12 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace Rokojori
|
|
|
|
{
|
|
|
|
public class Arrays
|
|
|
|
{
|
2024-09-14 06:41:52 +00:00
|
|
|
public static int IndexOf<T>( T[] values, T other )
|
|
|
|
{
|
|
|
|
return Array.IndexOf( values, other );
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int FindIndex<T>( T[] values, Func<T,bool> predicate )
|
|
|
|
{
|
|
|
|
for ( int i = 0; i < values.Length; i++ )
|
|
|
|
{
|
|
|
|
if ( predicate( values[ i ] ) )
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2024-08-05 07:14:00 +00:00
|
|
|
public static bool Contains <T>( T[] values, T other )
|
|
|
|
{
|
|
|
|
return Array.IndexOf( values, other ) != -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static T[] Add<T>( T[] values, T other )
|
|
|
|
{
|
|
|
|
var newValues = new T[ values.Length + 1 ];
|
|
|
|
|
|
|
|
Array.Copy( values, newValues, values.Length );
|
|
|
|
newValues[ values.Length ] = other;
|
|
|
|
|
|
|
|
return newValues;
|
|
|
|
}
|
|
|
|
|
2024-08-04 09:08:12 +00:00
|
|
|
public static void ForEach<T>( T[] values, Action<T> callback )
|
|
|
|
{
|
|
|
|
foreach ( var it in values )
|
|
|
|
{
|
|
|
|
callback( it );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|