Top Description Inners Fields Constructors Methods
org.python.core

public Class PyDictionary

extends AbstractDict
implements ConcurrentMap, Traverseproc
Class Inheritance
All Implemented Interfaces
org.python.core.Traverseproc, java.util.concurrent.ConcurrentMap, java.util.Map
Known Direct Subclasses
org.python.core.PyDictionaryDerived, org.python.modules._collections.PyDefaultDict
Annotations
@ExposedType
name:dict
base:PyObject
doc:dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object\'s (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
Imports
java.util.AbstractSet, .ArrayList, .Collection, .Iterator, .List, .Map, .Map.Entry, .Set, java.util.concurrent.ConcurrentMap, .ConcurrentHashMap, org.python.core.AbstractDict.ValuesIter, .AbstractDict.KeysIter, .AbstractDict.ItemsIter, org.python.expose.ExposedClassMethod, .ExposedMethod, .ExposedNew, .ExposedType, .MethodType, org.python.util.Generic

A builtin python dictionary.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final ConcurrentMap<PyObject, PyObject>
public static final PyType

Constructor Summary

AccessConstructor and Description
public
PyDictionary()

Create an empty dictionary.

public
PyDictionary(PyType type, int capacity)

Create a dictionary of type with the specified initial capacity.

public
PyDictionary(PyType type)

For derived types

public
PyDictionary(Map<PyObject, PyObject> map)

Create a new dictionary which is based on given map.

public
PyDictionary(ConcurrentMap<PyObject, PyObject> backingMap, boolean useBackingMap)

public
PyDictionary(PyType type, ConcurrentMap<PyObject, PyObject> backingMap, boolean useBackingMap)

public
PyDictionary(PyType type, Map<PyObject, PyObject> map)

Create a new dictionary which is populated with entries the given map.

protected
PyDictionary(PyType type, boolean initializeBacking)

Create a new dictionary without initializing table.

public
PyDictionary(PyObject[]
The initial elements that is inserted in the dictionary. Even numbered elements are keys, odd numbered elements are values.
elements
)

Create a new dictionary with the element as content.

Method Summary

Modifier and TypeMethod and Description
public int
__cmp__(PyObject
the object to compare this with.
otherObj
)

Overrides org.python.core.PyObject.__cmp__.

Equivalent to the standard Python __cmp__ method.

public boolean
__contains__(PyObject
the element to search for in this container.
o
)

Overrides org.python.core.PyObject.__contains__.

Equivalent to the standard Python __contains__ method.

public void
__delitem__(PyObject
the key to be removed from the container
key
)

Overrides org.python.core.PyObject.__delitem__.

Equivalent to the standard Python __delitem__ method.

public PyObject
__eq__(PyObject
the object to compare this with.
otherObj
)

Overrides org.python.core.PyObject.__eq__.

Equivalent to the standard Python __eq__ method.

public PyObject
__finditem__(int
the key to lookup in this sequence.
index
)

Overrides org.python.core.PyObject.__finditem__.

A variant of the __finditem__ method which accepts a primitive int as the key.

public PyObject
__finditem__(PyObject
the key to lookup in this container
key
)

Overrides org.python.core.PyObject.__finditem__.

Very similar to the standard Python __getitem__ method.

public PyObject
__iter__()

Overrides org.python.core.PyObject.__iter__.

Return an iterator that is used to iterate the element of this sequence.

public int
__len__()

Overrides org.python.core.PyObject.__len__.

Equivalent to the standard Python __len__ method.

public PyObject
__ne__(PyObject
the object to compare this with.
otherObj
)

Overrides org.python.core.PyObject.__ne__.

Equivalent to the standard Python __ne__ method.

public boolean
__nonzero__()

Overrides org.python.core.PyObject.__nonzero__.

Equivalent to the standard Python __nonzero__ method.

public void
__setitem__(PyObject
the key whose value will be set
key
,
PyObject
the value to set this key to
value
)

Overrides org.python.core.PyObject.__setitem__.

Equivalent to the standard Python __setitem__ method.

public void
clear()

Implements abstract org.python.core.AbstractDict.clear.

Implements java.util.Map.clear.

Remove all items from the dictionary.

public boolean
containsKey(Object
key whose presence in this map is to be tested
key
)

Implements java.util.Map.containsKey.

Returns true if this map contains a mapping for the specified key.

public boolean
containsValue(Object
value whose presence in this map is to be tested
value
)

Implements java.util.Map.containsValue.

Returns true if this map maps one or more keys to the specified value.

public PyDictionary
copy()

Implements abstract org.python.core.AbstractDict.copy.

Return a shallow copy of the dictionary.

pack-priv final int
pack-priv final boolean
pack-priv final void
pack-priv final PyObject
pack-priv final PyObject
protected final PyObject
pack-priv final PyObject
pack-priv final int
protected final void
dict___init__(PyObject[] args, String[] keywords)

pack-priv final PyObject
pack-priv final PyObject
pack-priv final int
pack-priv final PyObject
pack-priv final PyObject
pack-priv final void
pack-priv final void
pack-priv final PyDictionary
pack-priv static PyObject
pack-priv final PyObject
dict_get(PyObject key, PyObject defaultObj)

pack-priv final boolean
pack-priv final PyList
pack-priv final PyObject
pack-priv final PyObject
pack-priv final PyObject
pack-priv final PyList
pack-priv final PyObject
dict_pop(PyObject key, PyObject defaultValue)

pack-priv final PyObject
pack-priv final PyObject
pack-priv final PyObject
pack-priv final String
pack-priv final void
dict_update(PyObject[] args, String[] keywords)

pack-priv final PyList
public Set<E>
entrySet()

Implements abstract org.python.core.AbstractDict.entrySet.

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.

public boolean
equals(Object
object to be compared for equality with this map
obj
)

Overrides org.python.core.PyObject.equals.

Implements java.util.Map.equals.

Compares the specified object with this map for equality.

public static PyObject
public static PyObject
fromkeys(PyObject keys, PyObject value)

public PyObject
get(PyObject
the key to lookup in the dictionary.
key
,
PyObject
the value to return if the key does not exists in the mapping.
defaultObj
)

Implements abstract org.python.core.AbstractDict.get.

Return this[key] if the key exists in the mapping, defaultObj is returned otherwise.

public PyObject
get(PyObject
the key to lookup in the dictionary.
key
)

Implements abstract org.python.core.AbstractDict.get.

Return this[key] if the key exists in the mapping, None is returned otherwise.

public Object
get(Object
the key whose associated value is to be returned
key
)

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

public ConcurrentMap<PyObject, PyObject>
public boolean
has_key(PyObject key)

Implements abstract org.python.core.AbstractDict.has_key.

Return true if the key exist in the dictionary.

public int
hashCode()

Overrides org.python.core.PyObject.hashCode.

Implements java.util.Map.hashCode.

Returns the hash code value for this map.

public boolean
isEmpty()

Implements java.util.Map.isEmpty.

Returns true if this map contains no key-value mappings.

public boolean
public boolean
public PyList
items()

Implements abstract org.python.core.AbstractDict.items.

Return a copy of the dictionary's list of (key, value) tuple pairs.

public PyObject
iteritems()

Implements abstract org.python.core.AbstractDict.iteritems.

Returns an iterator over (key, value) pairs.

public PyObject
iterkeys()

Implements abstract org.python.core.AbstractDict.iterkeys.

Returns an iterator over the dictionary's keys.

public PyObject
itervalues()

Implements abstract org.python.core.AbstractDict.itervalues.

Returns an iterator over the dictionary's values.

public PyList
keys()

Implements abstract org.python.core.AbstractDict.keys.

Return a copy of the dictionary's list of keys.

public Set<E>
keySet()

Implements java.util.Map.keySet.

Returns a Set view of the keys contained in this map.

private void
private void
merge(PyObject
a PyObject with a keys() method
other
)

Merge another PyObject that supports keys() with this dict.

public void
merge(PyObject
a PyObject with a keys() method
other
,
boolean
if true, the value from other is used on key-collision
override
)

Implements abstract org.python.core.AbstractDict.merge.

Merge another PyObject that supports keys() with this dict.

private void
mergeFromKeys(PyObject
a PyObject with a keys() method
other
,
PyObject
the result of other's keys() method
keys
)

Merge another PyObject via its keys() method

public void
mergeFromKeys(PyObject
a PyObject with a keys() method
other
,
PyObject
the result of other's keys() method
keys
,
boolean
if true, the value from other is used on key-collision
override
)

Implements abstract org.python.core.AbstractDict.mergeFromKeys.

Merge another PyObject via its keys() method

private void
mergeFromSeq(PyObject
another PyObject
other
)

Merge any iterable object producing iterable objects of length 2 into this dict.

public void
mergeFromSeq(PyObject
another PyObject
other
,
boolean
if true, the value from other is used on key-collision
override
)

Implements abstract org.python.core.AbstractDict.mergeFromSeq.

Merge any iterable object producing iterable objects of length 2 into this dict.

public PyObject
pop(PyObject key)

Implements abstract org.python.core.AbstractDict.pop.

Return a value based on key from the dictionary.

public PyObject
pop(PyObject key, PyObject defaultValue)

Implements abstract org.python.core.AbstractDict.pop.

Return a value based on key from the dictionary or default if that key is not found.

public PyObject
popitem()

Implements abstract org.python.core.AbstractDict.popitem.

Return a random (key, value) tuple pair and remove the pair from the dictionary.

public Object
put(Object
key with which the specified value is to be associated
key
,
Object
value to be associated with the specified key
value
)

Implements java.util.Map.put.

Associates the specified value with the specified key in this map (optional operation).

public void
putAll(Map<K, V>
mappings to be stored in this map
map
)

Implements java.util.Map.putAll.

Copies all of the mappings from the specified map to this map (optional operation).

public Object
putIfAbsent(Object
key with which the specified value is to be associated
key
,
Object
value to be associated with the specified key
value
)

Implements java.util.concurrent.ConcurrentMap.putIfAbsent.

If the specified key is not already associated with a value, associates it with the given value.

public Set<PyObject>
public boolean
public Object
remove(Object
key whose mapping is to be removed from the map
key
)

Implements java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation).

public boolean
remove(Object
key with which the specified value is associated
key
,
Object
value expected to be associated with the specified key
value
)

Implements java.util.concurrent.ConcurrentMap.remove.

Removes the entry for a key only if currently mapped to a given value.

public boolean
replace(Object
key with which the specified value is associated
key
,
Object
value expected to be associated with the specified key
oldValue
,
Object
value to be associated with the specified key
newValue
)

Implements java.util.concurrent.ConcurrentMap.replace.

Replaces the entry for a key only if currently mapped to a given value.

public Object
replace(Object
key with which the specified value is associated
key
,
Object
value to be associated with the specified key
value
)

Implements java.util.concurrent.ConcurrentMap.replace.

Replaces the entry for a key only if currently mapped to some value.

public PyObject
setdefault(PyObject
the key to lookup in the dictionary.
key
)

Implements abstract org.python.core.AbstractDict.setdefault.

Return this[key] if the key exist, otherwise insert key with a None value and return None.

public PyObject
setdefault(PyObject
the key to lookup in the dictionary.
key
,
PyObject
the default value to insert in the dictionary if key does not already exist.
failobj
)

Implements abstract org.python.core.AbstractDict.setdefault.

Return this[key] if the key exist, otherwise insert key with the value of failobj and return failobj

public int
size()

Implements java.util.Map.size.

Returns the number of key-value mappings in this map.

public String
toString()

Overrides org.python.core.PyObject.toString.

Returns a string representation of the object.

public int
traverse(Visitproc visit, Object arg)

Implements org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects.

public void
update(PyObject other)

Implements abstract org.python.core.AbstractDict.update.

Insert all the key:value pairs from d into this dictionary.

public void
updateCommon(PyObject[] args, String[] keywords, String methName)

public Collection<E>
values()

Implements abstract org.python.core.AbstractDict.values.

Implements java.util.Map.values.

Returns a Collection view of the values contained in this map.

public PyObject
viewitems()

Overrides org.python.core.AbstractDict.viewitems.

Returns a dict_items on the dictionary's items

public PyObject
viewkeys()

Overrides org.python.core.AbstractDict.viewkeys.

Returns a dict_keys on the dictionary's keys

public PyObject
viewvalues()

Overrides org.python.core.AbstractDict.viewvalues.

Returns a dict_values on the dictionary's values

Inherited from org.python.core.AbstractDict:
tojava