/// <summary> Look up a reference by kernel. /// Use a binary search on the ordered list of known references. /// Since the binary search returns the position at which a new item should /// be inserted, we check the references earlier in the list if there is /// a failure. /// </summary> /// <param name="key">A character reference with the kernel set to the string /// to be found. It need not be truncated at the exact end of the reference. /// </param> protected internal static CharacterReference LookUp(CharacterReference key) { System.String string_Renamed; int index; System.String kernel; char character; CharacterReference test; CharacterReference ret; // Care should be taken here because some entity references are // prefixes of others, i.e.: // \u2209[notin] \u00ac[not] // \u00ba[ordm] \u2228[or] // \u03d6[piv] \u03c0[pi] // \u00b3[sup3] \u2283[sup] ret = null; index = SortImpl.Bsearch(mCharacterReferences, key); string_Renamed = key.Kernel; if (index < mCharacterReferences.Length) { ret = mCharacterReferences[index]; kernel = ret.Kernel; //if (!(String.Compare(string_Renamed, 0, kernel, 0, kernel.Length) == 0)) if (!(PlatformTools.CompareStr(string_Renamed, 0, kernel, 0, kernel.Length) == 0)) { // not exact, check references starting with same character // to see if a subset matches ret = null; } } if (null == ret) { character = string_Renamed[0]; while (--index >= 0) { test = mCharacterReferences[index]; kernel = test.Kernel; if (character == kernel[0]) { //if (String.Compare(string_Renamed, 0, kernel, 0, kernel.Length) == 0) if (PlatformTools.CompareStr(string_Renamed, 0, kernel, 0, kernel.Length) == 0) { ret = test; break; } } else { break; } } } return(ret); }
/// <summary> Remove an element from the list</summary> /// <param name="cursor">The element to remove. /// </param> public virtual void Remove(Cursor cursor) { int i; // find it i = SortImpl.Bsearch(this, cursor); // remove if ((i < Size()) && (cursor.Position == mIndices[i])) { RemoveElementAt(i); } }
/// <summary> Get the line number for a cursor.</summary> /// <param name="cursor">The character offset into the page. /// </param> /// <returns> The line number the character is in. /// </returns> public virtual int Row(Cursor cursor) { int ret; ret = SortImpl.Bsearch(this, cursor); // handle line transition, the search returns the index if it matches // exactly one of the line end positions, so we advance one line if // it's equal to the offset at the row index, since that position is // actually the beginning of the next line if ((ret < mCount) && (cursor.Position == mIndices[ret])) { ret++; } return(ret); }
/// <summary> Add an element to the list</summary> /// <param name="cursor">The element to add. /// </param> /// <returns> The position at which the element was inserted or /// the index of the existing element if it is a duplicate. /// </returns> public virtual int Add(Cursor cursor) { int position; int last; int ret; position = cursor.Position; if (0 == mCount) { ret = 0; InsertElementAt(position, ret); } else { last = mIndices[mCount - 1]; if (position == last) { ret = mCount - 1; } else if (position > last) { ret = mCount; InsertElementAt(position, ret); } else { // find where it goes ret = SortImpl.Bsearch(this, cursor); // insert, but not twice if (!((ret < Size()) && (position == mIndices[ret]))) { InsertElementAt(position, ret); } } } return(ret); }
/// <summary> Binary search for the element.</summary> /// <param name="cursor">The element to search for. /// </param> /// <param name="first">The index to start at. /// </param> /// <param name="last">The index to stop at. /// </param> /// <returns> The index at which the element was found or is to be inserted. /// </returns> protected internal virtual int Bsearch(int cursor, int first, int last) { return(SortImpl.Bsearch(this, new Cursor(Page, cursor), first, last)); }
/// <summary> Binary search for the element.</summary> /// <param name="cursor">The element to search for. /// </param> /// <returns> The index at which the element was found or is to be inserted. /// </returns> protected internal virtual int Bsearch(int cursor) { return(SortImpl.Bsearch(this, new Cursor(Page, cursor))); }
static Translate() { Int32 idx = 0; mCharacterReferences = new CharacterReference[252]; mCharacterReferences[idx++] = new CharacterReference("nbsp", '\u00a0'); mCharacterReferences[idx++] = new CharacterReference("iexcl", '\u00a1'); mCharacterReferences[idx++] = new CharacterReference("cent", '\u00a2'); mCharacterReferences[idx++] = new CharacterReference("pound", '\u00a3'); mCharacterReferences[idx++] = new CharacterReference("curren", '\u00a4'); mCharacterReferences[idx++] = new CharacterReference("yen", '\u00a5'); mCharacterReferences[idx++] = new CharacterReference("brvbar", '\u00a6'); mCharacterReferences[idx++] = new CharacterReference("sect", '\u00a7'); mCharacterReferences[idx++] = new CharacterReference("uml", '\u00a8'); mCharacterReferences[idx++] = new CharacterReference("copy", '\u00a9'); mCharacterReferences[idx++] = new CharacterReference("ordf", '\u00aa'); mCharacterReferences[idx++] = new CharacterReference("laquo", '\u00ab'); mCharacterReferences[idx++] = new CharacterReference("not", '\u00ac'); mCharacterReferences[idx++] = new CharacterReference("shy", '\u00ad'); mCharacterReferences[idx++] = new CharacterReference("reg", '\u00ae'); mCharacterReferences[idx++] = new CharacterReference("macr", '\u00af'); mCharacterReferences[idx++] = new CharacterReference("deg", '\u00b0'); mCharacterReferences[idx++] = new CharacterReference("plusmn", '\u00b1'); mCharacterReferences[idx++] = new CharacterReference("sup2", '\u00b2'); mCharacterReferences[idx++] = new CharacterReference("sup3", '\u00b3'); mCharacterReferences[idx++] = new CharacterReference("acute", '\u00b4'); mCharacterReferences[idx++] = new CharacterReference("micro", '\u00b5'); mCharacterReferences[idx++] = new CharacterReference("para", '\u00b6'); mCharacterReferences[idx++] = new CharacterReference("middot", '\u00b7'); mCharacterReferences[idx++] = new CharacterReference("cedil", '\u00b8'); mCharacterReferences[idx++] = new CharacterReference("sup1", '\u00b9'); mCharacterReferences[idx++] = new CharacterReference("ordm", '\u00ba'); mCharacterReferences[idx++] = new CharacterReference("raquo", '\u00bb'); mCharacterReferences[idx++] = new CharacterReference("frac14", '\u00bc'); mCharacterReferences[idx++] = new CharacterReference("frac12", '\u00bd'); mCharacterReferences[idx++] = new CharacterReference("frac34", '\u00be'); mCharacterReferences[idx++] = new CharacterReference("iquest", '\u00bf'); mCharacterReferences[idx++] = new CharacterReference("Agrave", '\u00c0'); mCharacterReferences[idx++] = new CharacterReference("Aacute", '\u00c1'); mCharacterReferences[idx++] = new CharacterReference("Acirc", '\u00c2'); mCharacterReferences[idx++] = new CharacterReference("Atilde", '\u00c3'); mCharacterReferences[idx++] = new CharacterReference("Auml", '\u00c4'); mCharacterReferences[idx++] = new CharacterReference("Aring", '\u00c5'); mCharacterReferences[idx++] = new CharacterReference("AElig", '\u00c6'); mCharacterReferences[idx++] = new CharacterReference("Ccedil", '\u00c7'); mCharacterReferences[idx++] = new CharacterReference("Egrave", '\u00c8'); mCharacterReferences[idx++] = new CharacterReference("Eacute", '\u00c9'); mCharacterReferences[idx++] = new CharacterReference("Ecirc", '\u00ca'); mCharacterReferences[idx++] = new CharacterReference("Euml", '\u00cb'); mCharacterReferences[idx++] = new CharacterReference("Igrave", '\u00cc'); mCharacterReferences[idx++] = new CharacterReference("Iacute", '\u00cd'); mCharacterReferences[idx++] = new CharacterReference("Icirc", '\u00ce'); mCharacterReferences[idx++] = new CharacterReference("Iuml", '\u00cf'); mCharacterReferences[idx++] = new CharacterReference("ETH", '\u00d0'); mCharacterReferences[idx++] = new CharacterReference("Ntilde", '\u00d1'); mCharacterReferences[idx++] = new CharacterReference("Ograve", '\u00d2'); mCharacterReferences[idx++] = new CharacterReference("Oacute", '\u00d3'); mCharacterReferences[idx++] = new CharacterReference("Ocirc", '\u00d4'); mCharacterReferences[idx++] = new CharacterReference("Otilde", '\u00d5'); mCharacterReferences[idx++] = new CharacterReference("Ouml", '\u00d6'); mCharacterReferences[idx++] = new CharacterReference("times", '\u00d7'); mCharacterReferences[idx++] = new CharacterReference("Oslash", '\u00d8'); mCharacterReferences[idx++] = new CharacterReference("Ugrave", '\u00d9'); mCharacterReferences[idx++] = new CharacterReference("Uacute", '\u00da'); mCharacterReferences[idx++] = new CharacterReference("Ucirc", '\u00db'); mCharacterReferences[idx++] = new CharacterReference("Uuml", '\u00dc'); mCharacterReferences[idx++] = new CharacterReference("Yacute", '\u00dd'); mCharacterReferences[idx++] = new CharacterReference("THORN", '\u00de'); mCharacterReferences[idx++] = new CharacterReference("szlig", '\u00df'); mCharacterReferences[idx++] = new CharacterReference("agrave", '\u00e0'); mCharacterReferences[idx++] = new CharacterReference("aacute", '\u00e1'); mCharacterReferences[idx++] = new CharacterReference("acirc", '\u00e2'); mCharacterReferences[idx++] = new CharacterReference("atilde", '\u00e3'); mCharacterReferences[idx++] = new CharacterReference("auml", '\u00e4'); mCharacterReferences[idx++] = new CharacterReference("aring", '\u00e5'); mCharacterReferences[idx++] = new CharacterReference("aelig", '\u00e6'); mCharacterReferences[idx++] = new CharacterReference("ccedil", '\u00e7'); mCharacterReferences[idx++] = new CharacterReference("egrave", '\u00e8'); mCharacterReferences[idx++] = new CharacterReference("eacute", '\u00e9'); mCharacterReferences[idx++] = new CharacterReference("ecirc", '\u00ea'); mCharacterReferences[idx++] = new CharacterReference("euml", '\u00eb'); mCharacterReferences[idx++] = new CharacterReference("igrave", '\u00ec'); mCharacterReferences[idx++] = new CharacterReference("iacute", '\u00ed'); mCharacterReferences[idx++] = new CharacterReference("icirc", '\u00ee'); mCharacterReferences[idx++] = new CharacterReference("iuml", '\u00ef'); mCharacterReferences[idx++] = new CharacterReference("eth", '\u00f0'); mCharacterReferences[idx++] = new CharacterReference("ntilde", '\u00f1'); mCharacterReferences[idx++] = new CharacterReference("ograve", '\u00f2'); mCharacterReferences[idx++] = new CharacterReference("oacute", '\u00f3'); mCharacterReferences[idx++] = new CharacterReference("ocirc", '\u00f4'); mCharacterReferences[idx++] = new CharacterReference("otilde", '\u00f5'); mCharacterReferences[idx++] = new CharacterReference("ouml", '\u00f6'); mCharacterReferences[idx++] = new CharacterReference("divide", '\u00f7'); mCharacterReferences[idx++] = new CharacterReference("oslash", '\u00f8'); mCharacterReferences[idx++] = new CharacterReference("ugrave", '\u00f9'); mCharacterReferences[idx++] = new CharacterReference("uacute", '\u00fa'); mCharacterReferences[idx++] = new CharacterReference("ucirc", '\u00fb'); mCharacterReferences[idx++] = new CharacterReference("uuml", '\u00fc'); mCharacterReferences[idx++] = new CharacterReference("yacute", '\u00fd'); mCharacterReferences[idx++] = new CharacterReference("thorn", '\u00fe'); mCharacterReferences[idx++] = new CharacterReference("yuml", '\u00ff'); mCharacterReferences[idx++] = new CharacterReference("fnof", '\u0192'); mCharacterReferences[idx++] = new CharacterReference("Alpha", '\u0391'); mCharacterReferences[idx++] = new CharacterReference("Beta", '\u0392'); mCharacterReferences[idx++] = new CharacterReference("Gamma", '\u0393'); mCharacterReferences[idx++] = new CharacterReference("Delta", '\u0394'); mCharacterReferences[idx++] = new CharacterReference("Epsilon", '\u0395'); mCharacterReferences[idx++] = new CharacterReference("Zeta", '\u0396'); mCharacterReferences[idx++] = new CharacterReference("Eta", '\u0397'); mCharacterReferences[idx++] = new CharacterReference("Theta", '\u0398'); mCharacterReferences[idx++] = new CharacterReference("Iota", '\u0399'); mCharacterReferences[idx++] = new CharacterReference("Kappa", '\u039a'); mCharacterReferences[idx++] = new CharacterReference("Lambda", '\u039b'); mCharacterReferences[idx++] = new CharacterReference("Mu", '\u039c'); mCharacterReferences[idx++] = new CharacterReference("Nu", '\u039d'); mCharacterReferences[idx++] = new CharacterReference("Xi", '\u039e'); mCharacterReferences[idx++] = new CharacterReference("Omicron", '\u039f'); mCharacterReferences[idx++] = new CharacterReference("Pi", '\u03a0'); mCharacterReferences[idx++] = new CharacterReference("Rho", '\u03a1'); mCharacterReferences[idx++] = new CharacterReference("Sigma", '\u03a3'); mCharacterReferences[idx++] = new CharacterReference("Tau", '\u03a4'); mCharacterReferences[idx++] = new CharacterReference("Upsilon", '\u03a5'); mCharacterReferences[idx++] = new CharacterReference("Phi", '\u03a6'); mCharacterReferences[idx++] = new CharacterReference("Chi", '\u03a7'); mCharacterReferences[idx++] = new CharacterReference("Psi", '\u03a8'); mCharacterReferences[idx++] = new CharacterReference("Omega", '\u03a9'); mCharacterReferences[idx++] = new CharacterReference("alpha", '\u03b1'); mCharacterReferences[idx++] = new CharacterReference("beta", '\u03b2'); mCharacterReferences[idx++] = new CharacterReference("gamma", '\u03b3'); mCharacterReferences[idx++] = new CharacterReference("delta", '\u03b4'); mCharacterReferences[idx++] = new CharacterReference("epsilon", '\u03b5'); mCharacterReferences[idx++] = new CharacterReference("zeta", '\u03b6'); mCharacterReferences[idx++] = new CharacterReference("eta", '\u03b7'); mCharacterReferences[idx++] = new CharacterReference("theta", '\u03b8'); mCharacterReferences[idx++] = new CharacterReference("iota", '\u03b9'); mCharacterReferences[idx++] = new CharacterReference("kappa", '\u03ba'); mCharacterReferences[idx++] = new CharacterReference("lambda", '\u03bb'); mCharacterReferences[idx++] = new CharacterReference("mu", '\u03bc'); mCharacterReferences[idx++] = new CharacterReference("nu", '\u03bd'); mCharacterReferences[idx++] = new CharacterReference("xi", '\u03be'); mCharacterReferences[idx++] = new CharacterReference("omicron", '\u03bf'); mCharacterReferences[idx++] = new CharacterReference("pi", '\u03c0'); mCharacterReferences[idx++] = new CharacterReference("rho", '\u03c1'); mCharacterReferences[idx++] = new CharacterReference("sigmaf", '\u03c2'); mCharacterReferences[idx++] = new CharacterReference("sigma", '\u03c3'); mCharacterReferences[idx++] = new CharacterReference("tau", '\u03c4'); mCharacterReferences[idx++] = new CharacterReference("upsilon", '\u03c5'); mCharacterReferences[idx++] = new CharacterReference("phi", '\u03c6'); mCharacterReferences[idx++] = new CharacterReference("chi", '\u03c7'); mCharacterReferences[idx++] = new CharacterReference("psi", '\u03c8'); mCharacterReferences[idx++] = new CharacterReference("omega", '\u03c9'); mCharacterReferences[idx++] = new CharacterReference("thetasym", '\u03d1'); mCharacterReferences[idx++] = new CharacterReference("upsih", '\u03d2'); mCharacterReferences[idx++] = new CharacterReference("piv", '\u03d6'); mCharacterReferences[idx++] = new CharacterReference("bull", '\u2022'); mCharacterReferences[idx++] = new CharacterReference("hellip", '\u2026'); mCharacterReferences[idx++] = new CharacterReference("prime", '\u2032'); mCharacterReferences[idx++] = new CharacterReference("Prime", '\u2033'); mCharacterReferences[idx++] = new CharacterReference("oline", '\u203e'); mCharacterReferences[idx++] = new CharacterReference("frasl", '\u2044'); mCharacterReferences[idx++] = new CharacterReference("weierp", '\u2118'); mCharacterReferences[idx++] = new CharacterReference("image", '\u2111'); mCharacterReferences[idx++] = new CharacterReference("real", '\u211c'); mCharacterReferences[idx++] = new CharacterReference("trade", '\u2122'); mCharacterReferences[idx++] = new CharacterReference("alefsym", '\u2135'); mCharacterReferences[idx++] = new CharacterReference("larr", '\u2190'); mCharacterReferences[idx++] = new CharacterReference("uarr", '\u2191'); mCharacterReferences[idx++] = new CharacterReference("rarr", '\u2192'); mCharacterReferences[idx++] = new CharacterReference("darr", '\u2193'); mCharacterReferences[idx++] = new CharacterReference("harr", '\u2194'); mCharacterReferences[idx++] = new CharacterReference("crarr", '\u21b5'); mCharacterReferences[idx++] = new CharacterReference("lArr", '\u21d0'); mCharacterReferences[idx++] = new CharacterReference("uArr", '\u21d1'); mCharacterReferences[idx++] = new CharacterReference("rArr", '\u21d2'); mCharacterReferences[idx++] = new CharacterReference("dArr", '\u21d3'); mCharacterReferences[idx++] = new CharacterReference("hArr", '\u21d4'); mCharacterReferences[idx++] = new CharacterReference("forall", '\u2200'); mCharacterReferences[idx++] = new CharacterReference("part", '\u2202'); mCharacterReferences[idx++] = new CharacterReference("exist", '\u2203'); mCharacterReferences[idx++] = new CharacterReference("empty", '\u2205'); mCharacterReferences[idx++] = new CharacterReference("nabla", '\u2207'); mCharacterReferences[idx++] = new CharacterReference("isin", '\u2208'); mCharacterReferences[idx++] = new CharacterReference("notin", '\u2209'); mCharacterReferences[idx++] = new CharacterReference("ni", '\u220b'); mCharacterReferences[idx++] = new CharacterReference("prod", '\u220f'); mCharacterReferences[idx++] = new CharacterReference("sum", '\u2211'); mCharacterReferences[idx++] = new CharacterReference("minus", '\u2212'); mCharacterReferences[idx++] = new CharacterReference("lowast", '\u2217'); mCharacterReferences[idx++] = new CharacterReference("radic", '\u221a'); mCharacterReferences[idx++] = new CharacterReference("prop", '\u221d'); mCharacterReferences[idx++] = new CharacterReference("infin", '\u221e'); mCharacterReferences[idx++] = new CharacterReference("ang", '\u2220'); mCharacterReferences[idx++] = new CharacterReference("and", '\u2227'); mCharacterReferences[idx++] = new CharacterReference("or", '\u2228'); mCharacterReferences[idx++] = new CharacterReference("cap", '\u2229'); mCharacterReferences[idx++] = new CharacterReference("cup", '\u222a'); mCharacterReferences[idx++] = new CharacterReference("int", '\u222b'); mCharacterReferences[idx++] = new CharacterReference("there4", '\u2234'); mCharacterReferences[idx++] = new CharacterReference("sim", '\u223c'); mCharacterReferences[idx++] = new CharacterReference("cong", '\u2245'); mCharacterReferences[idx++] = new CharacterReference("asymp", '\u2248'); mCharacterReferences[idx++] = new CharacterReference("ne", '\u2260'); mCharacterReferences[idx++] = new CharacterReference("equiv", '\u2261'); mCharacterReferences[idx++] = new CharacterReference("le", '\u2264'); mCharacterReferences[idx++] = new CharacterReference("ge", '\u2265'); mCharacterReferences[idx++] = new CharacterReference("sub", '\u2282'); mCharacterReferences[idx++] = new CharacterReference("sup", '\u2283'); mCharacterReferences[idx++] = new CharacterReference("nsub", '\u2284'); mCharacterReferences[idx++] = new CharacterReference("sube", '\u2286'); mCharacterReferences[idx++] = new CharacterReference("supe", '\u2287'); mCharacterReferences[idx++] = new CharacterReference("oplus", '\u2295'); mCharacterReferences[idx++] = new CharacterReference("otimes", '\u2297'); mCharacterReferences[idx++] = new CharacterReference("perp", '\u22a5'); mCharacterReferences[idx++] = new CharacterReference("sdot", '\u22c5'); mCharacterReferences[idx++] = new CharacterReference("lceil", '\u2308'); mCharacterReferences[idx++] = new CharacterReference("rceil", '\u2309'); mCharacterReferences[idx++] = new CharacterReference("lfloor", '\u230a'); mCharacterReferences[idx++] = new CharacterReference("rfloor", '\u230b'); mCharacterReferences[idx++] = new CharacterReference("lang", '\u2329'); mCharacterReferences[idx++] = new CharacterReference("rang", '\u232a'); mCharacterReferences[idx++] = new CharacterReference("loz", '\u25ca'); mCharacterReferences[idx++] = new CharacterReference("spades", '\u2660'); mCharacterReferences[idx++] = new CharacterReference("clubs", '\u2663'); mCharacterReferences[idx++] = new CharacterReference("hearts", '\u2665'); mCharacterReferences[idx++] = new CharacterReference("diams", '\u2666'); mCharacterReferences[idx++] = new CharacterReference("quot", '\u0022'); mCharacterReferences[idx++] = new CharacterReference("amp", '\u0026'); mCharacterReferences[idx++] = new CharacterReference("lt", '\u003c'); mCharacterReferences[idx++] = new CharacterReference("gt", '\u003e'); mCharacterReferences[idx++] = new CharacterReference("OElig", '\u0152'); mCharacterReferences[idx++] = new CharacterReference("oelig", '\u0153'); mCharacterReferences[idx++] = new CharacterReference("Scaron", '\u0160'); mCharacterReferences[idx++] = new CharacterReference("scaron", '\u0161'); mCharacterReferences[idx++] = new CharacterReference("Yuml", '\u0178'); mCharacterReferences[idx++] = new CharacterReference("circ", '\u02c6'); mCharacterReferences[idx++] = new CharacterReference("tilde", '\u02dc'); mCharacterReferences[idx++] = new CharacterReference("ensp", '\u2002'); mCharacterReferences[idx++] = new CharacterReference("emsp", '\u2003'); mCharacterReferences[idx++] = new CharacterReference("thinsp", '\u2009'); mCharacterReferences[idx++] = new CharacterReference("zwnj", '\u200c'); mCharacterReferences[idx++] = new CharacterReference("zwj", '\u200d'); mCharacterReferences[idx++] = new CharacterReference("lrm", '\u200e'); mCharacterReferences[idx++] = new CharacterReference("rlm", '\u200f'); mCharacterReferences[idx++] = new CharacterReference("ndash", '\u2013'); mCharacterReferences[idx++] = new CharacterReference("mdash", '\u2014'); mCharacterReferences[idx++] = new CharacterReference("lsquo", '\u2018'); mCharacterReferences[idx++] = new CharacterReference("rsquo", '\u2019'); mCharacterReferences[idx++] = new CharacterReference("sbquo", '\u201a'); mCharacterReferences[idx++] = new CharacterReference("ldquo", '\u201c'); mCharacterReferences[idx++] = new CharacterReference("rdquo", '\u201d'); mCharacterReferences[idx++] = new CharacterReference("bdquo", '\u201e'); mCharacterReferences[idx++] = new CharacterReference("dagger", '\u2020'); mCharacterReferences[idx++] = new CharacterReference("Dagger", '\u2021'); mCharacterReferences[idx++] = new CharacterReference("permil", '\u2030'); mCharacterReferences[idx++] = new CharacterReference("lsaquo", '\u2039'); mCharacterReferences[idx++] = new CharacterReference("rsaquo", '\u203a'); mCharacterReferences[idx++] = new CharacterReference("euro", '\u20ac'); int index; CharacterReference item; int character; // count below the break point index = 0; for (int i = 0; i < mCharacterReferences.Length; i++) { if (mCharacterReferences[i].Character < BREAKPOINT) { index++; } } // allocate enough for the linear table and remainder mCharacterList = new CharacterReference[BREAKPOINT + mCharacterReferences.Length - index]; index = BREAKPOINT; for (int i = 0; i < mCharacterReferences.Length; i++) { item = mCharacterReferences[i]; character = mCharacterReferences[i].Character; if (character < BREAKPOINT) { mCharacterList[character] = item; } else { // use a linear search and insertion sort, done only once int x = BREAKPOINT; while (x < index) { if (mCharacterList[x].Character > character) { break; } else { x++; } } int y = index - 1; while (y >= x) { mCharacterList[y + 1] = mCharacterList[y]; y--; } mCharacterList[x] = item; index++; } } // reorder the original array into kernel order SortImpl.QuickSort(mCharacterReferences); }