public int addSorted(System.Object o) { //UPGRADE_TODO: The equivalent in .NET for method 'java.util.ArrayList.size' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"' int n = this.Count - 1; int i = 0; int idx = 0; bool insertBefore = true; while (i <= n) { idx = (n + i) >> 1; System.IComparable o1 = (System.IComparable) this[idx]; int rc = o1.CompareTo(o); if (rc > 0) { insertBefore = true; n = idx - 1; } else if (rc < 0) { i = idx + 1; insertBefore = false; } else { break; //values equal } } if (!insertBefore) { idx++; } this.Insert(idx, o); return(idx); }
public override bool check() { System.IComparable chk = (System.IComparable)IsoSwitchesManager.getInstance().getIsoSwitches().consultSwitch(id); if (chk == null) { return(false); } bool c = false; switch (comparationType) { case ComparationType.Equal: c = chk.CompareTo(value.Value) == 0; break; case ComparationType.Greather: c = chk.CompareTo(value.Value) > 0; break; case ComparationType.Less: c = chk.CompareTo(value.Value) < 0; break; case ComparationType.Distinct: c = chk.CompareTo(value.Value) != 0; break; case ComparationType.GreatherEqual: c = chk.CompareTo(value.Value) >= 0; break; case ComparationType.LessEqual: c = chk.CompareTo(value.Value) <= 0; break; } return(c); }
public override bool evaluate(System.Object object1, System.Object object2) { System.IComparable comp = (System.IComparable)object1; int val = comp.CompareTo(object2); return(val < 0); }
protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey) { Entry entry = (Entry)entryKey; System.String field = entry.field; SortComparator comparator = (SortComparator)entry.custom; System.IComparable[] retArray = new System.IComparable[reader.MaxDoc()]; TermDocs termDocs = reader.TermDocs(); TermEnum termEnum = reader.Terms(new Term(field)); try { do { Term term = termEnum.Term(); if (term == null || (System.Object)term.Field() != (System.Object)field) { break; } System.IComparable termval = comparator.GetComparable(term.Text()); termDocs.Seek(termEnum); while (termDocs.Next()) { retArray[termDocs.Doc()] = termval; } }while (termEnum.Next()); } finally { termDocs.Close(); termEnum.Close(); } return(retArray); }
/// <summary> Returns an array of objects which represent that natural order /// of the term values in the given Field. /// /// </summary> /// <param name="reader"> Terms are in this index. /// </param> /// <param name="enumerator">Use this to get the term values and TermDocs. /// </param> /// <param name="fieldname"> Comparables should be for this Field. /// </param> /// <returns> Array of objects representing natural order of terms in Field. /// </returns> /// <throws> IOException If an error occurs reading the index. </throws> protected internal virtual System.IComparable[] FillCache(IndexReader reader, TermEnum enumerator, System.String fieldname) { System.String field = String.Intern(fieldname); System.IComparable[] retArray = new System.IComparable[reader.MaxDoc()]; if (retArray.Length > 0) { TermDocs termDocs = reader.TermDocs(); try { if (enumerator.Term() == null) { throw new System.SystemException("no terms in Field " + field); } do { Term term = enumerator.Term(); if ((System.Object)term.Field() != (System.Object)field) { break; } System.IComparable termval = GetComparable(term.Text()); termDocs.Seek(enumerator); while (termDocs.Next()) { retArray[termDocs.Doc()] = termval; } }while (enumerator.Next()); } finally { termDocs.Close(); } } return(retArray); }
protected internal int countLessThan(System.IComparable value) { if (value == null) { throw new System.ArgumentException("This is bogus"); } return(countHelp(root, value)); }
public virtual bool evaluate(System.Object object1, System.Object object2) { //UPGRADE_NOTE: Final was removed from the declaration of 'comp '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'" System.IComparable comp = (System.IComparable)object1; //UPGRADE_NOTE: Final was removed from the declaration of 'val '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'" int val = comp.CompareTo(object2); return(val < 0); }
/// <summary> Given a queue Entry, creates a corresponding FieldDoc /// that contains the values used to sort the given document. /// These values are not the raw values out of the index, but the internal /// representation of them. This is so the given search hit can be collated by /// a MultiSearcher with other search hits. /// /// </summary> /// <param name="entry">The Entry used to create a FieldDoc /// </param> /// <returns> The newly created FieldDoc /// </returns> /// <seealso cref="Searchable.Search(Weight,Filter,int,Sort)"> /// </seealso> internal virtual FieldDoc FillFields(Entry entry) { int n = comparators.Length; System.IComparable[] fields = new System.IComparable[n]; for (int i = 0; i < n; ++i) { fields[i] = comparators[i][entry.slot]; } //if (maxscore > 1.0f) doc.score /= maxscore; // normalize scores return(new FieldDoc(entry.Doc, entry.Score, fields)); }
private int countHelp(BinaryTree.Node current, System.IComparable value) { if (current == null) { return(0); } if (current.value.CompareTo(value) > 0) { return(1 + countHelp(current.left, value) + countHelp(current.right, value)); } return(countHelp(current.left, value) + countHelp(current.right, value)); }
/// <summary> Given a FieldDoc object, stores the values used /// to sort the given document. These values are not the raw /// values out of the index, but the internal representation /// of them. This is so the given search hit can be collated /// by a MultiSearcher with other search hits. /// </summary> /// <param name="doc"> The FieldDoc to store sort values into. /// </param> /// <returns> The same FieldDoc passed in. /// </returns> /// <seealso cref="Searchable.Search(Weight,Filter,int,Sort)"> /// </seealso> internal virtual FieldDoc FillFields(FieldDoc doc) { int n = comparators.Length; System.IComparable[] fields = new System.IComparable[n]; for (int i = 0; i < n; ++i) { fields[i] = comparators[i].SortValue(doc); } doc.fields = fields; //if (maxscore > 1.0f) doc.score /= maxscore; // normalize scores return(doc); }
public virtual int Compare(object o1, object o2) { System.IComparable c1 = (System.IComparable) o1; System.IComparable c2 = (System.IComparable) o2; int cmp = c1.CompareTo(c2); // We cannot simply return -cmp, as -Integer.MinValue == Integer.MinValue. int bits = 1; if (cmp >= 0) return -(cmp >> bits); else return -((cmp >> bits) + (2 << ~bits)); // return -(cmp | (URShift(cmp, 1))); }
private int CompareList(System.Collections.ArrayList a_list, System.Collections.ArrayList b_list) { for (int i = 0; i < b_list.Count; i++) { System.IComparable a = (System.IComparable)a_list[i]; System.IComparable b = (System.IComparable)b_list[i]; int c = a.CompareTo(b); if (c != 0) { return(c); } } if (a_list.Count == b_list.Count) { return(0); } return(1); }
// inherit javadocs public virtual System.IComparable[] GetCustom(IndexReader reader, System.String field, SortComparator comparator) { field = String.Intern(field); System.Object ret = Lookup(reader, field, comparator); if (ret == null) { System.IComparable[] retArray = new System.IComparable[reader.MaxDoc()]; if (retArray.Length > 0) { TermDocs termDocs = reader.TermDocs(); TermEnum termEnum = reader.Terms(new Term(field, "")); try { if (termEnum.Term() == null) { throw new System.SystemException("no terms in field " + field); } do { Term term = termEnum.Term(); if (term.Field() != field) { break; } System.IComparable termval = comparator.GetComparable(term.Text()); termDocs.Seek(termEnum); while (termDocs.Next()) { retArray[termDocs.Doc()] = termval; } }while (termEnum.Next()); } finally { termDocs.Close(); termEnum.Close(); } } Store(reader, field, comparator, retArray); return(retArray); } return((System.IComparable[])ret); }
public static void BinaryInsert(this ArrayList self, System.IComparable element) { int min = 0; int max = self.Count - 1; while (min <= max) { int mid = (min + max) / 2; int comparison = element.CompareTo((System.IComparable)self[mid]); if (comparison < 0) { max = mid - 1; } else { min = mid + 1; } } self.Insert(min, element); }
static StackObject *CompareTo_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Object @obj = (System.Object) typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.IComparable instance_of_this_method = (System.IComparable) typeof(System.IComparable).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.CompareTo(@obj); __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method; return(__ret + 1); }
public void Sort(string key, bool ascending) { base.Sort(delegate(IHashMap obj1, IHashMap obj2) { System.IComparable value = obj1.GetValue <System.IComparable>(key); System.IComparable value2 = obj2.GetValue <System.IComparable>(key); int result; if (value == null) { result = (ascending ? -1 : 1); } else if (value2 == null) { result = (ascending ? 1 : -1); } else { result = (ascending ? value.CompareTo(value2) : value2.CompareTo(value)); } return(result); }); }
private void add(BinaryTree.Node current, System.IComparable value) { if (current == null) { root = new BinaryTree.Node(this, value); } else if (current.right == null) { current.right = new BinaryTree.Node(this, value); } else if (current.left == null) { current.left = new BinaryTree.Node(this, value); } else if (random.Next(2) == 0) { add(current.right, value); } else { add(current.left, value); } }
/// <summary> Given a FieldDoc object, stores the values used /// to sort the given document. These values are not the raw /// values out of the index, but the internal representation /// of them. This is so the given search hit can be collated /// by a MultiSearcher with other search hits. /// </summary> /// <param name="doc"> The FieldDoc to store sort values into. /// </param> /// <returns> The same FieldDoc passed in. /// </returns> /// <seealso cref="Searchable.Search(Weight,Filter,int,Sort)"> /// </seealso> internal virtual FieldDoc FillFields(FieldDoc doc) { int n = comparators.Length; System.IComparable[] fields = new System.IComparable[n]; for (int i = 0; i < n; ++i) fields[i] = comparators[i].SortValue(doc); doc.fields = fields; //if (maxscore > 1.0f) doc.score /= maxscore; // normalize scores return doc; }
// inherit javadocs public virtual System.IComparable[] GetCustom(IndexReader reader, System.String field, SortComparator comparator) { field = String.Intern(field); System.Object ret = Lookup(reader, field, comparator); if (ret == null) { System.IComparable[] retArray = new System.IComparable[reader.MaxDoc()]; if (retArray.Length > 0) { TermDocs termDocs = reader.TermDocs(); TermEnum termEnum = reader.Terms(new Term(field, "")); try { if (termEnum.Term() == null) { throw new System.SystemException("no terms in field " + field); } do { Term term = termEnum.Term(); if (term.Field() != field) break; System.IComparable termval = comparator.GetComparable(term.Text()); termDocs.Seek(termEnum); while (termDocs.Next()) { retArray[termDocs.Doc()] = termval; } } while (termEnum.Next()); } finally { termDocs.Close(); termEnum.Close(); } } Store(reader, field, comparator, retArray); return retArray; } return (System.IComparable[]) ret; }
public LessThanPredicate(int r_index, System.IComparable value) { this._r_index = r_index; this._value = value; }
/// <summary> Returns an array of objects which represent that natural order /// of the term values in the given field. /// /// </summary> /// <param name="reader"> Terms are in this index. /// </param> /// <param name="enumerator">Use this to get the term values and TermDocs. /// </param> /// <param name="fieldname"> Comparables should be for this field. /// </param> /// <returns> Array of objects representing natural order of terms in field. /// </returns> /// <throws> IOException If an error occurs reading the index. </throws> public static System.IComparable[] FillCache(IndexReader reader, TermEnum enumerator, System.String fieldname) { System.String field = String.Intern(fieldname); System.IComparable[] retArray = new System.IComparable[reader.MaxDoc()]; if (retArray.Length > 0) { TermDocs termDocs = reader.TermDocs(); try { if (enumerator.Term() == null) { throw new System.SystemException("no terms in field " + field); } do { Term term = enumerator.Term(); if (term.Field() != field) break; System.IComparable termval = GetComparable(term.Text()); termDocs.Seek(enumerator); while (termDocs.Next()) { retArray[termDocs.Doc()] = termval; } } while (enumerator.Next()); } finally { termDocs.Close(); } } return retArray; }
protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey) { Entry entry = (Entry) entryKey; System.String field = entry.field; SortComparator comparator = (SortComparator) entry.custom; System.IComparable[] retArray = new System.IComparable[reader.MaxDoc()]; TermDocs termDocs = reader.TermDocs(); TermEnum termEnum = reader.Terms(new Term(field)); try { do { Term term = termEnum.Term(); if (term == null || (System.Object) term.Field() != (System.Object) field) break; System.IComparable termval = comparator.GetComparable(term.Text()); termDocs.Seek(termEnum); while (termDocs.Next()) { retArray[termDocs.Doc()] = termval; } } while (termEnum.Next()); } finally { termDocs.Close(); termEnum.Close(); } return retArray; }
/// <summary>Execute query using index</summary> /// <param name="index"></param> /// <param name="inMemory"></param> /// <param name="startIndex"></param> /// <param name="endIndex"></param> /// <param name="returnObjects"></param> /// <returns></returns> /// <exception cref="System.Exception">System.Exception</exception> private NeoDatis.Odb.Objects <T> ExecuteUsingIndex <T>(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex index, bool inMemory, int startIndex, int endIndex, bool returnObjects, NeoDatis.Odb.Core.Query.Execution.IMatchingObjectAction queryResultAction) { // Index that have not been used yet do not have persister! if (index.GetBTree().GetPersister() == null) { index.GetBTree().SetPersister(new NeoDatis.Odb.Impl.Core.Btree.LazyODBBTreePersister (storageEngine)); } bool objectMatches = false; long nbObjects = classInfo.GetNumberOfObjects(); long btreeSize = index.GetBTree().GetSize(); // the two values should be equal if (nbObjects != btreeSize) { NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = storageEngine.GetSession(true ).GetMetaModel().GetClassInfoFromId(index.GetClassInfoId()); throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.IndexIsCorrupted .AddParameter(index.GetName()).AddParameter(ci.GetFullClassName()).AddParameter( nbObjects).AddParameter(btreeSize)); } if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId)) { NeoDatis.Tool.DLogger.Debug("loading " + nbObjects + " instance(s) of " + classInfo .GetFullClassName()); } if (ExecuteStartAndEndOfQueryAction()) { queryResultAction.Start(); } PrepareQuery(); if (query != null) { queryHasOrderBy = query.HasOrderBy(); } NeoDatis.Btree.IBTree tree = index.GetBTree(); bool isUnique = index.IsUnique(); // Iterator iterator = new BTreeIterator(tree, // OrderByConstants.ORDER_BY_ASC); System.IComparable key = ComputeIndexKey(classInfo, index); System.Collections.IList list = null; // If index is unique, get the object if (isUnique) { NeoDatis.Btree.IBTreeSingleValuePerKey treeSingle = (NeoDatis.Btree.IBTreeSingleValuePerKey )tree; object o = treeSingle.Search(key); if (o != null) { list = new System.Collections.ArrayList(); list.Add(o); } } else { NeoDatis.Btree.IBTreeMultipleValuesPerKey treeMultiple = (NeoDatis.Btree.IBTreeMultipleValuesPerKey )tree; list = treeMultiple.Search(key); } if (list != null) { System.Collections.IEnumerator iterator = list.GetEnumerator(); while (iterator.MoveNext()) { NeoDatis.Odb.OID oid = (NeoDatis.Odb.OID)iterator.Current; // FIXME Why calling this method long position = objectReader.GetObjectPositionFromItsOid(oid, true, true); orderByKey = null; objectMatches = MatchObjectWithOid(oid, returnObjects, inMemory); if (objectMatches) { queryResultAction.ObjectMatch(oid, GetCurrentObjectMetaRepresentation(), orderByKey ); } } queryResultAction.End(); return(queryResultAction.GetObjects <T>()); } if (ExecuteStartAndEndOfQueryAction()) { queryResultAction.End(); } return(queryResultAction.GetObjects <T>()); }
public GreaterThanPredicate(Bamboo.Query.Query.Column column, System.IComparable value) { this._column = column; this._value = value; }
public static System.IComparable ShouldBeGreaterThan(this System.IComparable arg1, System.IComparable arg2) { Assert.Equal(1, arg1.CompareTo(arg2)); return(arg2); }
public static System.IComparable ShouldBeLessThan(this System.IComparable arg1, System.IComparable arg2) { Assert.AreEqual(-1, arg1.CompareTo(arg2)); return(arg2); }
/// <summary> Given a queue Entry, creates a corresponding FieldDoc /// that contains the values used to sort the given document. /// These values are not the raw values out of the index, but the internal /// representation of them. This is so the given search hit can be collated by /// a MultiSearcher with other search hits. /// /// </summary> /// <param name="entry">The Entry used to create a FieldDoc /// </param> /// <returns> The newly created FieldDoc /// </returns> /// <seealso cref="Searchable.Search(Weight,Filter,int,Sort)"> /// </seealso> internal virtual FieldDoc FillFields(Entry entry) { int n = comparators.Length; System.IComparable[] fields = new System.IComparable[n]; for (int i = 0; i < n; ++i) { fields[i] = comparators[i].Value(entry.slot); } //if (maxscore > 1.0f) doc.score /= maxscore; // normalize scores return new FieldDoc(entry.docID, entry.score, fields); }
public void add(System.IComparable value) { add(root, value); }
internal Node(BinaryTree _enclosing, System.IComparable setValue) { this._enclosing = _enclosing; this.value = setValue; }
private static object ParseWherePredicate(System.Collections.ArrayList tokens, string from) { System.Text.StringBuilder Column = new System.Text.StringBuilder(); System.Text.StringBuilder Operator = new System.Text.StringBuilder(); System.Text.StringBuilder Value = new System.Text.StringBuilder(); System.Text.StringBuilder current = Column; for (int i = 0; i < tokens.Count; i++) { string token = (string)tokens[i]; if (token.Equals("=")) { Operator.Append(token); current = Value; } else if (token.Equals(">")) { Operator.Append(token); current = Value; } else if (token.Equals("<")) { Operator.Append(token); current = Value; } else if (token.Equals("<>")) { Operator.Append(token); current = Value; } else if (token.Equals("!=")) { Operator.Append(token); current = Value; } else { current.Append(token); } } object predicate = null; string column = Column.ToString(); string operator_ = Operator.ToString(); System.IComparable value = ParseAtom(Value.ToString()); if (operator_.Equals("=")) { predicate = new Bamboo.Query.Query.EqualsPredicate(CreateColumn(column, from), value); } else if (operator_.Equals(">")) { predicate = new Bamboo.Query.Query.GreaterThanPredicate(CreateColumn(column, from), value); } else if (operator_.Equals("<")) { predicate = new Bamboo.Query.Query.LessThanPredicate(CreateColumn(column, from), value); } else if (operator_.Equals("<>")) { predicate = new Bamboo.Query.Query.NotEqualsPredicate(CreateColumn(column, from), value); } else if (operator_.Equals("!=")) { predicate = new Bamboo.Query.Query.NotEqualsPredicate(CreateColumn(column, from), value); } else { throw new System.Exception("Invalid operator: " + operator_); } return(predicate); }