private static void InitPool() { for (var i = 0; i < SOUND_SOURCES_COUNT; i++) { var source = new SoundSource(); source.Handle = new SoundHandle((ushort)(i + 1), 0); AllSources[i] = source; FreeList.AddFirst(source.Link); } }
public void DoubleLinkedListTestRun() { DLinkedList <string> stringsList = new DLinkedList <string>(); stringsList.AddLast(new DLinkedListNode <string>("1")); stringsList.AddLast(new DLinkedListNode <string>("2")); stringsList.AddFirst(new DLinkedListNode <string>("0")); Debug.Log(stringsList.ToString()); string[] stringArray = stringsList.ToArray(); Debug.Assert(stringArray[0] == "0"); Debug.Assert(stringArray[1] == "1"); Debug.Assert(stringArray[2] == "2"); Debug.Assert(stringsList.ToList().ToArray().ToString() == new string[] { "0", "1", "2" }.ToString()); Debug.Assert(stringsList.ToArray().ToString() == new string[] { "0", "1", "2" }.ToString()); string iteratorString = ""; foreach (string v in stringsList) { iteratorString += v.ToString(); } Debug.Assert(iteratorString == "012"); DLinkedList <int> intList = new DLinkedList <int>(); intList.AddLast(new DLinkedListNode <int>(1)); intList.AddLast(new DLinkedListNode <int>(2)); intList.AddFirst(new DLinkedListNode <int>(0)); Debug.Log(stringsList.ToString( )); int[] intArray = intList.ToArray(); Debug.Assert(intArray[0] == 0); Debug.Assert(intArray[1] == 1); Debug.Assert(intArray[2] == 2); Debug.Assert(intList.ToList().ToArray().ToString() == new int[] { 0, 1, 2 }.ToString()); Debug.Assert(intList.ToArray().ToString() == new int[] { 0, 1, 2 }.ToString()); DLinkedList <MyClass> intusiveList = new DLinkedList <MyClass>(); intusiveList.AddLast(new MyClass(1).link); intusiveList.AddLast(new MyClass(2).link); intusiveList.AddFirst(new MyClass(0).link); Debug.Log(stringsList.ToString( )); MyClass[] classArray = intusiveList.ToArray(); Debug.Assert(classArray[0].value == 0); Debug.Assert(classArray[1].value == 1); Debug.Assert(classArray[2].value == 2); Debug.Assert(intusiveList.ToList().ToArray().ToString() == new MyClass[] { new MyClass(0), new MyClass(1), new MyClass(2) }.ToString()); Debug.Assert(intusiveList.ToArray().ToString() == new MyClass[] { new MyClass(0), new MyClass(1), new MyClass(2) }.ToString()); }