AudioStreamer/AudioStreamer/ModuloList.cs

35 lines
525 B
C#

using System;
using System.Runtime.CompilerServices;
namespace AudioStreamer
{
public class ModuloList<T>
{
T[] buffer;
public ModuloList(int size)
{
buffer = new T[size];
}
public T this[int n]{
get {
n %= this.buffer.Length;
if (n<0){
n += this.buffer.Length;
}
return this.buffer[n];
}
set {
n %= this.buffer.Length;
if (n<0){
n += this.buffer.Length;
}
this.buffer[n] = value;
}
}
public int Size { get { return this.buffer.Length; } }
}
}