mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
style(SyncList): formatting
This commit is contained in:
parent
bdac4445ca
commit
fb1fc3a0ae
@ -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() { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user