/**
 * --------------------------------------------------------------------
 * Copyright 2015 Nikolay Mavrenkov
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * --------------------------------------------------------------------
 * <p/>
 * Author:  Nikolay Mavrenkov <koluch@koluch.ru>
 * Created: 30.10.2015 01:11
 */
package ru.koluch.textWork.dictionary.prefixTree;


public class PrefixTree<T> {

    public PrefixTree[] branches;

    public T data;

    public PrefixTree(T data) {
        this.data = data;
    }

    public PrefixTree() {
    }

    public void add(String wordForm, T data) {
        if(wordForm.length()==0) {
            this.data = data;
        }
        else {
            char nextBranch = wordForm.charAt(0);

            int index;
            if(nextBranch=='ё') {
                index = 32;
            }
            else {
                if(nextBranch<'а' || nextBranch>'я') {
                    throw new IllegalArgumentException("Bad branch: '" + nextBranch + "' (allowed only russian letters)");
                }
                index = nextBranch - 'а';
            }
            String rest = wordForm.substring(1);
            if(this.branches==null) {
                this.branches = new PrefixTree[33];  // 33 letters in russian alphabet
            }

            PrefixTree<T> nextTree;
            if(this.branches[index]==null) {
                nextTree = new PrefixTree<T>();
                this.branches[index] = nextTree;
            }
            else {
                nextTree = this.branches[index];
            }
            nextTree.add(rest, data);
        }
    }
}

@@ -1258,17 +1258,16 @@
 rAt(0);%0A
-%0A
         
@@ -1310,12 +1310,35 @@
 anch
-=='%D1%91
+ %3E= '%D0%B0' && nextBranch %3C= '%D0%B5
 ') %7B
@@ -1366,10 +1366,24 @@
 x = 
-32
+nextBranch - '%D0%B0'
 ;%0A  
@@ -1415,28 +1415,104 @@
 lse 
-%7B%0A                if
+if (nextBranch=='%D1%91') %7B%0A                index = '%D0%B5' - '%D0%B0' + 1;%0A            %7D%0A            else if 
 (nex
@@ -1522,15 +1522,17 @@
 anch
-%3C'%D0%B0' %7C%7C
+ %3E '%D0%B5' &&
  nex
@@ -1538,17 +1538,20 @@
 xtBranch
-%3E
+ %3C= 
 '%D1%8F') %7B%0A 
@@ -1545,32 +1545,107 @@
 h %3C= '%D1%8F') %7B%0A    
+            index = nextBranch - '%D0%B0' + 1;%0A            %7D%0A            else %7B%0A
                 
@@ -1763,69 +1763,10 @@
     
-    %7D%0A                index = nextBranch - '%D0%B0';%0A            
 %7D
+%0A
 %0A   

Change indexing for 'ё'