Exemplo n.º 1
0
        public UnihanCharacterDataBuilder GetUnihan(int codePoint)
        {
            int index = FindUnihanCodePoint(codePoint);

            if (index >= 0)
            {
                return(unihanEntries[index]);
            }
            else
            {
                var data = new UnihanCharacterDataBuilder(codePoint);

                Insert(data);

                return(data);
            }
        }
Exemplo n.º 2
0
        private void Insert(UnihanCharacterDataBuilder data)
        {
            int insertionPoint = FindUnihanInsertionPoint(data.CodePoint);

            if (insertionPoint < 0)
            {
                throw new InvalidOperationException("The specified range overlaps with pre-existing ranges.");
            }

            if (unihanEntryCount == unihanEntries.Length)
            {
                Array.Resize(ref unihanEntries, unihanEntries.Length << 1);
            }

            if (insertionPoint < unihanEntryCount)
            {
                Array.Copy(unihanEntries, insertionPoint, unihanEntries, insertionPoint + 1, unihanEntryCount - insertionPoint);
            }

            unihanEntries[insertionPoint] = data;
            ++unihanEntryCount;
        }