DebugLogIndexList.cs 627 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. namespace IngameDebugConsole
  2. {
  3. public class DebugLogIndexList<T>
  4. {
  5. private T[] indices;
  6. private int size;
  7. public int Count { get { return size; } }
  8. public T this[int index]
  9. {
  10. get { return indices[index]; }
  11. set { indices[index] = value; }
  12. }
  13. public DebugLogIndexList()
  14. {
  15. indices = new T[64];
  16. size = 0;
  17. }
  18. public void Add( T value )
  19. {
  20. if( size == indices.Length )
  21. System.Array.Resize( ref indices, size * 2 );
  22. indices[size++] = value;
  23. }
  24. public void Clear()
  25. {
  26. size = 0;
  27. }
  28. public int IndexOf( T value )
  29. {
  30. return System.Array.IndexOf( indices, value );
  31. }
  32. }
  33. }