Table of Contents

Class SerializedSwiftSparseSet

Unity-serializable adapter for persisted compact integer-ID membership consumed as a SwiftSparseSet.

[Serializable]
public sealed class SerializedSwiftSparseSet : ISerializationCallbackReceiver
Inheritance
SerializedSwiftSparseSet
Implements
ISerializationCallbackReceiver
Inherited Members

Properties

Count

Gets the number of stored IDs.

public int Count { get; }

Property Value

int

Runtime

Gets the live runtime sparse set rebuilt from Unity serialized data.

public SwiftSparseSet Runtime { get; }

Property Value

SwiftSparseSet

Remarks

Direct runtime mutations are copied into serialized backing data before Unity serialization.

Methods

Add(int)

Adds an ID to the runtime set and updates the serialized backing array.

public bool Add(int item)

Parameters

item int

The non-negative ID to add.

Returns

bool

true when the ID was added; otherwise false.

Exceptions

ArgumentOutOfRangeException

item is negative.

Clear()

Removes all IDs from the runtime set and serialized backing array.

public void Clear()

Contains(int)

Returns whether the set contains the specified ID.

public bool Contains(int item)

Parameters

item int

The non-negative ID to find.

Returns

bool

true when the ID exists; otherwise false.

Exceptions

ArgumentOutOfRangeException

item is negative.

GetEnumerator()

Returns an enumerator for the runtime sparse set.

public SwiftSparseSet.SwiftSparseSetEnumerator GetEnumerator()

Returns

SwiftSparseSet.SwiftSparseSetEnumerator

A SwiftCollections sparse set enumerator.

OnAfterDeserialize()

Rebuilds runtime contents after Unity deserialization.

public void OnAfterDeserialize()

Exceptions

ArgumentOutOfRangeException

A serialized ID is negative.

InvalidOperationException

Serialized IDs contain duplicates.

OnBeforeSerialize()

Copies live runtime contents into Unity's serialized backing data.

public void OnBeforeSerialize()

Remove(int)

Removes an ID from the runtime set and updates the serialized backing array.

public bool Remove(int item)

Parameters

item int

The non-negative ID to remove.

Returns

bool

true when the ID was removed; otherwise false.

Exceptions

ArgumentOutOfRangeException

item is negative.

SetItems(params int[])

Replaces the serialized contents with a copy of the supplied IDs.

public void SetItems(params int[] items)

Parameters

items int[]

The unique, non-negative IDs to persist.

Exceptions

ArgumentNullException

items is null.

ArgumentOutOfRangeException

An ID is negative.

InvalidOperationException

items contains duplicate IDs.

ToArray()

Returns a copy of the serialized IDs.

public int[] ToArray()

Returns

int[]

A new array containing the current IDs.

ToSwiftSparseSet()

Returns a copy as a standalone SwiftSparseSet.

public SwiftSparseSet ToSwiftSparseSet()

Returns

SwiftSparseSet

A new sparse set containing the current IDs.