summaryrefslogtreecommitdiff
path: root/giscanner/odict.py
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2008-04-20 19:06:19 +0000
committerJohan Dahlin <johan@src.gnome.org>2008-04-20 19:06:19 +0000
commite01880c5205ee16eebb7b0cedc7e207a08d4df3d (patch)
tree1a6a7f7f2aa3a462a0d034303d6731be26839449 /giscanner/odict.py
parentf941a4ff59698c6a3c326eafe177af2d43a23505 (diff)
downloadgobject-introspection-e01880c5205ee16eebb7b0cedc7e207a08d4df3d.tar.gz
Avoid conflicts, keep the output ordered similar to the order of the
2008-04-20 Johan Dahlin <johan@gnome.org> * giscanner/gidlwriter.py: * giscanner/gobjecttreebuilder.py: * giscanner/odict.py: Avoid conflicts, keep the output ordered similar to the order of the input. Add a simple ordered dictionary implemenation svn path=/trunk/; revision=180
Diffstat (limited to 'giscanner/odict.py')
-rw-r--r--giscanner/odict.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/giscanner/odict.py b/giscanner/odict.py
new file mode 100644
index 00000000..00d5a5bd
--- /dev/null
+++ b/giscanner/odict.py
@@ -0,0 +1,24 @@
+# odict - an ordered dictionary
+
+from UserDict import DictMixin
+
+
+class odict(DictMixin):
+ def __init__(self):
+ self._items = {}
+ self._keys = []
+
+ def __setitem__(self, key, value):
+ if key not in self._items:
+ self._keys.append(key)
+ self._items[key] = value
+
+ def __getitem__(self, key):
+ return self._items[key]
+
+ def __delitem__(self, key):
+ del self._items[key]
+ self._keys.remove(key)
+
+ def keys(self):
+ return self._keys[:]