aboutsummaryrefslogtreecommitdiff
path: root/scripts/resource-set.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/resource-set.py')
-rw-r--r--scripts/resource-set.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/resource-set.py b/scripts/resource-set.py
new file mode 100644
index 00000000..49b6fc9b
--- /dev/null
+++ b/scripts/resource-set.py
@@ -0,0 +1,35 @@
+# $Id$
+
+class resource(object):
+
+ def __init__(self, car, cdr):
+ self.car = car
+ self.cdr = cdr
+
+ def __str__(self):
+ return "(" + str(self.car) + " . " + str(self.cdr) + ")"
+
+ def __eq__(self, other):
+ return self.car == other.car and self.cdr == other.cdr
+
+ def __hash__(self):
+ return self.car.__hash__() + self.cdr.__hash__()
+
+class resource_set(set):
+
+ def __init__(self, *elts):
+ for e in elts:
+ assert isinstance(e, resource)
+ set.__init__(self, elts)
+
+ def __str__(self):
+ return "(" + " ".join(map(str, self)) + ")"
+
+s = resource_set(resource("a", "b"), resource("c", "d"), resource("a", "b"))
+
+print s
+
+print len(s)
+
+for i in s:
+ print i