All pastes #486362 Raw Edit

Mine

public text v1 · immutable
·published 2007-05-13 21:31 UTC
rendered paste body
to insert

int hash = newnode.key.hashCode();
int headernum = hash%num_of_headers;

hashnode curr = headers[headernum];
while (curr != null) {
   if (curr.key.equals(key))
   {
      unitmap.unit myunit = curr.value;
      curr.value = newnode.value;
      return myunit;
   }
   curr = curr.link;
}

newnode.link = headers[headernum];
headers[headernum] = newnode;
return null;



to find
int hash = key.hashCode();
int headernum = hash&num_ofheaders;

hashnode curr = headers[headernum];
while (curr != null) {
   if (curr.key.equals(key))
      return curr.value;
   curr = curr.link;
}

return null;