From charlesreid1

(Created page with "==Functions== Some absolute basic functionality that should be provided: * m[k] or m.get(k) - get the value v associated with key k in map m, returns key error * m[k] = v or...")
 
No edit summary
 
Line 1: Line 1:
==Functions==
==Implementation and Functionality==
 


Some absolute basic functionality that should be provided:
Some absolute basic functionality that should be provided:
Line 8: Line 7:
* len(m) or m.size() - return the number of elements (unique keys) in the map
* len(m) or m.size() - return the number of elements (unique keys) in the map
* iter(m) - iterator over keys of map
* iter(m) - iterator over keys of map




Line 19: Line 19:


The base type Map defines a large number of methods - see [[Maps/ADT]] for the full list.
The base type Map defines a large number of methods - see [[Maps/ADT]] for the full list.
==Flags==
{{MapsFlag}}

Latest revision as of 13:58, 21 June 2017

Implementation and Functionality

Some absolute basic functionality that should be provided:

  • m[k] or m.get(k) - get the value v associated with key k in map m, returns key error
  • m[k] = v or m.set(k,v) or m.put(k,v) - set the value v associated with key k in map m
  • del m[k] or m.remove(k) - remove the element with key k in map m
  • len(m) or m.size() - return the number of elements (unique keys) in the map
  • iter(m) - iterator over keys of map


Notes

Base map class. Maps are essentially key-value data structures - you pass in a key, you get back a value.

In the Java Collections framework, the Map class is the highest-level abstract class - it is actually an interface, not a class.

Java API Documentation for Map class: http://docs.oracle.com/javase/8/docs/api/java/util/Map.html

The base type Map defines a large number of methods - see Maps/ADT for the full list.


Flags