summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2006-05-31 19:40:11 +0000
committerRich Hickey <richhickey@gmail.com>2006-05-31 19:40:11 +0000
commit00d88b349cff1b49b8026add38bb62407232ce31 (patch)
tree1ca8c18e7f898cb2fbec507e14493a6265ae6e09
parentaaf41d731cc4baa7693cae8d09814a00cd0e6255 (diff)
added has(), made keys comparable
-rw-r--r--src/cli/runtime/Obj.cs17
-rw-r--r--src/org/clojure/runtime/Obj.java12
2 files changed, 22 insertions, 7 deletions
diff --git a/src/cli/runtime/Obj.cs b/src/cli/runtime/Obj.cs
index 7058ebe3..9a165e67 100644
--- a/src/cli/runtime/Obj.cs
+++ b/src/cli/runtime/Obj.cs
@@ -20,9 +20,9 @@ public class Obj
{
HybridDictionary attrs;
-public static int INITIAL_SIZE = 7;
-
-public Object put(Keyword key, Object val)
+public static int INITIAL_SIZE = 7;
+
+public Object put(IComparable key, Object val)
{
if(attrs == null)
attrs = new HybridDictionary(INITIAL_SIZE);
@@ -30,11 +30,18 @@ public Object put(Keyword key, Object val)
return val;
}
-public Object get(Keyword key)
+public Object get(IComparable key)
{
if(attrs == null)
return null;
return attrs[key];
- }
+ }
+
+public bool has(IComparable key)
+ {
+ if (attrs == null)
+ return false;
+ return attrs.Contains(key);
+ }
}
} \ No newline at end of file
diff --git a/src/org/clojure/runtime/Obj.java b/src/org/clojure/runtime/Obj.java
index c96e70da..4125b298 100644
--- a/src/org/clojure/runtime/Obj.java
+++ b/src/org/clojure/runtime/Obj.java
@@ -19,7 +19,7 @@ public class Obj {
IdentityHashMap attrs;
public static final int INITIAL_SIZE = 7;
-public Object put(Keyword key, Object val)
+public Object put(Comparable key, Object val)
{
if(attrs == null)
attrs = new IdentityHashMap(INITIAL_SIZE);
@@ -27,10 +27,18 @@ public Object put(Keyword key, Object val)
return val;
}
-public Object get(Keyword key)
+public Object get(Comparable key)
{
if(attrs == null)
return null;
return attrs.get(key);
}
+
+public boolean has(Comparable key){
+ if(attrs == null)
+ return false;
+ return attrs.containsKey(key);
+ }
+
+
}