mn8 Language Reference | Index    

Series

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

Description

Series is a set of items organized in an specific order. There is no restrictions related to duplicates, and does not perform (in an automatic manner) any ordering (unless wonted) of the elements. A series can also contain any kind of data type including other series.

Usage

The number of items this Series contains.

            $list = "one;two;three".getTokens(";")
            print $list@length
                3

            $list1 typeof Series
            $list1.add("one")
            $list1.add("two")
            $list1.add("red,blue".getTokens(","))
            print $list1@length
                3

The current position of the cursor in the Series, also used to move the cursor at the wanted position.

            $list = "one;two;three".getTokens(";")
            PRINT $list@index
                0

            PRINT $list/$list.index
                one

            PRINT $list/2
                two

            $list@index = 3
            $nr=$list@index
            PRINT $list/$nr
                three

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

            $list = "one;two;three".getTokens(";")
            PRINT $list@hasNext
                true

            $list@index = 3
            PRINT $list@hasNext
                false

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

            $list = "one;two;three".getTokens(";")
            PRINT $list@hasPrevious
            false

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

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

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

IntegerIndexOf (Concept $value)
add (Concept $value)
Logicalcontains (Concept $value)
Conceptcurrent
ConceptelementAt (Integer $position)
ConceptgetConceptElement (String $elem)
SeriesgetConceptElements
insert (Integer $index, Concept $value)
insert (Concept $value)
Conceptnext
Conceptprevious
Conceptremove
Conceptremove (Integer $ind)
setIndex (Integer $index)
setValue (Integer $index, Concept $newValue)
sort (Concept $sorter)
StringtoTXT
StringtoXML
top

Detailed Attribute Info

@hasNext

Label:Has next
Type:Logical
Is Static:false
Is Hidden:true
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:true
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:true
Show Empty:true

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

top

@length

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

Specify the number of items this Series contains.

top

Detailed Method Info

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

If the concept argument occurs in this Series then his index is returned, else -1 returned.

            $s typeof Series
            $s.add("red")
            $s.add("green")
            $s.add("blue")
            print $s.indexOf("blue")
            -- the result is --
            3
            

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

Appends the concept given as parameter to the end of this Series.

            $s typeof Series
            $s.add("red")
            $s.add("green")
            print $s
            $s.add("blue")
            print $s
            -- the result is --
            red
            green
            red
            green
            blue
            

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

Returns true if this Series contains the specified concept, false otherwise.

            $s typeof Series
            $s.add("red")
            $s.add("green")
            $s.add("blue")
            print $s.contains("blue")
            -- the result is --
            true
            

top
current
Returns: Concept

Returns the concept from the position to which the index point.

            $s typeof Series
            $s.add("red")
            $s.add("green")
            $s.add("blue")
            $s.setIndex(2)
            print $s.current
            -- the result is --
            green
            

top
elementAt (Integer $position)
Parameters:
$position :The index of the required item.
Returns: Concept

Returns the concept at the specified position or nil if the position doesn't exist.

            $s typeof Series
            $s.add("red")
            $s.add("green")
            $s.add("blue")
            print $s.elementAt(3)
            -- the result is --
            blue
            

top
getConceptElement (String $elem)
Parameters:
$elem :Element name.
Returns: Concept
Exceptions:
noSuchElement :
(Warning)
If the concept does not have such an Element.

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

            $s typeof Series
            $s.add("red")
            $s.add("green")
            $s.add("blue")
            print $s.getConceptElement("string")
            -- the result is --
            red
            green
            blue
            

top
getConceptElements
Returns: Series

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

            $s typeof Series
            $s.add("red")
            $s.add("green")
            $s.add("blue")
            print $s.getConceptElements
            -- the result is --
            red
            green
            blue
            

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

Adds the specified Concept to this Series at the given position.

            $s typeof Series
            $s.add("red")
            $s.add("green")
            $s.insert(2, "blue")
            print $s
            -- the result is --
            red
            blue
            green
            

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

Adds the specified component to the end of this Series.

            $s typeof Series
            $s.insert("red")
            $s.insert("green")
            $s.insert("blue")
            print $s
            -- the result is --
            red
            green
            blue
            

top
next
Returns: Concept

Returns the next element after the one marked by the index of the series and sets the index on it.

            $s typeof Series
            $s.add("red")
            $s.add("green")
            $s.add("blue")
            print $s.next
            print $s.next
            -- the result is --
            red
            green
            

top
previous
Returns: Concept

Returns the element before the one marked by the index of the series and sets the index on it.

            $s typeof Series
            $s.add("red")
            $s.add("green")
            $s.add("blue")
            $s.setIndex(3)
            print $s.previous
            print $s.previous
            -- the result is --
            green
            red
            

top
remove
Returns: Concept

Removes the element marked by the index and sets the index on the next element, if it is available, on the previous one if it is not.

            $s typeof Series
            $s.add("red")
            $s.add("green")
            $s.add("blue")
            $s.setIndex(2)
            $s.remove
            print $s
            -- the result is --
            red
            blue
            

top
remove (Integer $ind)
Parameters:
$ind :The index position
Returns: Concept

Removes the element marked by the parameter and sets the index on the next element, if it is available, on the previous one if it is not.

            $s typeof Series
            $s.add("red")
            $s.add("green")
            $s.add("blue")
            $s.remove(2)
            print $s
            -- the result is --
            red
            blue
            

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

Sets the index value to the given value.

            $s typeof Series
            $s.add("red")
            $s.add("green")
            $s.add("blue")
            $s.setIndex(1)
            print $s.current
            $s.setIndex(3)
            print $s.current    
            -- the result is --
            red
            blue
            

top
setValue (Integer $index, Concept $newValue)
Parameters:
$index :The index of the value to be replaced.
$newValue :The new value.
Returns:

Sets the value at the position specified by the $index parameter to the new value.

            $ser typeof Series
            $ser.add("red")
            $ser.add("yellow")
            $ser.add("blue")
            print $ser
            $ser.setValue(2, "green")
            print $ser
            -- the result is --
            red
            yellow
            blue
            red
            green
            blue
            

top
sort (Concept $sorter)
Parameters:
$sorter :

Any SorterConcept. The SorterConcept is a simple concept which contains at least one method which accepts two concepts as parameters and produce an integer which has a value of zero if the concepts are equals, +1 if the first concept is greater than the second and -1 if the first concept is less than the second. In this way we can provide a simple way to allow anybody to produce their own sorting methods specially fitted for their problems and data types.

Returns:

Sorts the series. If no parameter is specified it will sort the series based on the value of the items found in it in alphabetical order. If a SorterConcept is specified as parameter it's compare method will be used to produce the sorting of the series.

top
toTXT
Returns: String

Returns a stream representing the simple text rendering of this concept.

            $s typeof Series
            $s.add("red")
            $s.add("green")
            $s.add("blue")
            print $s.toTXT
            -- the result is --
            red
            green
            blue
            

top
toXML
Returns: String

Returns a stream representing the XML rendering of this concept.

            $s typeof Series
            $s.add("red")
            $s.add("green")
            $s.add("blue")
            print $s.toTXT
            -- the result is --
            redgreenblue
            

top