Skip to content

Commit

Permalink
Merge pull request #14 from hlstudio/setvalue
Browse files Browse the repository at this point in the history
Add support for update value
  • Loading branch information
hankcs authored May 7, 2018
2 parents 3ce80e5 + 1bfec58 commit e9864ba
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/com/hankcs/algorithm/AhoCorasickDoubleArrayTrie.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,23 @@ public V get(String key)

return null;
}
/**
* Update a value corresponding to a key
* @param key the key
* @param value the value
* @return successful or not(failure if there is no key)
*/
public boolean set(String key, V value)
{
int index = exactMatchSearch(key);
if (index >= 0)
{
v[index] = value;
return true;
}

return false;
}
/**
* Pick the value by index in value array <br>
* Notice that to be more efficiently, this method DO NOT check the parameter
Expand Down

0 comments on commit e9864ba

Please sign in to comment.