public void RangeSearching3() { TestKey keyFactory = new TestKey(); IBTree bTree = new /*BTree*/ OmniaMeaBTree(_indexFileName, keyFactory); bTree.SetCacheSize(2); bTree.Open(); for (int i = 0; i < 100000; i++) { bTree.InsertKey(new TestKey(2), i); } IntArrayList offsets = new IntArrayList(); bTree.SearchForRange(new TestKey(2), new TestKey(2), offsets); Assert.AreEqual(true, FindOffset(offsets, 9000)); bTree.DeleteKey(new TestKey(2), 9000); offsets.Clear(); bTree.SearchForRange(new TestKey(2), new TestKey(2), offsets); Assert.AreEqual(false, FindOffset(offsets, 9000)); Assert.AreEqual(true, FindOffset(offsets, 1)); bTree.DeleteKey(new TestKey(2), 1); offsets.Clear(); bTree.SearchForRange(new TestKey(2), new TestKey(2), offsets); Assert.AreEqual(false, FindOffset(offsets, 1)); bTree.Close(); }
public void BatchSearchingBackward() { TestKey keyFactory = new TestKey(); IBTree bTree = new /*BTree*/OmniaMeaBTree( _indexFileName, keyFactory ); using( bTree ) { bTree.Open(); IntArrayList offsets = new IntArrayList(); for( int i = 10000; i > 0; i-- ) { bTree.InsertKey( new TestKey( i ), i ); offsets.Clear(); bTree.SearchForRange( new TestKey( i ), new TestKey( i ), offsets ); Assert.AreEqual( true, FindOffset( offsets, i ), i.ToString() + " not found" ); } Assert.AreEqual( 10000, bTree.Count ); for( int i = 10000; i > 0; i-- ) { bTree.DeleteKey( new TestKey( i ), i ); offsets.Clear(); bTree.SearchForRange( new TestKey( i ), new TestKey( i ), offsets ); Assert.AreEqual( 0, offsets.Count, i.ToString() + " must not be found" ); Assert.AreEqual( false, FindOffset( offsets, i ) ); } Assert.AreEqual( 0, bTree.Count ); bTree.Close(); bTree.Open(); Assert.AreEqual( 0, bTree.Count ); bTree.Close(); } }
public void SequentialSearchDeleteInsert() { IntHashSet numbers = new IntHashSet(); const int queueSize = 100000; TestKey keyFactory = new TestKey(); IBTree bTree = new /*BTree*/OmniaMeaBTree( _indexFileName, keyFactory ); using( bTree ) { bTree.Open( ); //Random random = new Random( System.Environment.TickCount ); Queue queue = new Queue( queueSize ); for ( int i = 0; i < queueSize; i++ ) { int key = GetUniqueRand( numbers ); TestKey testKey = new TestKey( key ); queue.Enqueue( testKey ); bTree.InsertKey( testKey, key ); } bTree.Close(); if( !bTree.Open() ) { throw new Exception( "Can't reopen btree! "); } int time = System.Environment.TickCount; IntArrayList offsets = new IntArrayList(); for ( int i = 0; i < 20000; i++ ) { TestKey testKey = (TestKey)queue.Dequeue(); offsets.Clear(); bTree.SearchForRange( testKey, testKey, offsets ); Assert.AreEqual( 1, offsets.Count, testKey.Key.ToString() + " not found. i = " + i.ToString() ); Assert.AreEqual( (int)testKey.Key, offsets[0] ); bTree.DeleteKey( testKey, (int)testKey.Key ); numbers.Remove( (int)testKey.Key ); offsets.Clear(); bTree.SearchForRange( testKey, testKey, offsets ); Assert.AreEqual( 0, offsets.Count ); TestKey newKey = new TestKey( GetUniqueRand( numbers ) ); queue.Enqueue( newKey ); bTree.InsertKey( newKey, (int)newKey.Key ); offsets.Clear(); bTree.SearchForRange( newKey, newKey, offsets ); Assert.AreEqual( 1, offsets.Count ); Assert.AreEqual( (int)newKey.Key, offsets[0] ); } time = System.Environment.TickCount - time; Console.WriteLine( " work took " + time.ToString() ); bTree.Close(); } }
private void DoStressProcessing( IBTree bTree ) { const int initialSize = 500000; const int iterations = 1000000; IntHashSet uniqueKeys = new IntHashSet(); IntArrayList array = new IntArrayList(); using( bTree ) { bTree.Open(); for( int i = 0; i < initialSize; ++i ) { bTree.InsertKey( new TestKey( GetUniqueRand( uniqueKeys ) ), 0 ); } for( int i = 0; i < iterations; ++i ) { int key = 0; foreach( IntHashSet.Entry e in uniqueKeys ) { key = e.Key; break; } array.Clear(); bTree.SearchForRange( new TestKey( key ), new TestKey( key ), array ); Assert.AreEqual( 1, array.Count ); bTree.DeleteKey( new TestKey( key ), 0 ); uniqueKeys.Remove( key ); if( ( i & 31 ) == 5 ) { array.Clear(); bTree.GetAllKeys( array ); Assert.AreEqual( initialSize + i - 1, array.Count ); Assert.AreEqual( uniqueKeys.Count, array.Count ); } bTree.InsertKey( new TestKey( GetUniqueRand( uniqueKeys ) ), 0 ); bTree.InsertKey( new TestKey( GetUniqueRand( uniqueKeys ) ), 0 ); if( ( i & 31 ) == 17 ) { array.Clear(); bTree.GetAllKeys( array ); Assert.AreEqual( initialSize + i + 1, array.Count ); Assert.AreEqual( uniqueKeys.Count, array.Count ); } Trace.WriteLine( "Passes: " + i ); } bTree.Close(); } }
public void BatchInsertingAndDeleting() { TestKey keyFactory = new TestKey(); IBTree bTree = new /*BTree*/OmniaMeaBTree( _indexFileName, keyFactory ); using( bTree ) { bTree.Open(); for( int i = 0; i < 10000; i++ ) { bTree.InsertKey( new TestKey( i ), i ); } Assert.AreEqual( 10000, bTree.Count ); for( int i = 0; i < 10000; i++ ) { bTree.DeleteKey( new TestKey( i ), i ); } Assert.AreEqual( 0, bTree.Count ); bTree.Close(); bTree.Open(); Assert.AreEqual( 0, bTree.Count ); for( int i = 0; i < 10; i++ ) { bTree.InsertKey( new TestKey( i ), i ); } Assert.AreEqual( 10, bTree.Count ); IntArrayList offsets = new IntArrayList(); for( int i = 0; i < 10; i++ ) { offsets.Clear(); bTree.SearchForRange( new TestKey( i ), new TestKey( i ), offsets ); Assert.AreEqual( 1, offsets.Count ); Assert.AreEqual( i, offsets[0] ); } for( int i = 0; i < 10; i++ ) { bTree.DeleteKey( new TestKey( i ), i ); } Assert.AreEqual( 0, bTree.Count ); for( int i = 0; i < 10; i++ ) { offsets.Clear(); bTree.SearchForRange( new TestKey( i ), new TestKey( i ), offsets ); Assert.AreEqual( 0, offsets.Count ); } bTree.Close(); } }
public void BatchSearching() { TestKey keyFactory = new TestKey(); IBTree bTree = new /*BTree*/ OmniaMeaBTree(_indexFileName, keyFactory); bTree.SetCacheSize(2); bTree.Open(); for (int i = 0; i < 10000; i++) { bTree.InsertKey(new TestKey(i), i); } Assert.AreEqual(10000, bTree.Count); IntArrayList offsets = new IntArrayList(); for (int i = 0; i < 10000; i++) { bTree.DeleteKey(new TestKey(i), i); offsets.Clear(); bTree.SearchForRange(new TestKey(i), new TestKey(Int32.MaxValue), offsets); Assert.AreEqual(10000 - i - 1, offsets.Count); Assert.AreEqual(false, FindOffset(offsets, i)); } Assert.AreEqual(0, bTree.Count); bTree.Close(); bTree.Open(); Assert.AreEqual(0, bTree.Count); bTree.Close(); }
public void Clearing() { TestKey keyFactory = new TestKey(); IBTree bTree = new /*BTree*/OmniaMeaBTree( _indexFileName, keyFactory ); using( bTree ) { bTree.Open(); bTree.InsertKey( new TestKey( 1 ), 1 ); for( int i = 0; i < 10000; i++ ) { bTree.InsertKey( new TestKey( 2 ), i ); } bTree.InsertKey( new TestKey( 3 ), 3 ); IntArrayList offsets = new IntArrayList(); bTree.SearchForRange( new TestKey( 2 ), new TestKey( 2 ), offsets ); Assert.AreEqual( 10000, offsets.Count ); bTree.Clear(); offsets.Clear(); bTree.SearchForRange( new TestKey( 2 ), new TestKey( 2 ), offsets ); Assert.AreEqual( 0, offsets.Count ); Assert.AreEqual( 0, bTree.Count ); for( int i = 0; i < 10000; i++ ) { bTree.InsertKey( new TestKey( 2 ), i ); } Assert.AreEqual( 10000, bTree.Count ); bTree.Close(); } }
/// <summary> /// Fills the coordinates and values of cells having non-zero values into the specified lists. /// Fills into the lists, starting at index 0. /// After this call returns the specified lists all have a new size, the number of non-zero values. /// </summary> /// <param name="indexList"> /// The list to be filled with indexes, can have any size. /// </param> /// <param name="valueList"> /// The list to be filled with values, can have any size. /// </param> public override void GetNonZeros(IntArrayList indexList, List <double> valueList) { bool fillIndexList = indexList != null; bool fillValueList = valueList != null; if (fillIndexList) { indexList.Clear(); } if (fillValueList) { valueList.Clear(); } AutoParallel.AutoParallelForEach(Elements, (e) => { if (fillIndexList) { indexList.Add(e.Key); } if (fillValueList) { valueList.Add(e.Value); } }); }
/// <summary> /// Unserializes a BinaryStream into the Attributes of this Instance /// </summary> /// <param name="reader">The Stream that contains the FileData</param> public void Unserialize(System.IO.BinaryReader reader) { unknown1 = (PrimitiveType)reader.ReadUInt32(); alternate = reader.ReadInt32(); name = reader.ReadString(); ReadBlock(reader, items1); if (parent.Version != 0x03) { opacity = reader.ReadUInt32(); } else { opacity = 0; } if (parent.Version != 0x01) { ReadBlock(reader, items2); } else { items2.Clear(); } }
/// <summary> /// Fills the coordinates and values of cells having non-zero values into the specified lists. /// Fills into the lists, starting at index 0. /// After this call returns the specified lists all have a new size, the number of non-zero values. /// </summary> /// <param name="indexList"> /// The list to be filled with indexes, can have any size. /// </param> /// <param name="valueList"> /// The list to be filled with values, can have any size. /// </param> public override void GetNonZeros(IntArrayList indexList, List <double> valueList) { bool fillIndexList = indexList != null; bool fillValueList = valueList != null; if (fillIndexList) { indexList.Clear(); } if (fillValueList) { valueList.Clear(); } foreach (var e in Elements) { if (fillIndexList) { indexList.Add(e.Key); } if (fillValueList) { valueList.Add(e.Value); } } }
/// <summary> /// Fills the coordinates and values of cells having non-zero values into the specified lists. /// Fills into the lists, starting at index 0. /// After this call returns the specified lists all have a new size, the number of non-zero values. /// <p> /// In general, fill order is <i>unspecified</i>. /// This implementation fills like: <i>for (index = 0..Count - 1) do ..d </i>. /// However, subclasses are free to us any other order, even an order that may change over time as cell values are changed. /// (Of course, result lists indexes are guaranteed to correspond to the same cell). /// <p> /// <b>Example:</b> /// <br> /// <pre> /// 0, 0, 8, 0, 7 /// --> /// indexList = (2,4) /// valueList = (8,7) /// </pre> /// In other words, <i>get(2)==8, get(4)==7</i>. /// </summary> /// <param name="indexList">the list to be filled with indexes, can have any size.</param> /// <param name="valueList">the list to be filled with values, can have any size.</param> public void GetNonZeros(ref IntArrayList indexList, ref List <Object> valueList) { Boolean fillIndexList = indexList != null; Boolean fillValueList = valueList != null; if (fillIndexList) { indexList.Clear(); } if (fillValueList) { valueList.Clear(); } int s = Size; for (int i = 0; i < s; i++) { Object value = this[i]; if (value != null) { if (fillIndexList) { indexList.Add(i); } if (fillValueList) { valueList.Add(value); } } } }
/// <summary> /// Unserializes a BinaryStream into the Attributes of this Instance /// </summary> /// <param name="reader">The Stream that contains the FileData</param> public void Unserialize(System.IO.BinaryReader reader) { int vcount = reader.ReadInt32(); if (vcount > 0) { try { int count = reader.ReadInt32(); verts.Clear(); for (int i = 0; i < vcount; i++) { Vector3f f = new Vector3f(); f.Unserialize(reader); verts.Add(f); } items.Clear(); for (int i = 0; i < count; i++) { items.Add(this.ReadValue(reader)); } } catch (Exception ex) { Helper.ExceptionMessage("", ex); } } }
/// <summary> /// Fills the coordinates and values of cells having non-zero values into the specified lists. /// Fills into the lists, starting at index 0. /// After this call returns the specified lists all have a new size, the number of non-zero values. /// </summary> /// <param name="indexList"> /// The list to be filled with indexes, can have any size. /// </param> /// <param name="valueList"> /// The list to be filled with values, can have any size. /// </param> public virtual void GetNonZeros(IntArrayList indexList, List <double> valueList) { bool fillIndexList = indexList != null; bool fillValueList = valueList != null; if (fillIndexList) { indexList.Clear(); } if (fillValueList) { valueList.Clear(); } int s = Size; for (int i = 0; i < s; i++) { double value = this[i]; if (value != 0) { if (fillIndexList) { indexList.Add(i); } if (fillValueList) { valueList.Add(value); } } } }
public void GetAllOffsets() { TestKey keyFactory = new TestKey(); IBTree bTree = new /*BTree*/OmniaMeaBTree( _indexFileName, keyFactory ); using( bTree ) { bTree.Open(); bTree.InsertKey( new TestKey( 1 ), 1 ); for( int i = 0; i < 10000; i++ ) { bTree.InsertKey( new TestKey( 2 ), i ); } bTree.InsertKey( new TestKey( 3 ), 3 ); IntArrayList offsets = new IntArrayList(); bTree.GetAllKeys( offsets ); Assert.AreEqual( 10002, offsets.Count ); bTree.Close(); bTree.Open(); offsets.Clear(); bTree.GetAllKeys( offsets ); Assert.AreEqual( 10002, offsets.Count ); for( int i = 5; i < 15; ++i ) { bTree.InsertKey( new TestKey( i - 5 ), i ); } bTree.Close(); bTree.Open(); offsets.Clear(); bTree.GetAllKeys( offsets ); Assert.AreEqual( 10012, offsets.Count ); bTree.Close(); bTree.Open(); for( int i = 5; i < 15; ++i ) { bTree.DeleteKey( new TestKey( i - 5 ), i ); } offsets.Clear(); bTree.GetAllKeys( offsets ); Assert.AreEqual( 10002, offsets.Count ); bTree.Close(); bTree.Open(); offsets.Clear(); bTree.GetAllKeys( offsets ); Assert.AreEqual( 10002, offsets.Count ); bTree.Close(); } }
[Test] public void SameValuesInIntersectSortedInplace() { IntArrayList list1 = new IntArrayList(); list1.AddRange(new int[] { 0, 1, 2, 3, 3 }); IntArrayList list2 = new IntArrayList(); list2.AddRange(new int[] { 0, 1, 2, 3 }); list1.IntersectSorted(list2); Assert.AreEqual(4, list1.Count); AssertEquals(0, list1[0]); AssertEquals(1, list1[1]); AssertEquals(2, list1[2]); AssertEquals(3, list1[3]); list1.Clear(); list2.Clear(); list1.AddRange(new int[] { 3, 3 }); list2.AddRange(new int[] { 0, 1, 2, 3 }); list1.IntersectSorted(list2); Assert.AreEqual(1, list1.Count); AssertEquals(3, list1[0]); list1.Clear(); list2.Clear(); list2.AddRange(new int[] { 3, 3 }); list1.AddRange(new int[] { 0, 1, 2, 3 }); list1.IntersectSorted(list2); Assert.AreEqual(1, list1.Count); AssertEquals(3, list1[0]); list1.Clear(); list2.Clear(); list2.AddRange(new int[] { 0, 0, 3, 3 }); list1.AddRange(new int[] { 0, 1, 2 }); list1.IntersectSorted(list2); Assert.AreEqual(1, list1.Count); AssertEquals(0, list1[0]); list1.Clear(); list2.Clear(); list2.AddRange(new int[] { 0, 0, 3, 3, 7, 8, 9, 12, 12, 13 }); list1.AddRange(new int[] { 0, 1, 2, 3, 4, 5, 8, 8, 12 }); list1.IntersectSorted(list2); list1 = (IntArrayList)list1.Clone(); Assert.AreEqual(4, list1.Count); AssertEquals(0, list1[0]); AssertEquals(3, list1[1]); AssertEquals(8, list1[2]); AssertEquals(12, list1[3]); }
/// <summary> /// Read a Link Block /// </summary> /// <param name="reader"></param> /// <param name="items"></param> protected void ReadBlock(System.IO.BinaryReader reader, IntArrayList items) { int count = reader.ReadInt32(); items.Clear(); for (int i = 0; i < count; i++) { items.Add(ReadValue(reader)); } ; }
[Test] public void BinarySearchTests() { IntArrayList list = new IntArrayList(); int[] sorted = new int[] { 0, 0, 1, 2, 3, 4, 6, 7, 8, 8, 8, 8, 8, 8, 9, 10 }; list.AddRange(sorted); AssertEquals(Array.BinarySearch(sorted, 5), list.BinarySearch(5)); AssertEquals(Array.BinarySearch(sorted, 11), list.BinarySearch(11)); AssertEquals(Array.BinarySearch(sorted, 8), list.BinarySearch(8)); AssertEquals(Array.BinarySearch(sorted, 0), list.BinarySearch(0)); AssertEquals(Array.BinarySearch(sorted, 10), list.BinarySearch(10)); AssertEquals(Array.BinarySearch(sorted, -1), list.BinarySearch(-1)); AssertEquals(Array.BinarySearch(sorted, 100), list.BinarySearch(100)); list.Clear(); AssertEquals(Array.BinarySearch(new int[] {}, 5), list.BinarySearch(5)); }
/// <summary> /// Fills the coordinates and values of cells having non-zero values into the specified lists. /// Fills into the lists, starting at index 0. /// After this call returns the specified lists all have a new size, the number of non-zero values. /// </summary> /// <param name="indexList"> /// The list to be filled with indexes, can have any size. /// </param> /// <param name="valueList"> /// The list to be filled with values, can have any size. /// </param> /// <param name="maxCardinality"> /// The max cardinality. /// </param> public void GetNonZeros(IntArrayList indexList, List <double> valueList, int maxCardinality) { bool fillIndexList = indexList != null; bool fillValueList = valueList != null; int card = Cardinality(maxCardinality); if (fillIndexList) { indexList.Size = card; } if (fillValueList) { valueList.Capacity = card; } if (!(card < maxCardinality)) { return; } if (fillIndexList) { indexList.Clear(); } if (fillValueList) { valueList.Clear(); } int s = Size; for (int i = 0; i < s; i++) { double value = this[i]; if (value != 0) { if (fillIndexList) { indexList.Add(i); } if (fillValueList) { valueList.Add(value); } } } }
/// <summary> /// Fills the coordinates and values of cells having non-zero values into the specified lists. /// Fills into the lists, starting at index 0. /// After this call returns the specified lists all have a new size, the number of non-zero values. /// <p> /// In general, fill order is <i>unspecified</i>. /// This implementation fills like <i>for (row = 0..Rows-1) for (column = 0..Columns-1) do ..d </i>. /// However, subclasses are free to us any other order, even an order that may change over time as cell values are changed. /// (Of course, result lists indexes are guaranteed to correspond to the same cell). /// <p> /// <b>Example:</b> /// <br> /// <pre> /// 2 x 3 matrix: /// 0, 0, 8 /// 0, 7, 0 /// --> /// rowList = (0,1) /// columnList = (2,1) /// valueList = (8,7) /// </pre> /// In other words, <i>get(0,2)==8, get(1,1)==7</i>. /// </summary> /// <param name="rowList">the list to be filled with row indexes, can have any size.</param> /// <param name="columnList">the list to be filled with column indexes, can have any size.</param> /// <param name="valueList">the list to be filled with values, can have any size.</param> /// <returns></returns> /// <exception cref=""></exception> public virtual void GetNonZeros(ref IntArrayList rowList, ref IntArrayList columnList, ref List <Object> valueList) { rowList.Clear(); columnList.Clear(); valueList.Clear(); int r = Rows; int c = Columns; for (int row = 0; row < r; row++) { for (int column = 0; column < c; column++) { Object value = this[row, column]; if (value != null) { rowList.Add(row); columnList.Add(column); valueList.Add(value); } } } }
/// <summary> /// Fills the coordinates and values of cells having non-zero values into the specified lists. /// Fills into the lists, starting at index 0. /// After this call returns the specified lists all have a new size, the number of non-zero values. /// </summary> /// <param name="rowList"> /// The list to be filled with row indexes, can have any size. /// </param> /// <param name="columnList"> /// The list to be filled with column indexes, can have any size. /// </param> /// <param name="valueList"> /// The ist to be filled with values, can have any size. /// </param> public void GetNonZeros(IntArrayList rowList, IntArrayList columnList, List <double> valueList) { rowList.Clear(); columnList.Clear(); valueList.Clear(); int r = Rows; int c = Columns; for (int row = 0; row < r; row++) { for (int column = 0; column < c; column++) { double value = this[row, column]; if (value != 0) { rowList.Add(row); columnList.Add(column); valueList.Add(value); } } } }
public void TestIntArrayListMinusSorted() { IntArrayList array = new IntArrayList(); array.AddRange(new int[] { 0, 1, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9 }); IntArrayList minus = new IntArrayList(); minus.Add(0); minus.Add(1); array.MinusSorted(minus); Assert.AreEqual(10, array.Count); minus.Add(6); minus.Add(7); minus.Add(8); minus.Add(9); array.MinusSorted(minus); Assert.AreEqual(6, array.Count); minus.Clear(); minus.Add(5); array.MinusSorted(minus); Assert.AreEqual(3, array.Count); array.MinusSorted(array); Assert.AreEqual(0, array.Count); }
public void TestRBInsideBTree() { int test = 0; int maxCount = 1; //40 int attempts = 2; //7 while (true) { test++; TestKey keyFactory = new TestKey(); IBTree bTree = new /*BTree*/ OmniaMeaBTree(test.ToString() + ".btree_test", keyFactory); bTree.SetCacheSize(2); IntArrayList offsets = new IntArrayList(); maxCount++; if (maxCount > 40) { maxCount = 1; attempts++; } if (attempts > 3) { break; } Console.WriteLine("Attempts = " + attempts.ToString() + " maxCount = " + maxCount.ToString()); for (int j = 0; j < attempts; j++) { bTree.Open(); for (int i = 0; i < maxCount; i++) { bTree.InsertKey(new TestKey(i), i); offsets.Clear(); bTree.SearchForRange(new TestKey(i), new TestKey(i), offsets); Assert.AreEqual(1, offsets.Count); Assert.AreEqual(i, offsets[0]); offsets.Clear(); bTree.SearchForRange(new TestKey(0), new TestKey(maxCount), offsets); Assert.AreEqual(i + 1, offsets.Count); int expectedOffset = 0; foreach (int offset in offsets) { Assert.AreEqual(expectedOffset, offset); expectedOffset++; } } for (int i = 0; i < maxCount; i++) { bTree.DeleteKey(new TestKey(i), i); offsets.Clear(); bTree.SearchForRange(new TestKey(i), new TestKey(i), offsets); Assert.AreEqual(0, offsets.Count); offsets.Clear(); bTree.SearchForRange(new TestKey(0), new TestKey(maxCount), offsets); Assert.AreEqual(maxCount - i - 1, offsets.Count); int expectedOffset = 0; foreach (int offset in offsets) { Assert.AreEqual(expectedOffset + i + 1, offset); expectedOffset++; } } for (int i = maxCount; i > 0; i--) { bTree.InsertKey(new TestKey(i), i); offsets.Clear(); bTree.SearchForRange(new TestKey(i), new TestKey(i), offsets); Assert.AreEqual(1, offsets.Count); Assert.AreEqual(i, offsets[0]); offsets.Clear(); bTree.SearchForRange(new TestKey(0), new TestKey(maxCount), offsets); Assert.AreEqual(maxCount - i + 1, offsets.Count); int expectedOffset = i; foreach (int offset in offsets) { Assert.AreEqual(expectedOffset, offset); expectedOffset++; } } for (int i = maxCount; i > 0; i--) { bTree.DeleteKey(new TestKey(i), i); offsets.Clear(); bTree.SearchForRange(new TestKey(i), new TestKey(i), offsets); Assert.AreEqual(0, offsets.Count); offsets.Clear(); bTree.SearchForRange(new TestKey(0), new TestKey(maxCount), offsets); Assert.AreEqual(i - 1, offsets.Count); int expectedOffset = 0; foreach (int offset in offsets) { Assert.AreEqual(expectedOffset + 1, offset); expectedOffset++; } } bTree.Close(); } } }
/// <summary> /// Unserializes a BinaryStream into the Attributes of this Instance /// </summary> /// <param name="reader">The Stream that contains the FileData</param> public override void Unserialize(System.IO.BinaryReader reader) { version = reader.ReadUInt32(); string name = reader.ReadString(); uint myid = reader.ReadUInt32(); gb.Unserialize(reader); gb.BlockID = myid; int count = reader.ReadInt32(); v1.Clear(); for (int i = 0; i < count; i++) { Vector3f o = new Vector3f(); o.Unserialize(reader); v1.Add(o); } count = reader.ReadInt32(); v2.Clear(); for (int i = 0; i < count; i++) { Vector3f o = new Vector3f(); o.Unserialize(reader); v2.Add(o); } count = reader.ReadInt32(); v3.Clear(); for (int i = 0; i < count; i++) { Vector2f o = new Vector2f(); o.Unserialize(reader); v3.Add(o); } zero1 = reader.ReadBytes(zero1.Length); refcount = reader.ReadInt32(); u1 = reader.ReadInt32(); zero2 = reader.ReadBytes(zero2.Length); count = reader.ReadInt32(); v4.Clear(); for (int i = 0; i < count; i++) { Vector2f o = new Vector2f(); o.Unserialize(reader); v4.Add(o); } count = reader.ReadInt32(); v5.Clear(); for (int i = 0; i < count; i++) { Vector2f o = new Vector2f(); o.Unserialize(reader); v5.Add(o); } count = reader.ReadInt32(); v6.Clear(); for (int i = 0; i < count; i++) { Vector2f o = new Vector2f(); o.Unserialize(reader); v6.Add(o); } for (int i = 0; i < u2.Length; i++) { u2[i] = reader.ReadSingle(); } count = reader.ReadInt32(); mbi.Clear(); for (int i = 0; i < count; i++) { IndexedMeshBuilderItem o = new IndexedMeshBuilderItem(); o.Unserialize(reader); mbi.Add(o); } u3 = reader.ReadInt32(); u4 = reader.ReadInt32(); count = reader.ReadInt32(); ia1.Clear(); for (int i = 0; i < count; i++) { ia1.Add(reader.ReadInt32()); } count = reader.ReadInt32(); ia2.Clear(); for (int i = 0; i < count; i++) { ia2.Add(reader.ReadInt32()); } count = reader.ReadInt32(); ia3.Clear(); for (int i = 0; i < count; i++) { ia3.Add(reader.ReadInt32()); } count = reader.ReadInt32(); ia4.Clear(); for (int i = 0; i < count; i++) { ia4.Add(reader.ReadInt32()); } u5 = reader.ReadInt32(); u6 = reader.ReadInt32(); u7 = reader.ReadInt32(); u8 = reader.ReadInt32(); u9 = reader.ReadInt32(); u10 = reader.ReadInt32(); s1 = reader.ReadString(); }
public AnimationFrame[] GetFrames(bool exludelocked) { ArrayList tclist = new ArrayList(); Hashtable ht = new Hashtable(); ArrayList list = new ArrayList(); //get a List of all TimeCodes for (int i = 0; i < MaxAxisFrameCount; i++) { foreach (AnimationAxisTransformBlock ab in ab3) { IntArrayList tcs = ab.GetTimeCodes(true, true); if (ab.Locked && exludelocked && ab.Count <= 1) { tcs.Clear(); } foreach (int rtc in tcs) { short tc = (short)rtc; if (!tclist.Contains((short)tc)) { tclist.Add(tc); ht[tc] = new AnimationFrame(tc, this.TransformationType); } } } } tclist.Sort(); for (int part = 0; part < ab3.Length; part++) { AnimationAxisTransformBlock ab = ab3[part]; if (ab.Locked && exludelocked && ab.Count <= 1) { continue; } for (int i = 0; i < ab.Count; i++) { //if ((ab[i].Event && !events) || (!ab[i].Event && events)) continue; short tc = ab.GetTimeCode(i); AnimationFrame af = (AnimationFrame)ht[tc]; if (af != null) { if (part == 0) { af.XBlock = ab[i]; } else if (part == 1) { af.YBlock = ab[i]; } else if (part == 2) { af.ZBlock = ab[i]; } } } } //build ordered List foreach (short tc in tclist) { list.Add(ht[tc]); } AnimationFrame[] afs = new AnimationFrame[list.Count]; list.CopyTo(afs); return(afs); }