Example #1
0
  public void useSource(CharGenerator dsource) {

    // Set up the initial key
    String key = "";
    for (int i = 0; i < ngram; i++) {
      if (!dsource.hasNextChar()) return;
      key = key + alphabet[dsource.nextChar()];
    }

    while (true) {
      addKey(key);

      if (!dsource.hasNextChar()) break;
      key = key + alphabet[dsource.nextChar()];
      key = key.substring(1);
    }
  }