Metadata-Version: 1.1
Name: indexed.py
Version: 0.0.1
Summary: A dictionary that is indexed by insertion order.
Home-page: http://github.com/niklasf/indexed.py
Author: Niklas Fiekas
Author-email: niklas.fiekas@tu-clausthal.de
License: GPL3
Description: indexed.py: a dictionary that is indexed by insertion order
        ===========================================================
        
        .. image:: https://travis-ci.org/niklasf/indexed.py.png?branch=master
            :target: https://travis-ci.org/niklasf/indexed.py
            :alt: Build status
        
        Introduction
        ------------
        
        ``indexed.IndexedOrderedDict`` is fully compatible with
        ``collections.OrderedDict`` and can be used as a drop in replacement.
        The main difference is that key, value and item views support accessing
        elements by their index.
        
        ::
        
            d = indexed.IndexedOrderedDict()
            d["first-key"] = "first-value"
            d["second-key"] = "second-value"
            d["third-key"] = "third-value"
        
            values = d.values()
            assert values[2] == "third-value"
        
            assert d.keys().index("second-key") == 1
        
        Features
        --------
        
        * Can be used with both Python 2 and 3. Provides ``keysview()``,
          ``valuesview()`` and ``itemsview()`` which were removed from Python 3 for
          compability.
        
        * Access keys, values and items by index, e.g. ``d.keys()[5]``.
        
        * Find the index of a key, e.g. ``d.keys().index("key")``.
        
        Excluding those additions the API is the same as the API of
        ``collections.OrderedDict()``. Including:
        
        * Initializing, setting, getting and deleting items
        
        * Iterating forwards and in reverse
        
        * ``d.clear()``
        
        * ``d.popitem(last=True)``
        
        * ``d.move_to_end(key, last=True)``
        
        * ``d.keys()``, ``d.values()``, ``d.items()``
        
        * ``d.pop(key[, default])``
        
        * ``d.setdefault(key, default=None)``
        
        * String representation
        
        * Pickling
        
        * Copying
        
        * Creating from keys
        
        * Comparing order sensitively with other ordered dictionaries or order
          insensitively with standard mappings
        
        Installing
        ----------
        The only dependencies are Python >= 2.7 or Python >= 3.0.
        
        * With pip:
        
          ::
        
              sudo pip install indexed.py
        
        * With easy_install:
        
          ::
        
              sudo easy_install indexed.py
        
        * From current source code:
        
          ::
        
              python setup.py build
              sudo python setup.py install
        
        Performance
        -----------
        
        Performance is practically on the same order of magnitude as the built in
        ``collections.OrderedDict``.
        
        ================= ========== ================== ======== ======================
        d                 ``collections.OrderedDict``   ``indexed.IndexedOrderedDict``
        ----------------- ----------------------------- -------------------------------
        Operation         Avergage   Worst case         Average  Worst case
        ================= ========== ================== ======== ======================
        d.copy()          O(n)       O(n)               O(n)     O(n)  
        ----------------- ---------- ------------------ -------- ----------------------
        d[key]            O(1)       O(n)               O(1)     O(n)
        ----------------- ---------- ------------------ -------- ----------------------
        d[key] = value    O(1)       O(n) [#a]_         O(1)     O(n) [#a]_
        ----------------- ---------- ------------------ -------- ----------------------
        del d[key]        **O(1)**   O(n)               O(n)     O(n)
        ----------------- ---------- ------------------ -------- ----------------------
        d.keys()[i]       O(n) [#k]_ O(n) [#k]_         **O(1)** **O(1)**
        ----------------- ---------- ------------------ -------- ----------------------
        d.values()[i]     O(n) [#v]_ O(n) [#v]_         **O(1)** O(n)
        ----------------- ---------- ------------------ -------- ----------------------
        d.items()[i]      O(n) [#v]_ O(n) [#v]_         **O(1)** O(n)
        ----------------- ---------- ------------------ -------- ----------------------
        d.keys().index(x) O(n) [#v]_ O(n) [#v]_         O(n)     O(n)
        ================= ========== ================== ======== ======================
        
        .. [#a] These are amortized_ worst case runtimes.
        .. [#k] This does not work in Python 3 because ``colections.KeysView`` is not
                indexable. One of the theoretically best work arounds is
                ``next(itertools.islice(d.keys(), i, i + 1))``.
        .. [#v] Assuming the theoretically best possible workaround.
        
        License
        -------
        indexed.py is licensed under the GPL3. See the LICENSE file for full copyright
        and license information.
        
        .. _amortized: http://en.wikipedia.org/wiki/Amortized_analysis
        
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries :: Python Modules
