Skip to content

Hash map initial commit.#1

Open
ASGusev wants to merge 1 commit intomasterfrom
hashmap
Open

Hash map initial commit.#1
ASGusev wants to merge 1 commit intomasterfrom
hashmap

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.

10


dependencies {
testCompile 'junit:junit:4.12'
} No newline at end of file

Choose a reason for hiding this comment

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

junit два раза объявлен

for (int i = 0; i < capacity; i++) {
store[i] = new List();
}
}

Choose a reason for hiding this comment

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

с отступами что-то не то, пробелы/табы?

public boolean contains(String key) {
// true, если такой ключ содержится в таблице
int cellNumber = key.hashCode() % capacity;
return store[cellNumber].exists(key);

Choose a reason for hiding this comment

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

как минимум вычисление cellNumber стоило выделить в отдельный метод, но еще лучше, вынести в отдельный метод код:

int cellNumber = ...;
return store[cellNumber];

for (int i = 0; i < capacity; i++) {
store[i] = new List();
}
size = 0;

Choose a reason for hiding this comment

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

можно упростить конструктор, вызывая clear

size = 0;
}

private class Entry {

Choose a reason for hiding this comment

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

static

}
}

private class List {

Choose a reason for hiding this comment

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

static

int hash;
String key, val;

Entry(String newKey, String newVal) {

Choose a reason for hiding this comment

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

почему у конструкторов нет модификаторов доступа?

head = null;
}

private class Node {

Choose a reason for hiding this comment

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

static

@Test
public void testSize() {
org.junit.Assert.assertTrue("Size method " +
"returned incorrect value.", map.size() == 3);

Choose a reason for hiding this comment

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

assertEquals

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