Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mamayaya1
GitHub Repository: mamayaya1/game
Path: blob/main/projects/HexGL/libs/Editor_files/hashlist.js
4627 views
1
2
/**
3
* A map of linked lists mapped by a string value
4
*/
5
gamecore.HashList = gamecore.Base.extend('gamecore.HashList',
6
{},
7
{
8
hashtable: null,
9
10
init: function()
11
{
12
this.hashtable = new gamecore.Hashtable();
13
},
14
15
add: function(key, object)
16
{
17
// find the list associated with this key and add the object to it
18
var list = this.hashtable.get(key);
19
if (list == null)
20
{
21
// no list associated with this key yet, so let's make one
22
list = new pc.LinkedList();
23
this.hashtable.put(key, list);
24
}
25
list.add(object);
26
},
27
28
remove: function(key, object)
29
{
30
var list = this.hashtable.get(key);
31
if (list == null) throw "No list for a key in hashlist when removing";
32
list.remove(object);
33
},
34
35
get: function(key)
36
{
37
return this.hashtable.get(key);
38
}
39
40
41
});
42
43