แชร์ผ่าน


Map Class

Definition

The Map class lets to associate one value (the key) with another value.

public ref class Map : Microsoft::Dynamics::Ax::Xpp::XppObjectBase
public class Map : Microsoft.Dynamics.Ax.Xpp.XppObjectBase
type Map = class
    inherit XppObjectBase
Public Class Map
Inherits XppObjectBase
Inheritance
Microsoft.Dynamics.AX.KernelInterop.ProxyBase
Map

Remarks

Both the key and the value can be any valid X++ type, including objects. The types of the key and the value are specified in the declaration of the map. The way in which maps are implemented means that access to the values is very fast. Multiple keys can map to the same value, but one key can map to only one value at a time. If you add a (key, value) pair that has an existing key value, it replaces the existing pair with that key value. The (key, value) pairs in a map can be traversed by using the MapEnumerator class.

The following example illustrates how to invert a map. A map can be inverted only if no value is mapped to by two different keys. The number of elements in the Map.keySet method and the Map.valueSet method is compared to check this. Otherwise, the elements are traversed in the incoming map and inserted into the result map. The function that performs the inversion, the invertMap method, works regardless of the types of the keys and values.

{ 
    Map example; 
    Map invertMap(map _mapToInvert) 
    { 
        MapEnumerator en; 
        Map result =  new Map( 
            _mapToInvert.valueType(), 
            _mapToInvert.keyType()); 
        if (_mapToInvert.keySet().elements()  
            != _mapToInvert.valueSet().elements()) 
        { 
            return null; 
        } 
        en = new MapEnumerator(_mapToInvert); 
        while (en.moveNext()) 
        { 
            result.insert(en.currentValue(), en.currentKey()); 
        } 
        return result; 
    } 
    ; 
    // Fill in a few values. 
    example = new Map(Types::Integer, Types::String); 
    example.insert (1, "one"); 
    example.insert (2, "two"); 
    print invertMap(example).toString(); 
    pause; 
    // Now two keys (2 and 3) map to the same value 
    // so can't create inverse map 
    example.insert (3, "two"); 
    if (!invertMap(example)) 
    { 
        print "Could not create the map"; 
    } 
    pause; 
}

Constructors

Map()
Map(Types, Types)

Fields

kernelClass (Inherited from XppObjectBase)

Properties

AxClassId
GlobalType

Methods

__shouldCallNew(Type) (Inherited from XppObjectBase)
addXppProxyReference(Type, Object) (Inherited from XppObjectBase)
Call(String, Object[], Type[], Object[]) (Inherited from XppObjectBase)
cancelTimeOut(Int32) (Inherited from XppObjectBase)
create(Object[])

Creates a map from the container that was obtained from a previous call to the Map.pack method.

createFromXML(XppObjectBase)
createKernelClass(Object[], Type[], Object[]) (Inherited from XppObjectBase)
definitionString()

Returns a string that contains a definition of the map.

domainSet()

Creates a set of the key (domain) values in a map.

domainType()

Determines the type of the key (domain) values in a map.

DotNetCollectionToXppCollection<TKey,TValue>(Dictionary<TKey,TValue>, Types, Types)
elements()

Returns the number of elements in the map.

empty()

Determines whether the map contains any (key, value) pairs.

equal(Map, Map)

Determines whether two maps are equal.

equal(XppObjectBase) (Inherited from XppObjectBase)
exists(Object)

Determines whether a particular value exists as a key in the map.

finalize() (Inherited from XppObjectBase)
getEnumerator()

Creates an enumerator for the map, which lets you traverse the map.

GetIntPtr()
GetKernelInstanceUniqueId() (Inherited from XppObjectBase)
getTimeOutTimerHandle() (Inherited from XppObjectBase)
getXppProxyReference(Type) (Inherited from XppObjectBase)
handle()
insert(Object, Object)

Inserts an element (keyValue, valueValue pair) into the map.

IsManagedValid()
kernelhandle()
KernelInstanceDisposed() (Inherited from XppObjectBase)
keySet()

Returns a set that contains the key values from a map.

keyType()

Returns the type of the key values in a map.

lookup(Object)

Returns the value that is mapped to by a specified key value.

MakeReflectionCall(String, Object[]) (Inherited from XppObjectBase)
newmethod() (Inherited from XppObjectBase)
newmethod(Types, Types)

Creates a new map.

notify() (Inherited from XppObjectBase)
notifyAll() (Inherited from XppObjectBase)
objectOnServer()
Obsolete.
(Inherited from XppObjectBase)
pack()

Serializes the current instance of the Map class.

rangeSet()

Returns a set that contains the values (ranges) that are mapped to by the keys in a map.

rangeType()

Determines the type of the values (ranges) that are mapped to by the keys in a map.

remove(Object)

Removes a (key, value) pair from a map.

setTimeOut(String, Int32, Boolean)
Obsolete.
(Inherited from XppObjectBase)
setTimeOut(String, Int32)
Obsolete.
(Inherited from XppObjectBase)
ToString()

Returns a description of the (key, value) pairs in the map.

usageCount() (Inherited from XppObjectBase)
valueSet()

Returns a set that contains the values that are mapped to by the keys in a map.

valueType()

Returns the type of the values that are mapped to by the keys in a map.

VerifyKernelClass() (Inherited from XppObjectBase)
wait() (Inherited from XppObjectBase)
Xml()

Returns an XML string that represents the current object.

Xml(Int32)
XppCollectionToDotNetCollection<TKey,TValue>(Map)

Applies to