18 using System.Collections.Generic;
23 namespace Deveel.Data.Index {
34 : base(table, columnOffset) {
40 : this(table, columnOffset) {
42 foreach (var item
in list) {
49 : this(table, source.ColumnOffset, source.list) {
50 this.readOnly = readOnly;
53 readOnlyCount = list.Count;
60 public override bool IsReadOnly {
61 get {
return readOnly; }
64 protected override int Count {
65 get {
return list.Count; }
68 public override string IndexType {
73 get {
return GetValue(list[0]); }
77 get {
return GetValue(list[list.Count - 1]); }
80 internal bool RecordUid {
get; set; }
82 public override void Insert(
int rowNumber) {
84 throw new InvalidOperationException(
"Tried to change an read-only index.");
86 var value = GetValue(rowNumber);
87 list.InsertSort(value, rowNumber, comparer);
90 public override void Remove(
int rowNumber) {
92 throw new InvalidOperationException(
"Tried to change an read-only index.");
94 var value = GetValue(rowNumber);
95 var removed = list.RemoveSort(value, rowNumber, comparer);
97 if (removed != rowNumber)
98 throw new InvalidOperationException(String.Format(
"Could not remove the requested row ({0})", rowNumber));
101 protected override IEnumerable<int>
AddRange(
int start,
int end, IEnumerable<int> input) {
102 var result =
new List<int>();
104 result.AddRange(input);
106 var en = list.GetEnumerator(start, end);
107 while (en.MoveNext()) {
108 result.Add(en.Current);
111 return result.ToArray();
117 if (IsReadOnly && readOnlyCount != list.Count)
118 throw new InvalidOperationException(
"Assert failed: read-only size is different from when created.");
126 return list.SearchFirst(value, comparer);
130 return list.SearchLast(value, comparer);
133 protected override void Dispose(
bool disposing) {
138 #region IndexComparerImpl
144 this.columnIndex = columnIndex;
148 var cell = columnIndex.GetValue(index);
149 var cmp = cell.CompareTo(value);
154 return InternalCompare(index, val);
158 var cell = columnIndex.GetValue(index2);
159 return InternalCompare(index1, cell);
Defines the contract to access the data contained into a table of a database.
InsertSearchIndex(ITable table, int columnOffset)
IIndexComparer< int > comparer
override IEnumerable< int > AddRange(int start, int end, IEnumerable< int > input)
readonly InsertSearchIndex columnIndex
IndexComparerImpl(InsertSearchIndex columnIndex)
const string InsertSearch
override void Remove(int rowNumber)
int InternalCompare(int index, DataObject value)
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
InsertSearchIndex(ITable table, InsertSearchIndex source, bool readOnly)
override void Dispose(bool disposing)
override ColumnIndex Copy(ITable table, bool readOnly)
readonly int readOnlyCount
int CompareValue(int index, DataObject val)
override int SearchFirst(DataObject value)
override void Insert(int rowNumber)
override int SearchLast(DataObject value)
InsertSearchIndex(ITable table, int columnOffset, IEnumerable< int > list)
int Compare(int index1, int index2)