pro

pro

hanmarco


class Node{

char[] string;

int[] start;

public void newNODE(char[] string, int start) {

}

}



class Hashtable {

class Hash {

String key;

String data;

}


int capacity;

Hash tb[];


public Hashtable(int capacity) {

this.capacity = capacity;

tb = new Hash[capacity];

for (int i = 0; i < capacity; i++) {

tb[i] = new Hash();

}

}


private int hash(String str) {

int hash = 5381;


for (int i = 0; i < str.length(); i++) {

int c = (int) str.charAt(i);

hash = ((hash << 5) + hash) + c;

}

if (hash < 0)

hash *= -1;

return hash % capacity;

}


public String find(String key) {

int h = hash(key);

int cnt = capacity;

while (tb[h].key != null && (--cnt) != 0) {

if(isEquals(tb[h].key, key)){

return tb[h].data;

}

h = (h + 1) % capacity;

}

return null;

}


boolean add(String key, String data) {

int h = hash(key);

while (tb[h].key != null) {

if(isEquals(tb[h].key, key)){

return false;

}

h = (h + 1) % capacity;

}

tb[h].key = key;

tb[h].data = data;

return true;

}

boolean isEquals(String a, String b){

boolean isSame = false;

if(a.length()!=b.length())

return false;

for (int i = 0; i < a.length(); i++) {

if(a.charAt(i)==b.charAt(i))

continue;

else

return false;

}

return true;

}

}








public class Solution {


char[] buffer;

int cursor;

int temp_cursor;

Node[] list ; 

int count;

Hash

public void init() {

buffer = new char[100];

cursor = 0;

temp_cursor = 0;

list = new Node[25000];

count = 0;

}


public void add_char(char c) {


if (c == '\b') {

if (temp_cursor > 0)

if (cursor > 0) {

temp_cursor--;

cursor--;

buffer[temp_cursor] = '\0';

}

} else if (c == ' ') {

int start_index = cursor - temp_cursor;

int length = temp_cursor;

add_string(start_index, buffer, length);

cursor++;

temp_cursor = 0;

count++;

} else if (c == '\t') {

} else {

buffer[temp_cursor++] = c;

cursor++;

}


}


public void add_string(int start_index, char[] Cstring, int length) {

System.out.print(start_index);

System.out.print("번째부터 "+String.copyValueOf(Cstring)+"이 저장되었다.");

}


public void search(String str) {


}

}