diff --git a/src/main/java/dev/kalenchukov/alphabet/AbstractAlphabet.java b/src/main/java/dev/kalenchukov/alphabet/AbstractAlphabet.java index 20c313f..ed7bdfd 100644 --- a/src/main/java/dev/kalenchukov/alphabet/AbstractAlphabet.java +++ b/src/main/java/dev/kalenchukov/alphabet/AbstractAlphabet.java @@ -161,7 +161,13 @@ protected Integer getPosition(@NotNull final List<@NotNull Character> alphabet, @Override public List<@NotNull Character> getLettersReverse() { - return Collections.unmodifiableList(this.getLettersReverse(this.letters)); + List alphabetReverse = new ArrayList<>(this.letters.size()); + + for (int i = this.letters.size() - 1; i >= 0; i--) { + alphabetReverse.add(this.letters.get(i)); + } + + return Collections.unmodifiableList(alphabetReverse); } /** @@ -190,22 +196,4 @@ protected Integer getPosition(@NotNull final List<@NotNull Character> alphabet, return Collections.unmodifiableList(letters); } - - /** - * Возвращает буквы алфавита в обратном порядке. - * - * @param alphabet Алфавит. - * @return Коллекция букв алфавита. - */ - @NotNull - protected List<@NotNull Character> getLettersReverse(@NotNull final List<@NotNull Character> alphabet) - { - List alphabetReverse = new ArrayList<>(alphabet.size()); - - for (int i = alphabet.size() - 1; i >= 0; i--) { - alphabetReverse.add(alphabet.get(i)); - } - - return alphabetReverse; - } }