Path: blob/main/projects/HexGL/libs/Editor_files/hashlist.js
4627 views
1/**2* A map of linked lists mapped by a string value3*/4gamecore.HashList = gamecore.Base.extend('gamecore.HashList',5{},6{7hashtable: null,89init: function()10{11this.hashtable = new gamecore.Hashtable();12},1314add: function(key, object)15{16// find the list associated with this key and add the object to it17var list = this.hashtable.get(key);18if (list == null)19{20// no list associated with this key yet, so let's make one21list = new pc.LinkedList();22this.hashtable.put(key, list);23}24list.add(object);25},2627remove: function(key, object)28{29var list = this.hashtable.get(key);30if (list == null) throw "No list for a key in hashlist when removing";31list.remove(object);32},3334get: function(key)35{36return this.hashtable.get(key);37}383940});414243