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)
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
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, getConceptsAtPath, getErrorHandler, getInheritedConcepts, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML

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.

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

top
clear

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

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

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

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

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

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

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

top
getConceptElements
Returns: Series

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

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

Returns the key at the specified index.

top
getKeys
Returns: Series

Returns a Series containing all the keys of this Map.

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

Returns the value of this key.

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

Returns the value at the specified index.

top
getValues
Returns: Series

Returns a Series containing all the values of this Map.

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

Sets the index value to the given value.

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.

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.

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

Adds a new element with the given key and value to the end of this Map.

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.

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

top
nextKey
Returns: Concept

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

top
nextValue
Returns: Concept

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

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

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

top