Fusion type for networking LinkedLists. Maximum capacity is fixed, and is set with the CapacityAttribute.
Typical Usage:
More...
Inherits IEnumerable< T >, and INetworkLinkedList.
Classes | |
struct | Enumerator |
Enumerator for NetworkLinkedList<T>. More... | |
Public Member Functions | |
void INetworkLinkedList. | Add (object item) |
Adds an item to the networked linked list. More... | |
void | Add (T value) |
Adds a value to the end of the list. More... | |
void | Clear () |
Removes and clears all list elements. More... | |
bool | Contains (T value) |
Returns true if the value already exists in the list. More... | |
bool | Contains (T value, IEqualityComparer< T > comparer) |
Returns true if the value already exists in the list. More... | |
int * | Entry (int index) |
int * | FindFreeEntry (out int index) |
T | Get (int index) |
Returns the value at supplied index. More... | |
int * | GetEntryByListIndex (int listIndex) |
Enumerator | GetEnumerator () |
Get the enumerator for the list. More... | |
IEnumerator< T > IEnumerable< T >. | GetEnumerator () |
IEnumerator IEnumerable. | GetEnumerator () |
int | IndexOf (T value) |
Returns the index with this value. Returns -1 if not found. More... | |
int | IndexOf (T value, IEqualityComparer< T > equalityComparer) |
Returns the index of the first occurrence of a value in the NetworkLinkedList. More... | |
NetworkLinkedList (byte *data, int capacity, IElementReaderWriter< T > rw) | |
Initializes a new instance of the NetworkLinkedList struct with the specified data, capacity, and reader/writer. More... | |
T | Read (int *entry) |
NetworkLinkedList< T > | Remap (void *list) |
Remaps the current NetworkLinkedList to a new memory location. More... | |
bool | Remove (T value) |
Removes the first found element with indicated value. More... | |
bool | Remove (T value, IEqualityComparer< T > equalityComparer) |
Removes the first found element with indicated value. More... | |
void | RemoveEntry (int *entry, int entryIndex) |
T | Set (int index, T value) |
Sets the value at supplied index. More... | |
void | Write (int *entry, T value) |
Public Attributes | |
int | _capacity |
int * | _data |
IElementReaderWriter< T > | _rw |
int | _stride |
Static Public Attributes | |
const int | COUNT = 0 |
const int | ELEMENT_WORDS = 2 |
Returns the number of words required to store a single element. More... | |
const int | HEAD = 1 |
const int | INVALID = 0 |
const int | META_WORDS = 3 |
Returns the number of words required to store the list metadata. More... | |
const int | NEXT = 1 |
const int | OFFSET = 1 |
const int | PREV = 0 |
const int | TAIL = 2 |
Properties | |
int | Capacity [get] |
Returns the max element count. More... | |
int | Count [get] |
Returns the current element count. More... | |
int | Head [get, set] |
int | Tail [get, set] |
T | this[int index] [get, set] |
Element indexer. More... | |
Fusion type for networking LinkedLists. Maximum capacity is fixed, and is set with the CapacityAttribute.
Typical Usage:
[Networked, Capacity(10)]
NetworkLinkedList<int> syncedLinkedList => default;
Optional usage (for NetworkBehaviours ONLY - this is not legal in INetworkStructs): [Networked, Capacity(4)]
NetworkLinkedList<int> syncedLinkedList { get; } = MakeInitializer(new int[] { 1, 2, 3, 4 });
Usage for modifying data: var list = syncedLinkedList; list.Add(123); list[0] = 456; list.Remove(0);
T | T can be a primitive, or an INetworkStruct. |
NetworkLinkedList | ( | byte * | data, |
int | capacity, | ||
IElementReaderWriter< T > | rw | ||
) |
Initializes a new instance of the NetworkLinkedList struct with the specified data, capacity, and reader/writer.
data | The pointer to the data of the list. |
capacity | The capacity of the list. |
rw | The reader/writer for the elements of the list. |
void INetworkLinkedList. Add | ( | object | item | ) |
Adds an item to the networked linked list.
item | The item to add to the linked list. |
Implements INetworkLinkedList.
void Add | ( | T | value | ) |
Adds a value to the end of the list.
value | Value to add. |
void Clear | ( | ) |
Removes and clears all list elements.
bool Contains | ( | T | value | ) |
Returns true if the value already exists in the list.
bool Contains | ( | T | value, |
IEqualityComparer< T > | comparer | ||
) |
Returns true if the value already exists in the list.
T Get | ( | int | index | ) |
Returns the value at supplied index.
Enumerator GetEnumerator | ( | ) |
Get the enumerator for the list.
int IndexOf | ( | T | value | ) |
Returns the index with this value. Returns -1 if not found.
int IndexOf | ( | T | value, |
IEqualityComparer< T > | equalityComparer | ||
) |
Returns the index of the first occurrence of a value in the NetworkLinkedList.
value | The value to locate in the NetworkLinkedList. The value can be null for reference types. |
equalityComparer | An equality comparer to compare values. Must not be null. |
This method performs a linear search; therefore, this method is an O(n) operation, where n is Capacity.
NetworkLinkedList<T> Remap | ( | void * | list | ) |
Remaps the current NetworkLinkedList to a new memory location.
list | The pointer to the new memory location. |
bool Remove | ( | T | value | ) |
Removes the first found element with indicated value.
bool Remove | ( | T | value, |
IEqualityComparer< T > | equalityComparer | ||
) |
Removes the first found element with indicated value.
T Set | ( | int | index, |
T | value | ||
) |
Sets the value at supplied index.
|
static |
Returns the number of words required to store a single element.
|
static |
Returns the number of words required to store the list metadata.
|
get |
Returns the max element count.
|
get |
Returns the current element count.
|
getset |
Element indexer.