style(SyncList): formatting

This commit is contained in:
MrGadget 2024-03-23 11:48:22 -04:00
parent 48beaf597c
commit a356ef7aa4

View File

@ -6,23 +6,23 @@ namespace Mirror
{
public class SyncList<T> : SyncObject, IList<T>, IReadOnlyList<T>
{
public enum Operation : byte
{
OP_ADD,
OP_SET,
OP_INSERT,
OP_REMOVEAT,
OP_CLEAR
}
public delegate void SyncListChanged(Operation op, int itemIndex, T oldItem, T newItem);
public event SyncListChanged Callback;
readonly IList<T> objects;
readonly IEqualityComparer<T> comparer;
public int Count => objects.Count;
public bool IsReadOnly => !IsWritable();
public event SyncListChanged Callback;
public enum Operation : byte
{
OP_ADD,
OP_CLEAR,
OP_INSERT,
OP_REMOVEAT,
OP_SET
}
struct Change
{
@ -43,7 +43,7 @@ struct Change
// so we need to skip them
int changesAhead;
public SyncList() : this(EqualityComparer<T>.Default) {}
public SyncList() : this(EqualityComparer<T>.Default) { }
public SyncList(IEqualityComparer<T> comparer)
{
@ -71,9 +71,7 @@ public override void Reset()
void AddOperation(Operation op, int itemIndex, T oldItem, T newItem, bool checkAccess)
{
if (checkAccess && IsReadOnly)
{
throw new InvalidOperationException("Synclists can only be modified by the owner.");
}
Change change = new Change
{
@ -265,9 +263,7 @@ public void Add(T item)
public void AddRange(IEnumerable<T> range)
{
foreach (T entry in range)
{
Add(entry);
}
}
public void Clear()
@ -331,9 +327,8 @@ public bool Remove(T item)
int index = IndexOf(item);
bool result = index >= 0;
if (result)
{
RemoveAt(index);
}
return result;
}
@ -352,9 +347,7 @@ public int RemoveAll(Predicate<T> match)
toRemove.Add(objects[i]);
foreach (T entry in toRemove)
{
Remove(entry);
}
return toRemove.Count;
}
@ -393,6 +386,7 @@ public struct Enumerator : IEnumerator<T>
{
readonly SyncList<T> list;
int index;
public T Current { get; private set; }
public Enumerator(SyncList<T> list)
@ -405,16 +399,15 @@ public Enumerator(SyncList<T> list)
public bool MoveNext()
{
if (++index >= list.Count)
{
return false;
}
Current = list[index];
return true;
}
public void Reset() => index = -1;
object IEnumerator.Current => Current;
public void Dispose() {}
public void Dispose() { }
}
}
}