W3cubDocs

/Haxe

Map<K, V>(IMap<K, V>)

no package

Available on all platforms

Map allows key to value mapping for arbitrary value types, and many key types.

This is a multi-type abstract, it is instantiated as one of its specialization types depending on its type parameters.

A Map can be instantiated without explicit type parameters. Type inference will then determine the type parameters from the usage.

Maps can also be created with key1 => value1, key2 => value2 syntax.

Map is an abstract type, it is not available at runtime.

See:

Constructor

@:extern @:impl new ()

Creates a new Map.

This becomes a constructor call to one of the specialization types in the output. The rules for that are as follows:

  1. if K is a String, haxe.ds.StringMap is used
  2. if K is an Int, haxe.ds.IntMap is used
  3. if K is an EnumValue, haxe.ds.EnumValueMap is used
  4. if K is any other class or structure, haxe.ds.ObjectMap is used
  5. if K is any other type, it causes a compile-time error

(Cpp) Map does not use weak keys on ObjectMap by default.

Methods

@:impl @:arrayAccess @:noCompletion inline arrayWrite (this:IMap<K, V>, k:K ):V

@:impl inline exists (this:IMap<K, V>):Bool

Returns true if key has a mapping, false otherwise.

If key is null, the result is unspecified.

@:impl @:arrayAccess inline get (this:IMap<K, V>):Null<V>

Returns the current mapping of key.

If no such mapping exists, null is returned.

Note that a check like map.get(key) == null can hold for two reasons:

  1. the map has no mapping for key
  2. the map has a mapping with a value of null

If it is important to distinguish these cases, exists() should be used.

If key is null, the result is unspecified.

@:impl inline iterator ():Iterator<V>

Returns an Iterator over the values of this Map.

The order of values is undefined.

@:impl inline keys ():Iterator<K>

Returns an Iterator over the keys of this Map.

The order of keys is undefined.

@:impl inline remove (this:IMap<K, V>):Bool

Removes the mapping of key and returns true if such a mapping existed, false otherwise.

If key is null, the result is unspecified.

@:impl inline set (this:IMap<K, V>, key:K ):Void

Maps key to value.

If key already has a mapping, the previous value disappears.

If key is null, the result is unspecified.

@:impl inline toString ():String

Returns a String representation of this Map.

The exact representation depends on the platform and key-type.

Static methods

@:extern @:impl static new ()

Creates a new Map.

This becomes a constructor call to one of the specialization types in the output. The rules for that are as follows:

  1. if K is a String, haxe.ds.StringMap is used
  2. if K is an Int, haxe.ds.IntMap is used
  3. if K is an EnumValue, haxe.ds.EnumValueMap is used
  4. if K is any other class or structure, haxe.ds.ObjectMap is used
  5. if K is any other type, it causes a compile-time error

(Cpp) Map does not use weak keys on ObjectMap by default.

@:impl @:arrayAccess @:noCompletion static inline arrayWrite (this:IMap<K, V>, k:K ):V

@:impl static inline exists (this:IMap<K, V>):Bool

Returns true if key has a mapping, false otherwise.

If key is null, the result is unspecified.

@:impl @:arrayAccess static inline get (this:IMap<K, V>):Null<V>

Returns the current mapping of key.

If no such mapping exists, null is returned.

Note that a check like map.get(key) == null can hold for two reasons:

  1. the map has no mapping for key
  2. the map has a mapping with a value of null

If it is important to distinguish these cases, exists() should be used.

If key is null, the result is unspecified.

@:impl static inline iterator ():Iterator<V>

Returns an Iterator over the values of this Map.

The order of values is undefined.

@:impl static inline keys ():Iterator<K>

Returns an Iterator over the keys of this Map.

The order of keys is undefined.

@:impl static inline remove (this:IMap<K, V>):Bool

Removes the mapping of key and returns true if such a mapping existed, false otherwise.

If key is null, the result is unspecified.

@:impl static inline set (this:IMap<K, V>, key:K ):Void

Maps key to value.

If key already has a mapping, the previous value disappears.

If key is null, the result is unspecified.

@:impl static inline toString ():String

Returns a String representation of this Map.

The exact representation depends on the platform and key-type.

© 2005–2018 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/Map.html