Skip to content

Trie initial commit.#2

Open
ASGusev wants to merge 1 commit intomasterfrom
trie
Open

Trie initial commit.#2
ASGusev wants to merge 1 commit intomasterfrom
trie

Conversation

@ASGusev
Copy link
Owner

@ASGusev ASGusev commented Sep 28, 2016

No description provided.

Copy link

@sproshev sproshev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачтено, 9.5

@@ -0,0 +1,226 @@
import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это что за штука?)

public boolean contains(String element) {
Node pos = root;
boolean exists = true;
for (int i = 0; ((i < element.length()) && (exists)); i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в этой строке перебор со скобками

if (pos.hasKid(element.charAt(i))) {
pos = pos.getKid(element.charAt(i));
} else {
exists = false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

может тут сразу return можно делать?

if (exists) {
ans = pos.getSize();
}
return ans;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

может быть тут тоже можно как-то упростить по аналогии с contains?

}

private class Node {
private static final int basicRepSize = 9;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

константы именуются капсом, слова разделяются подчеркиваниями

private static final int basicRepSize = 9;
private boolean terminal = false;
private int subtreeSize = 0;
private Node[] kids = new Node[52];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

ans |= ((int)arr[beginning + i]) >>> (8 * (3 - i));
}
return ans;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataInput/OutputStream я не просто так подсказывал)

} else {
index = c - 'A' + 26;
}
return index;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем переменная индекс, если можно в обоих случаях сразу делать return?

kids[kidsNumbers[i]] = new Node();
kids[kidsNumbers[i]].unboxFromStream(stream);
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

результаты вызовов метода read проигнорированы, -0.5

stream.read(basicData, 0, basicRepSize);
terminal = (basicData[0] == 1);
subtreeSize = assembleInt(basicData, 1);
kidsNumber = assembleInt(basicData, 5);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем kidsNumber и kidsNumbers объявлены выше? можно их объявить прямо при инициализации

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants