Imp
[using it]
Interface Manipulation Package v4.0 (2008-06-25) a-projector ©copyright Author


imp.core
Class Structure

java.lang.Object
  extended by imp.core.Value
      extended by imp.core.Structure
All Implemented Interfaces:
Cloneable, Comparable<Value>
Direct Known Subclasses:
Expression, Location, Text

public class Structure
extends Value

Implements the basic capabilities of a static logical-structure with fields and elements.

A logical-structure is a minimal but general specification of a generic ``semantic'' object containing symbolic information.
The textual representation of a logical structure is a well-formed XML construct.
Logical structure : a generic ``semantic'' object. A logical structure is built of: as schematized here:
logical-structure
Defining containers. Data structures or data containers are easily defined by usage conventions of such logical structures:Other data containers (e.g. stacks, sequences, insertion/deletion lists, last-in/first-out list, graphs, trees, etc..) are easily derived from these conventions.


Field Summary
 
Fields inherited from class imp.core.Value
NULL
 
Constructor Summary
Structure(String type)
          Constructs an expression of the given type.
 
Method Summary
 Structure clear()
          Clears type, fields and elements of this logical-structure and return this.
 int indexOf(Value element)
          Searches for the first occurrence of the given element, testing for equality.
 Structure setType(String type)
          Sets the structure type and return this.
 Structure sort(Comparator<Value> comparator, Merger<Value> merger)
          Sorts the elements of this list into ascending order of its elements and return this.
 
Methods inherited from class imp.core.Value
cloneThis, create, get, getWrapping, isCyclic, isName, load, main, save, toString, wrappedObject
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Structure

public Structure(String type)
Constructs an expression of the given type.
This a simple short-hand for new Expression(type).

Parameters:
type - [optional, default is imp:expression] Expression type
Method Detail

clear

public final Structure clear()
Clears type, fields and elements of this logical-structure and return this.


indexOf

public final int indexOf(Value element)
Searches for the first occurrence of the given element, testing for equality.

Parameters:
element - The searched element.
Returns:
The index of the first occurrence of the element is any, or -1 if not found.

setType

public final Structure setType(String type)
Sets the structure type and return this.


sort

public final Structure sort(Comparator<Value> comparator,
                            Merger<Value> merger)
Sorts the elements of this list into ascending order of its elements and return this.
The sorting algorithm is a modified merge-sort, with a n * log(n) performance.

Parameters:
comparator - [optional, default is null] Defines how two elements are compared. If null, sorts according to the natural ordering.
merger - [optional, default is null] Defines how two equal elements are merged. If null, equal elements are not merged and not reordered.