mn8 Language Reference | Index    

Map

SUMMARY: ATTRIBUTES SUMMARY  NO ELEMENTS  NO CONSTRUCTORS  NO OPERATORS  METHODS SUMMARYDETAIL: ATTRIBUTE DETAILS  NO ELEMENTS  NO CONSTRUCTORS  NO OPERATORS  METHOD DETAILS

Description

A map is a set of items mapped to a key and organized in an specific order . There is no restrictions related to duplicates of the elements of the map, but the keys that map them must be unique. A map does not perform (in an automatic manner) any ordering (unless wonted) of the elements. A map can contain any kind of data type including other maps in it's elements but the keys are restricted to primitive data types (except nil).

Usage

The length specify the number of items this Map contains.

            $map TYPEOF Map
            $map.add("colors", "red,yellow,blue".getTokens(","))
            $map.add("numbers", "one,two,three".getTokens(","))
            $map.add("flawres", "rose,tulip".getTokens(","))

            PRINT $map@length
            3

The index specify the current position of the cursor in the Map, also used to move the cursor at the wanted position. Initially the index is positioned at the first element of the map.

 $map TYPEOF Map
            $map.add("colors", "red,yellow,blue".getTokens(","))
            $map.add("numbers", "one,two,three".getTokens(","))
            $map.add("flawres", "rose,tulip".getTokens(","))

            print $map.nextValue
                red
                yellow
                blue
            $map@index=2
            print $map.nextValue
                rose
                tulip

The hasNext specify whenever the index represents the last element of the series or not.

            $map TYPEOF Map
            $map.add("colors", "red,yellow,blue".getTokens(","))
            $map.add("numbers", "one,two,three".getTokens(","))
            $map.add("flawres", "rose,tulip".getTokens(","))

            print $map@hasNext
                true

            $map@index=3
            print $map@hasNext
                false

The hasPrevious specify whenever the index represents the first element of the series or not.

            $map TYPEOF Map
            $map.add("colors", "red,yellow,blue".getTokens(","))
            $map.add("numbers", "one,two,three".getTokens(","))
            $map.add("flawres", "rose,tulip".getTokens(","))

            PRINT $map@hasPrevious
                false

            $map@index = 3
            PRINT $map@hasPrevious
                true

Version: 0.1
Authors:Remus Pereni (http://neuro.nolimits.ro)
Location:
Inherits: Concept
Inherited by: HTMLForm

Attribute List

 @hasNext TYPEOF Logical LABEL "Has next "
 @hasPrevious TYPEOF Logical LABEL "Has previous "
 @index TYPEOF Integer LABEL "Index"
 @length TYPEOF Integer LABEL "Length"
top

Method List

add (Concept $key, Concept $value)
clear
LogicalcontainsKey (Concept $key)
LogicalcontainsValue (Concept $value)
ConceptgetConceptElement (String $elem)
SeriesgetConceptElements
FieldgetConceptElementField (String $elem)
SeriesgetConceptElementFields
ConceptgetKeyAt (Integer $index)
SeriesgetKeys
ConceptgetValue (Concept $key)
ConceptgetValueAt (Integer $index)
SeriesgetValues
setIndex (Integer $index)
IntegerindexOfKey (Concept $key)
IntegerindexOfValue (Concept $value)
insert (Concept $key, Concept $value)
insert (Integer $index, Concept $key, Concept $value)
ConceptnextKey
ConceptnextValue
remove (Concept $key)
top
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI

Detailed Attribute Info

@hasNext

Label:Has next
Type:Logical
Is Static:false
Is Hidden:false
Show Empty:true

Specify whenever the index represents the last element of the series or not.

top

@hasPrevious

Label:Has previous
Type:Logical
Is Static:false
Is Hidden:false
Show Empty:true

Specify whenever the index represents the first element of the series or not.

top

@index

Label:Index
Type:Integer
Is Static:false
Is Hidden:false
Show Empty:true

Specify the current position of the cursor in the Map, also used to move the cursor at the wanted position. Initially the index is positioned at the first element of the map.

top

@length

Label:Length
Type:Integer
Is Static:false
Is Hidden:false
Show Empty:true

Specify the number of items this Map contains.

top

Detailed Method Info

add (Concept $key, Concept $value)
Parameters:
$key :The key to add.
$value :The concept to add.
Returns:

Adds the given concept with the specified key to this Map.

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.add("3", "three")
            print $m@length
            -- the result is --
            3
            

top
clear
Returns:

Removes all of the elements from this Map. The Map will be empty after this.

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.add("3", "three")
            print $m@length
            $m.clear
            print $m@length
            -- the result is --
            3
            0
            

top
containsKey (Concept $key)
Parameters:
$key :Any concept.
Returns: Logical

Returns true if the specified concept is a key in this Map, false otherwise.

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.add("3", "three")
            print $m.containsKey("2")
            -- the result is --
            true
            

top
containsValue (Concept $value)
Parameters:
$value :Any concept.
Returns: Logical

Returns true if the specified concept is a value in this Map, false otherwise.

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.add("3", "three")
            print $m.containsValue("one")
            -- the result is --
            true
            

top
getConceptElement (String $elem)
Parameters:
$elem :Element name.
Returns: Concept

Returns the element with the specified name if it can be found in this Map, nil otherwise.

            $m typeof Map
            $m.add(1, "one")
            $m.add(2, "two")
            $m.add(3, "three")
            print $m.getConceptElement("2")
            -- the result is --
            2 two
            

top
getConceptElements
Returns: Series

Returns a Series containing elements of type String with the name of the elements defined in this concept.

            $m typeof Map
            $m.add(1, "one")
            $m.add(2, "two")
            $m.add(3, "three")
            print $m.getConceptElements
            -- the result is --
            1 one
            2 two
            3 three
            

top
getConceptElementField (String $elem)
Parameters:
$elem :Element field name.
Returns: Field

Returns the element field definition with the specified name if it can be found in this Map, nil otherwise.

            $m typeof Map
            $m.add(1, "one")
            $m.add(2, "two")
            $m.add(3, "three")
            print $m.getConceptElementField("2")
            -- the result is --
            2 TYPEOF String LABEL "2"
            

top
getConceptElementFields
Returns: Series

Returns a Series containing element fields.

            $m typeof Map
            $m.add(1, "one")
            $m.add(2, "two")
            $m.add(3, "three")
            print $m.getConceptElementFields
            -- the result is --
            1 TYPEOF String LABEL "1"
            2 TYPEOF String LABEL "2"
            3 TYPEOF String LABEL "3"
            

top
getKeyAt (Integer $index)
Parameters:
$index :The index of the key.
Returns: Concept

Returns the key at the specified index.

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.add("3", "three")
            print $m.getKeyAt(3)
            -- the result is --
            3
            

top
getKeys
Returns: Series

Returns a Series containing all the keys of this Map.

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.add("3", "three")
            print $m.getKeys
            -- the result is --
            1
            2
            3
            

top
getValue (Concept $key)
Parameters:
$key :The key for value.
Returns: Concept

Returns the value of this key.

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.add("3", "three")
            print $m.getValue("3")
            -- the result is --
            three
            

top
getValueAt (Integer $index)
Parameters:
$index :The index of the value.
Returns: Concept

Returns the value at the specified index.

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.add("3", "three")
            print $m.getValueAt(1)
            -- the result is --
            one
            

top
getValues
Returns: Series

Returns a Series containing all the values of this Map.

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.add("3", "three")
            print $m.getValues
            -- the result is --
            one
            two
            three
            

top
setIndex (Integer $index)
Parameters:
$index :New index.
Returns:

Sets the index value to the given value.

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.add("3", "three")
            $m.setIndex(2)
            print $m.nextValue
            -- the result is --
            three
            

top
indexOfKey (Concept $key)
Parameters:
$key :Any concept.
Returns: Integer

Returns the index of the specified concept if that is a key in this Map.

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.add("3", "three")
            print $m.indexOfKey("1")
            -- the result is --
            1
            

top
indexOfValue (Concept $value)
Parameters:
$value :Any concept.
Returns: Integer

Returns the index of the specified concept if that is a value in this Map.

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.add("3", "three")
            print $m.indexOfValue("three")
            -- the result is --
            3
            

top
insert (Concept $key, Concept $value)
Parameters:
$key :The key to be added.
$value :The value to be added.
Returns:

Adds a new element with the given key and value to the current index position in this Map.

            $m typeof Map
            $m.insert("1", "one")
            $m.insert("2", "two")
            $m.insert("3", "three")
            print $m
            -- the result is --
            Map
            3 three
            2 two
            1 one
            

top
insert (Integer $index, Concept $key, Concept $value)
Parameters:
$index :The position at which to insert the new Element.
$key :The key to be added.
$value :The value to be added.
Returns:

Adds the new element with with the given key and value to this Map at the given position.

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.insert(2, "3", "three")
            print $m
            -- the result is --
            Map
            1 one
            3 three
            2 two
            

top
nextKey
Returns: Concept

Returns the next key after the one marked by the index of the map and sets the index on it.

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.add("3", "three")
            while ($m@hasNext) do [
              print $m.nextKey
            ]
            -- the result is --
            1
            2
            3
            

top
nextValue
Returns: Concept

Returns the next value after the one marked by the index of the map and sets the index on it.

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.add("3", "three")
            while ($m@hasNext) do [
              print $m.nextValue
            ]
            -- the result is --
            one
            two
            three
            

top
remove (Concept $key)
Parameters:
$key :Any concept.
Returns:

Removes the key given as parameter and the value that belong to it from this Map..

            $m typeof Map
            $m.add("1", "one")
            $m.add("2", "two")
            $m.add("3", "three")
            $m.remove("2")
            print $m
            -- the result is --
            Map
            1 one
            3 three
            

top