Feature#1
Open
victortwin wants to merge 3 commits intojava-online-course:masterjava-online-course/java-collections-template:masterfrom
Open
Feature#1victortwin wants to merge 3 commits intojava-online-course:masterjava-online-course/java-collections-template:masterfrom
victortwin wants to merge 3 commits intojava-online-course:masterjava-online-course/java-collections-template:masterfrom
Conversation
IliaIsakhin
reviewed
Dec 13, 2019
| @Override | ||
| public List<String> getWords(String text) { | ||
| return new ArrayList<>(); | ||
| return new ArrayList<>(Arrays.asList(text.split("\\W+"))); |
Collaborator
There was a problem hiding this comment.
Можно просто Arrays.asList(text.split("\\W+"))
IliaIsakhin
reviewed
Dec 13, 2019
| @Override | ||
| public List<String> sortWordsByLength(String text, Direction direction) { | ||
| return new ArrayList<>(); | ||
| ArrayList<String> allWords = (ArrayList<String>) getWords(text); |
Collaborator
There was a problem hiding this comment.
Зачем явно указывать ArrayList
IliaIsakhin
reviewed
Dec 13, 2019
| List<String> listOfWords = new ArrayList<>(); | ||
| String [] arrayOfWords = text.split("\\W+"); | ||
| Arrays.stream(arrayOfWords).forEach(listOfWords::add); | ||
| return listOfWords; |
Collaborator
There was a problem hiding this comment.
Stream.of(text.split("\W+").collect(Collectors.toList());
IliaIsakhin
reviewed
Dec 13, 2019
| Map<String, Integer> countWordsRepetitionsMap = new LinkedHashMap<>(); | ||
| for (String s : allWords) { | ||
| int repetitionCounter = Collections.frequency(allWords, s); | ||
| countWordsRepetitionsMap.put(s, repetitionCounter); |
Collaborator
There was a problem hiding this comment.
У тебя же это будет вызываться для каждой копии слова в листе слов?
Author
There was a problem hiding this comment.
Да, получается решение более медленное с точки зрения времени выполнения, но более быстрое для программиста :)
Author
There was a problem hiding this comment.
Наверное, надо было использовать список уникальных слов, а частоту их употребления собирать из списка всех слов.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.