public static void AddAndRemoveItem_NaturalSort()
        {
            var index = new SortedCollection <SqlObject, long>();

            index.InsertSort(566);
            index.InsertSort(54);
            index.InsertSort(902);

            Assert.True(index.RemoveSort(902));
            Assert.False(index.RemoveSort(102));
            Assert.False(index.RemoveSort(902));
        }
        public static void InsertSort_NoCompare()
        {
            var index = new SortedCollection <SqlObject, long>();

            index.InsertSort(6);

            Assert.Equal(1, index.Count);
        }
        public static void ContainsItem()
        {
            var index = new SortedCollection <SqlObject, long>();
            var items = new BigList <SqlObject>();

            items.Add(SqlObject.Integer(435));
            items.Add(SqlObject.Integer(1920));
            items.Add(SqlObject.Integer(9182));

            var comparer = new CollectionComparer(items);

            index.InsertSort(items[0], 0, comparer);
            index.InsertSort(items[1], 1, comparer);
            index.InsertSort(items[2], 2, comparer);

            Assert.True(index.Contains(SqlObject.Integer(435), comparer));
            Assert.False(index.Contains(SqlObject.Integer(21), comparer));
        }
        public static void CreateFromOtherIndex()
        {
            var index = new SortedCollection <SqlObject, long>();
            var items = new BigList <SqlObject>();

            items.Add(SqlObject.Integer(435));
            items.Add(SqlObject.Integer(1920));
            items.Add(SqlObject.Integer(9182));

            var comparer = new CollectionComparer(items);

            index.InsertSort(items[0], 0, comparer);
            index.InsertSort(items[1], 1, comparer);
            index.InsertSort(items[2], 2, comparer);

            var index2 = new SortedCollection <SqlObject, long>(index);

            Assert.Equal(index.Count, index2.Count);
        }
        public static void SearcLast_Sort()
        {
            var index = new SortedCollection <SqlObject, long>();
            var items = new BigList <SqlObject>();

            items.Add(SqlObject.Integer(435));
            items.Add(SqlObject.Integer(1920));
            items.Add(SqlObject.Integer(9182));

            var comparer = new CollectionComparer(items);

            index.InsertSort(items[0], 0, comparer);
            index.InsertSort(items[1], 1, comparer);
            index.InsertSort(items[2], 2, comparer);

            Assert.Equal(3, index.Count);

            var first = index.SearchLast(SqlObject.Integer(435), comparer);

            Assert.Equal(0, first);
        }
        public static void AddAndRemoveItem()
        {
            var index = new SortedCollection <SqlObject, long>();
            var items = new BigList <SqlObject>();

            items.Add(SqlObject.Integer(435));
            items.Add(SqlObject.Integer(1920));
            items.Add(SqlObject.Integer(9182));

            var comparer = new CollectionComparer(items);

            index.InsertSort(items[0], 0, comparer);
            index.InsertSort(items[1], 1, comparer);
            index.InsertSort(items[2], 2, comparer);

            Assert.Equal(3, index.Count);

            var value = index.RemoveSort(SqlObject.Integer(435), 0, comparer);

            Assert.Equal(0, value);
        }
        public static void InsertSort()
        {
            var index = new SortedCollection <SqlObject, long>();
            var items = new BigList <SqlObject>();

            items.Add(SqlObject.Integer(435));
            items.Add(SqlObject.Integer(1920));

            var comparer = new CollectionComparer(items);

            index.InsertSort(SqlObject.Double(2234.99), 45, comparer);

            Assert.Equal(1, index.Count);
        }
        private static void FillIndexWith(SortedCollection <SqlObject, long> index, int count)
        {
            var items = new BigList <SqlObject>();

            for (int i = 0; i < count; i++)
            {
                items.Add(SqlObject.Integer(i * 2));
            }

            var comparer = new CollectionComparer(items);

            for (int i = 0; i < items.Count; i++)
            {
                index.InsertSort(items[i], i, comparer);
            }
        }