namespace Qrakhen.Qamp.Core.Collections;
///
/// Dynamic Pointer able to point to any object implementing the interface.
///
public class Pointer
{
protected IGetSet Target;
public long Ptr;
public Pointer(IGetSet target, long pointer = 0)
{
Target = target;
Ptr = pointer;
}
public Pointer Branch(long delta = 0)
{
return new Pointer(Target, Ptr + delta);
}
///
/// Returns the next item from and increases the pointer by 1.
///
public T Next() => Target.Get(Ptr++);
///
/// Sets the value of at .
///
public void Set(long position, T value) => Target.Set(position, value);
///
/// Sets the value of at the current location.
///
public void Set(T value) => Set(Ptr, value);
///
/// Gets the value of at .
///
public T Get(long position) => Target.Get(position);
///
/// Gets the value of at the current location.
///
public T Get() => Get(Ptr);
}