OrderedDict

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=1]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/utilities/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; } subgraph "cluster_abjad.utilities" { graph [label="abjad.utilities"]; node [color=2]; "abjad.utilities.OrderedDict.OrderedDict" [URL="../api/abjad/utilities/OrderedDict.html#abjad.utilities.OrderedDict.OrderedDict", color=black, fontcolor=white, label="Ordered\nDict", target=_top]; "abjad.utilities.TypedCollection.TypedCollection" [URL="../api/abjad/utilities/TypedCollection.html#abjad.utilities.TypedCollection.TypedCollection", label="Typed\nCollection", shape=oval, style=bold, target=_top]; "abjad.utilities.TypedCollection.TypedCollection" -> "abjad.utilities.OrderedDict.OrderedDict"; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } subgraph "cluster_collections.abc" { graph [label="collections.abc"]; node [color=4]; "collections.abc.Collection" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Collection", label=Collection, shape=oval, style=bold, target=_top]; "collections.abc.Container" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Container", label=Container, shape=oval, style=bold, target=_top]; "collections.abc.Iterable" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Iterable", label=Iterable, shape=oval, style=bold, target=_top]; "collections.abc.Mapping" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Mapping", label=Mapping, shape=oval, style=bold, target=_top]; "collections.abc.MutableMapping" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.MutableMapping", label="Mutable\nMapping", shape=oval, style=bold, target=_top]; "collections.abc.Sized" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Sized", label=Sized, shape=oval, style=bold, target=_top]; "collections.abc.Collection" -> "collections.abc.Mapping"; "collections.abc.Container" -> "collections.abc.Collection"; "collections.abc.Iterable" -> "collections.abc.Collection"; "collections.abc.Mapping" -> "collections.abc.MutableMapping"; "collections.abc.Sized" -> "collections.abc.Collection"; } "abjad.system.AbjadObject.AbjadObject" -> "abjad.utilities.TypedCollection.TypedCollection"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; "builtins.object" -> "collections.abc.Container"; "builtins.object" -> "collections.abc.Iterable"; "builtins.object" -> "collections.abc.Sized"; "collections.abc.MutableMapping" -> "abjad.utilities.OrderedDict.OrderedDict"; }

class abjad.utilities.OrderedDict.OrderedDict(items=None, item_class=None)

Ordered dictionary.

Initializes from list of pairs:

>>> dictionary = abjad.OrderedDict([
...     ('color', 'red'),
...     ('directive', abjad.Markup(r'\italic Allegretto')),
...     ])
>>> abjad.f(dictionary)
abjad.OrderedDict(
    [
        ('color', 'red'),
        (
            'directive',
            abjad.Markup(
                contents=[
                    abjad.MarkupCommand(
                        'italic',
                        'Allegretto'
                        ),
                    ],
                ),
            ),
        ]
    )

Initializes from built-in dictionary:

>>> dictionary = {
...     'color': 'red',
...     'directive': abjad.Markup(r'\italic Allegretto'),
...     }
>>> dictionary = abjad.OrderedDict(
...     dictionary
...     )
>>> abjad.f(dictionary)
abjad.OrderedDict(
    [
        ('color', 'red'),
        (
            'directive',
            abjad.Markup(
                contents=[
                    abjad.MarkupCommand(
                        'italic',
                        'Allegretto'
                        ),
                    ],
                ),
            ),
        ]
    )

Initializes from other ordered dictionary:

>>> dictionary_1 = abjad.OrderedDict([
...     ('color', 'red'),
...     ('directive', abjad.Markup(r'\italic Allegretto')),
...     ])
>>> dictionary_2 = abjad.OrderedDict(
...     dictionary_1
...     )
>>> abjad.f(dictionary_2)
abjad.OrderedDict(
    [
        ('color', 'red'),
        (
            'directive',
            abjad.Markup(
                contents=[
                    abjad.MarkupCommand(
                        'italic',
                        'Allegretto'
                        ),
                    ],
                ),
            ),
        ]
    )

Attributes Summary

__cmp__ Aliases OrderedDict.__cmp__().
__contains__ Aliases OrderedDict.__contains__().
__delitem__ Aliases OrderedDict.__delitem__().
__ge__ Is true when typed ordered dictionary is greater than or equal to argument.
__getitem__ Gets item or slice identified by argument.
__gt__ Is true when typed ordered dictionary is greater than argument.
__le__ Is true when typed ordered dictionary is less than or equal to argument.
__lt__ Is true when typed ordered dictionary is less than argument.
__reversed__ Aliases OrderedDict.__reversed__().
__setitem__ Changes items in argument to items and sets.
clear Clears typed ordered dictionary.
copy Copies typed ordered dictionary.
get Aliases OrderedDict.get().
has_key Aliases OrderdDict.has_key().
items Aliases OrderedDict.items().
keys Aliases OrderedDict.keys().
pop Aliases OrderedDict.pop().
popitem Aliases OrderedDict.popitem().
setdefault Aliases OrderedDict.setdefault().
sort Sorts ordered dictionary (in place).
update Aliases OrderedDict.update().
values Aliases OrderedDict.values().

Special methods

__cmp__(argument)

Aliases OrderedDict.__cmp__().

Returns true or false.

__contains__(key)

Aliases OrderedDict.__contains__().

Returns true or false.

__delitem__(i)

Aliases OrderedDict.__delitem__().

Returns none.

(TypedCollection).__eq__(argument)

Is true when argument is a typed collection with items that compare equal to those of this typed collection.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

__ge__(argument)

Is true when typed ordered dictionary is greater than or equal to argument.

Returns true or false.

__getitem__(argument)

Gets item or slice identified by argument.

Returns item or slice.

__gt__(argument)

Is true when typed ordered dictionary is greater than argument.

Returns true or false.

(TypedCollection).__hash__()

Hashes typed collection.

Redefined in tandem with __eq__.

(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

__le__(argument)

Is true when typed ordered dictionary is less than or equal to argument.

Returns true or false.

(TypedCollection).__len__()

Gets length of typed collection.

Returns nonnegative integer.

__lt__(argument)

Is true when typed ordered dictionary is less than argument.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

__reversed__()

Aliases OrderedDict.__reversed__().

Returns generatos.

__setitem__(i, argument)

Changes items in argument to items and sets.

Returns none.


Methods

clear()

Clears typed ordered dictionary.

Returns none.

copy()

Copies typed ordered dictionary.

Returns new typed ordered dictionary.

get(i, default=None)

Aliases OrderedDict.get().

Returns item or raises key error.

has_key(key)

Aliases OrderdDict.has_key().

Returns true or false.

items()

Aliases OrderedDict.items().

Returns generator.

keys()

Aliases OrderedDict.keys().

Returns generator.

pop(key, default=None)

Aliases OrderedDict.pop().

Returns items.

popitem()

Aliases OrderedDict.popitem().

Returns generator.

setdefault(key, default=None)

Aliases OrderedDict.setdefault().

Returns items.

sort(recurse=False)

Sorts ordered dictionary (in place).

>>> dictionary = abjad.OrderedDict()
>>> dictionary['flavor'] = 'cherry'
>>> dictionary['colors'] = abjad.OrderedDict()
>>> dictionary['colors']['red'] = 3
>>> dictionary['colors']['green'] = 2
>>> dictionary['colors']['blue'] = 1
>>> abjad.f(dictionary)
abjad.OrderedDict(
    [
        ('flavor', 'cherry'),
        (
            'colors',
            abjad.OrderedDict(
                [
                    ('red', 3),
                    ('green', 2),
                    ('blue', 1),
                    ]
                ),
            ),
        ]
    )
>>> dictionary.sort()
>>> abjad.f(dictionary)
abjad.OrderedDict(
    [
        (
            'colors',
            abjad.OrderedDict(
                [
                    ('red', 3),
                    ('green', 2),
                    ('blue', 1),
                    ]
                ),
            ),
        ('flavor', 'cherry'),
        ]
    )
>>> dictionary.sort(recurse=True)
>>> abjad.f(dictionary)
abjad.OrderedDict(
    [
        (
            'colors',
            abjad.OrderedDict(
                [
                    ('blue', 1),
                    ('green', 2),
                    ('red', 3),
                    ]
                ),
            ),
        ('flavor', 'cherry'),
        ]
    )
Return type:None
update(*arguments, **keywords)

Aliases OrderedDict.update().

Returns none.

values()

Aliases OrderedDict.values().

Returns generator.


Read-only properties

(TypedCollection).item_class

Gets item class of collection.

Collection coerces items according to item_class.

Returns class.