Module Assign NameStore Str If CompareEq NameLoad Str body ImportFrom alias ImportFrom alias Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call NameLoad ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias identifier ImportFrom alias ImportFrom alias Assign NameStore IfExp CompareEq NameLoad Str NameLoad NameLoad ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Print Str For NameStore NameLoad body Print Call AttributeLoad Str attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Print Str Return Str decorator_list decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad NameLoad decorator_list decorator_list ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam NameParam NameParam defaults ListLoad ListLoad Str body Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad If NameLoad body Expr Call NameLoad keyword Str decorator_list FunctionDef arguments args NameParam defaults body Return ListComp Call NameLoad AttributeLoad NameLoad attr comprehension NameStore Call NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Assign AttributeStore NameLoad attr ListComp Dict NameLoad Call AttributeLoad NameLoad attr comprehension NameStore AttributeLoad NameLoad attr Return AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad Assign NameStore AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Assign NameStore Call AttributeLoad Str attr Call NameLoad ListLoad Str Str NameLoad Call NameLoad Call NameLoad Num Num If NameLoad body Print Call AttributeLoad Str attr NameLoad NameLoad Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad NameLoad decorator_list decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Print Str For TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr body Print Call AttributeLoad Str attr NameLoad NameLoad Print Str Return Str decorator_list FunctionDef arguments args NameParam defaults vararg kwarg body Assign AttributeStore NameLoad attr Dict Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body For TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr body If CompareEq NameLoad NameLoad body Return NameLoad orelse If CompareEq NameLoad NameLoad body Return NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body TryFinally body TryExcept body Return SubscriptLoad NameLoad Index NameLoad handlers ExceptHandler type NameLoad body Return SubscriptLoad NameLoad Index NameLoad finalbody Pass decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore BoolOpAnd CompareIn NameLoad NameLoad CompareIn NameLoad NameLoad Assign NameStore BoolOpAnd CompareIn NameLoad NameLoad CompareIn NameLoad NameLoad If BoolOpOr NameLoad NameLoad body Raise Call NameLoad Str Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad NameLoad decorator_list decorator_list If NameLoad body With Call NameLoad Str body Assign NameStore Call NameLoad keyword Str For NameStore Call NameLoad Num body Assign NameStore Call AttributeLoad Str attr Call AttributeLoad Str attr Call NameLoad Num Assign SubscriptStore NameLoad Index NameLoad Call AttributeLoad Str attr Call NameLoad Num Print NameLoad With Call NameLoad Str body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call NameLoad keyword Str Expr Call NameLoad Str keyword Str For NameStore Call NameLoad Num body Assign NameStore Call AttributeLoad Str attr NameLoad Assign SubscriptStore NameLoad Index NameLoad Call AttributeLoad Str attr Call NameLoad Num Print NameLoad Print SubscriptLoad NameLoad Index Str Expr Call NameLoad Str keyword Str Assign NameStore Call NameLoad keyword ListLoad Str Str Str Str Str keyword BinOpAdd ListComp Call AttributeLoad NameLoad attr comprehension NameStore Call NameLoad Num ListLoad Str Expr Call NameLoad AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Expr Call NameLoad Str Print NameLoad Expr Call NameLoad Str Print Call AttributeLoad Str attr Call AttributeLoad NameLoad attr Str Delete SubscriptDel NameLoad Index Str Assert CompareIs SubscriptLoad NameLoad Index Str NameLoad Print NameLoad Assert CompareNotIn Str NameLoad Expr Call NameLoad Str keyword Str Assign NameStore Call NameLoad Dict Num Num Str Str Str Str Str Str Print NameLoad TryExcept body Assign SubscriptStore NameLoad Index Str Str Assign SubscriptStore NameLoad Index Str Str handlers ExceptHandler type NameLoad body Expr Call NameLoad Str Print NameLoad Assert CompareIn Str NameLoad Assert CompareIn Str NameLoad
N/A N/A __author__ Chris Tabor (dxdstudio@gmail.com) N/A N/A __name__ __main__ N/A os getcwd os sys N/A N/A N/A N/A sys path append N/A getcwd MOAL.helpers.display Section MOAL.helpers.display print_h2 MOAL.helpers.display print_h3 MOAL.helpers.display print_info MOAL.helpers.display divider MOAL.helpers.text randchars MOAL.data_structures.abstract.array_and_linked_lists AssociationList random randrange rr random choice faker Factory N/A DEBUG N/A N/A __name__ __main__ True False MapADT N/A AssociationList N/A N/A From wikipedia.org/wiki/Associative_array:

    "Operations associated with this data type allow:
        * The addition of pairs to the collection
        * The removal of pairs from the collection
        * The modification of the values of existing pairs
        * The lookup of the value associated with a particular key"

    ----------------------------------------------------------------------

    While we could just use a dictionary (cheating), it would make sense
    to use a vanilla array and implement a custom & importantly, internal,
    function that does key lookups.

    However, an associative array / map is purely abstract, and other data types
    use it as a template, either concretely or conceptually. A linked list is
    given as an example implementation, so we can use it here,
    providing some basic methods that act as a facade pattern over the
    internal implementation. __str__ N/A N/A self N/A N/A N/A { N/A node self N/A N/A N/A N/A  "{}": "{}", format N/A node title N/A node cargo N/A } N/A N/A N/A MultiMap N/A MapADT N/A N/A From wikipedia.org/wiki/Multimap (paraphrased):
    "In computer science, a multimap (sometimes also multihash) is a
    generalization of a map or associative array abstract data type in which
    more than one value may be associated with and returned for a given key.

    Often the multimap is implemented as a map with lists/sets as the values."

    "Both map and multimap are particular cases of containers"
    (See abstract/container for an example of this ADT.)

    Since our MapADT uses a linked list, and the linked list implementation
    does not prohibit certain types as values,
    we can simply use a list as mentioned above for the value.

    We could enforce certain types on the original linked list,
    but that is arbitrary and unnecessary. __setitem__ N/A N/A self key value N/A N/A N/A N/A N/A N/A super MultiMap self append key value N/A N/A Enrollment N/A MultiMap N/A __init__ N/A N/A self students classes title N/A N/A N/A Enrollment-MultiMap N/A N/A N/A self MAX_CLASSES 4 N/A N/A self classes classes N/A N/A self students students N/A N/A N/A N/A super Enrollment self __init__ title title N/A enroll N/A N/A self student klass N/A N/A N/A N/A N/A N/A super Enrollment self __setitem__ student klass N/A enroll_all N/A N/A self schedules N/A N/A N/A N/A student classes N/A N/A schedules iteritems N/A N/A klass classes N/A N/A N/A N/A self enroll student klass N/A DEBUG N/A N/A N/A divider atom . N/A _classes N/A N/A self N/A N/A N/A N/A N/A choice N/A self classes N/A _ N/A range N/A self MAX_CLASSES N/A schedules N/A N/A self N/A N/A N/A N/A self schedules N/A N/A student N/A N/A self _classes N/A student N/A self students N/A N/A self schedules N/A get_classes N/A N/A self student N/A N/A N/A res N/A N/A N/A super Enrollment self __getitem__ student N/A classes N/A res cargo N/A classes N/A __setitem__ N/A N/A self student klass N/A N/A N/A klass N/A N/A {}{} {} format N/A choice N/A AP  klass N/A str N/A rr 100 999 N/A DEBUG N/A N/A N/A N/A Enrolling {} into {} format student klass N/A N/A N/A N/A super Enrollment self __setitem__ student klass N/A N/A BidirectionalMap N/A dict N/A N/A The bi-directional map uses a dictionary rather than an associative
    or linked list, since the main purposes is to stress the concept of
    bi-directional mapping, not the actual implementation. Besides, a dict would
    be a better implementation for real-world usage, at least in python. __str__ N/A N/A self N/A N/A N/A { N/A N/A key val N/A N/A N/A self items iteritems N/A N/A N/A N/A   {}: {} format key val N/A } N/A N/A __init__ N/A N/A self N/A args kwargs N/A N/A N/A self items N/A N/A N/A N/A N/A self items update args kwargs N/A __contains__ N/A N/A self key N/A N/A N/A N/A _key val N/A N/A N/A self items iteritems N/A N/A N/A _key key N/A N/A True N/A N/A N/A val key N/A N/A True N/A False N/A __getitem__ N/A N/A self key value N/A N/A N/A N/A N/A N/A N/A N/A self N/A key N/A N/A N/A KeyError N/A N/A N/A self N/A value N/A N/A N/A __setitem__ N/A N/A self key val N/A N/A N/A The idea here is that a key and a value are interchangeable,
        but either direction should still enforce the rules of a traditional
        map (or dictionary, in this case.) N/A keys N/A N/A N/A self items keys N/A values N/A N/A N/A self items values N/A is_both_key N/A N/A key keys N/A key values N/A is_both_val N/A N/A val keys N/A val values N/A N/A is_both_key is_both_val N/A N/A N/A ValueError Item already exists in both key and value -- it can only exist in one! N/A N/A N/A N/A super BidirectionalMap self __setitem__ key val N/A N/A N/A DEBUG N/A N/A N/A Section Map Abstract Data Type N/A N/A map_adt N/A MapADT title map_head N/A n N/A range 6 N/A N/A key N/A N/A map_item-{} format N/A N/A join N/A randchars 8 N/A N/A map_adt N/A key N/A N/A join N/A randchars 4 N/A map_adt N/A N/A Section Multi-Map Abstract Data Type N/A N/A faker N/A N/A Factory create N/A multimap N/A MultiMap title multi-map_head N/A N/A print_h2 Multimap desc General abstract usage. N/A n N/A range 4 N/A N/A key N/A N/A map_item-{} format n N/A N/A multimap N/A key N/A N/A join N/A randchars 4 N/A multimap N/A N/A multimap N/A map_item-1 N/A N/A print_h2 Multimap desc Used contextually for school enrollment. N/A classes_map N/A Enrollment classes N/A English Comp Sci History Math Art students N/A N/A N/A N/A faker name N/A _ N/A range 3 N/A Ms. Ella Tabor N/A N/A map N/A classes_map enroll_all N/A N/A classes_map schedules N/A N/A print_h3 All fields N/A classes_map N/A N/A print_h3 
Classes for Ella Tabor N/A N/A N/A Classes: {} format N/A N/A classes_map get_classes Ms. Ella Tabor N/A N/A classes_map N/A Ms. Ella Tabor N/A N/A N/A classes_map N/A Ms. Ella Tabor None N/A classes_map N/A N/A Ms. Ella Tabor classes_map N/A N/A print_h3 Bi-directional desc A map ADT that maps to key OR value. N/A bdmap N/A BidirectionalMap N/A 1 2 Foo Bar Foo Bar Bar Foo N/A bdmap N/A N/A N/A N/A bdmap N/A Bar Foo N/A N/A bdmap N/A Foo Bar N/A N/A N/A ValueError N/A N/A N/A print_info Test raising error for duplicate values Foo and Bar N/A bdmap N/A N/A Bar bdmap N/A N/A Foo bdmap