aboutsummaryrefslogtreecommitdiff
path: root/scripts/resource-set.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2007-06-30 03:48:00 +0000
committerRob Austein <sra@hactrn.net>2007-06-30 03:48:00 +0000
commitcbe4e6826320e6890c8a8de655c44b6b07bbf832 (patch)
tree32f0431636df187075e73845530149da2e927481 /scripts/resource-set.py
parent03ae6c7efa7263aa1e98ba7d9e1854e39c09b10a (diff)
Checkpoint
svn path=/scripts/resource-set.py; revision=700
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