codesimian
Class StringTree

java.lang.Object
  extended by codesimian.CS<CSGeneric>
      extended by codesimian.DefaultCS
          extended by codesimian.SimpleList
              extended by codesimian.StringTree
All Implemented Interfaces:
CodeSimian

Deprecated. use CharTree instead

public class StringTree
extends SimpleList

A tree whose internal nodes are simple lists and whose leafs are strings (class S). This allows any string to have chars or other strings efficiently inserted anywhere or any range or subset efficiently deleted.

The childs of a node in this tree must be hidden, because the visible childs are mapped from tree nodes below. Every char in every string in every position in the tree has a unique index in the root. root.PC(57) returns char number 57, found somewhere within the tree, but it appears to be in the root. This is recursively true for any node in the tree.

When this string gets too big, should automaticly split childs[] into a larger array, creating new StringTrees to fill the new indexs.

THIS CLASS IS NOT FINISHED. When its done, TextAreaCS.java could become much faster by storing its string as a StringTree and only calling the paint() function every 50 milliseconds or every textlength/30 chars whichever is shorter. THIS CLASS COULD BE MADE MUCH MORE EFFICIENT BY DIRECTLY IMPLEMENTING ALL FUNCTIONS IN THE codesimian.CodeSimian interface. COULD ALSO BE MORE EFFICIENT BY IMPLEMENTING L AND SETL FOR ALL PRIMITIVE ARRAY TYPES. STRANGE ERRORS COULD OCCUR WITH ARRAYS OF STRINGS.

WARNING: if the tree (branching with the hidden childs[] array) becomes a network and that network contains a CYCLE then infinite loops will occur. Networks without cycles are ok.

Since this is a tree where leafs are usually S objects, P(int) should return objects from the constant-pool.


Field Summary
 
Fields inherited from class codesimian.CS
DESCRIPTION, END, EXECPROXY, HEAP, JAVACODE, MYFUEL, NAME, NEWINSTANCE, NULL, PARENT, PARSEPRIORITY, PREV, TESTER, THIS
 
Constructor Summary
StringTree()
          Deprecated.  
StringTree(CS[] childs)
          Deprecated.  
 
Method Summary
 int approximateheight(int randomPathsToMeasure)
          Deprecated. Returns the approximate height of this StringTree as a tree node above its lowest leaf.
 int[] childSizes()
          Deprecated.  
 int countP()
          Deprecated. Quantity of params.
 boolean deleteP(int index)
          Deprecated. WARNING: if returns false, could have deleted but not moved other params down 1 index.
WARNING: if duplicates not allowed, can not slide params down 1 index the standard way, returns false.
 double DForProxy()
          Deprecated. returns this.countP().
 boolean insertP(int index, CS ins)
          Deprecated. same as setP(int,CS) but inserts instead of overwriting.
 byte isIllusion(int index)
          Deprecated. Describes if the CS in an index is an illusion or not.
 boolean isLeaf(CS treeNode)
          Deprecated. a hack, checks if treeNode instanceof S, the default string type.
 java.lang.String keyword()
          Deprecated. For the CodeSimian language as a String.
CodeSimian language keyword, like "+" "*" "max" ">" etc.

Override this function if you want to specify a keyword other than how I derive them from the class name, like + for Add.

Some CSs might never be intended to be used in the language by their keyword.
The best example (4/05) is Num, because it is used in the language like "3.4" instead of "num()".
 int maxP()
          Deprecated. Maximum quantity of Params
 boolean mergeSmallest2Childs()
          Deprecated.  
 int minP()
          Deprecated. For DForProxy().
Minimum number of parameters in param[] needed to call DForProxy().
Defines which indexs of param[] DForProxy() can use.
Functions with a different number of parameters must override this.
OVERRIDE THIS FUNCTION IF EXEC USES A DIFFERENT NUMBER OF PARAMETERS.
Default is 1.
 CS P(int index)
          Deprecated. WARNING: if add CSs then delete them, they are still in the param[] array and can be returned in this function, despite them being out of valid range: index at least countP().
 boolean pushDownChilds(int start, int quantity)
          Deprecated. removes a range of childs and replaces them with 1 new StringTree containing them
 boolean reshapeTree()
          Deprecated. returns true if tree was changed to have a better shape, like moving chars from a big node to a smaller node
 boolean setP(int index, CS setTo)
          Deprecated. Every CS is a list of other CSs, between size minP() and maxP() inclusive.
 boolean splitBiggestChild()
          Deprecated.  
 int splitBigLeafs()
          Deprecated. splits leafs that are bigger than maxLeafSize, increasing childs.length by 1
 
Methods inherited from class codesimian.DefaultCS
B, C, decrementMyFuel, description, F, fuel, getExec, getObject, heap, I, indexP, indexPName, insertB, insertC, insertD, insertF, insertI, insertJ, insertL, insertL, insertL1, insertS, insertZ, J, javaCode, LForProxy, LForProxy, myFuel, name, newInstance, objectToCS, objectToCSArray, objectToCSArray, prevD, prevL, PType, S, setB, setC, setCountP, setD, setD, setExec, setF, setFuel, setI, setJ, setL, setL, setL, setL1, setMyFuel, setName, setObject, setPrevExec, setPType, setS, setZ, start, toString, V, Z
 
Methods inherited from class codesimian.CS
addB, addC, addD, addF, addI, addJ, addL, addP, addP, addP, addP, addP, addS, addZ, BForProxy, CForProxy, clone, cost, D, deleteP, FForProxy, GETB, GETC, GETD, GETF, GETI, GETJ, GETL, GETS, GETZ, IForProxy, JForProxy, L, L, L, L, L, maxD, minD, overwrites, parent, parsePriority, PB, PC, PD, PF, PI, PJ, PL, prevB, prevC, prevF, prevI, prevJ, prevS, prevZ, proxyOf, PS, PZ, reflect, reflect, reflect6, setB, SETB, setC, SETC, setCost, SETD, setDescription, setF, SETF, setHeap, setI, SETI, setJ, SETJ, SETL, setL, setL, setParent, setParsePriority, setProxyOf, setS, SETS, setTester, setZ, SETZ, SForProxy, tester, toJavaCode, VForProxy, voidReflect, ZForProxy
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringTree

public StringTree()
Deprecated. 

StringTree

public StringTree(CS[] childs)
Deprecated. 
Method Detail

DForProxy

public double DForProxy()
Deprecated. 
Description copied from class: SimpleList
returns this.countP(). This list does nothing.

Overrides:
DForProxy in class SimpleList

keyword

public java.lang.String keyword()
Deprecated. 
Description copied from class: DefaultCS
For the CodeSimian language as a String.
CodeSimian language keyword, like "+" "*" "max" ">" etc.

Override this function if you want to specify a keyword other than how I derive them from the class name, like + for Add.

Some CSs might never be intended to be used in the language by their keyword.
The best example (4/05) is Num, because it is used in the language like "3.4" instead of "num()".
Default: Returns class name, minus package name (and its dots), and change the first letter to lowercase.

For example, CS.MaxParams does not override keyword(), which returns "maxP".

Overrides:
keyword in class SimpleList
See Also:
CS.parent(), CS.newInstance(), CS.name()

minP

public int minP()
Deprecated. 
Description copied from class: DefaultCS
For DForProxy().
Minimum number of parameters in param[] needed to call DForProxy().
Defines which indexs of param[] DForProxy() can use.
Functions with a different number of parameters must override this.
OVERRIDE THIS FUNCTION IF EXEC USES A DIFFERENT NUMBER OF PARAMETERS.
Default is 1.

Overrides:
minP in class SimpleList

maxP

public int maxP()
Deprecated. 
Description copied from class: CS
Maximum quantity of Params

Overrides:
maxP in class SimpleList

countP

public int countP()
Deprecated. 
Description copied from class: CS
Quantity of params. Should be between minP() and maxP() inclusive when you EXECUTE this CS. Can be below minP() for a short time during compiling, but you must not EXECUTE this CS during that time.

Overrides:
countP in class DefaultCS

P

public CS P(int index)
Deprecated. 
Description copied from class: DefaultCS
WARNING: if add CSs then delete them, they are still in the param[] array and can be returned in this function, despite them being out of valid range: index at least countP().

Overrides:
P in class DefaultCS
Parameters:
index - range 0 (or neg?) to countP()-1 inclusive
See Also:
CS.heap()

setP

public boolean setP(int index,
                    CS setTo)
Deprecated. 
Description copied from class: CS
Every CS is a list of other CSs, between size minP() and maxP() inclusive. setP overwrites one of those CSs or adds a new one at the end, depending on the index. If index is between 0 and countP()-1, overwrites. If it equals countP(), adds at end.

Overrides:
setP in class DefaultCS

insertP

public boolean insertP(int index,
                       CS ins)
Deprecated. 
Description copied from class: CS
same as setP(int,CS) but inserts instead of overwriting. All higher params slide up 1 index.

Overrides:
insertP in class DefaultCS

deleteP

public boolean deleteP(int index)
Deprecated. 
Description copied from class: DefaultCS
WARNING: if returns false, could have deleted but not moved other params down 1 index.
WARNING: if duplicates not allowed, can not slide params down 1 index the standard way, returns false.

Overrides:
deleteP in class DefaultCS

isIllusion

public byte isIllusion(int index)
Deprecated. 
Description copied from class: CS
Describes if the CS in an index is an illusion or not. Example (S extends CS): new S("8fakeCSs") contains a String containing 8 chars. It only appears to contain 8 CSs. new S("8fakeCSs").P(3) returns the same as Const.pool('k'); //P(4).C() == 'e' Therefore S should override isIllusion to return 1 for every index.

Since illusions are constantly overwritten (to give the illusion that they change), if isIllusion(x)==1 then it must be true that: overwrites(x)==1 or overwrites(x)==0. It may equal 0 because that says you dont know (even though it is true).

Overrides:
isIllusion in class CS
See Also:
CS.overwrites(int), S.isIllusion(int)

reshapeTree

public boolean reshapeTree()
Deprecated. 
returns true if tree was changed to have a better shape, like moving chars from a big node to a smaller node


mergeSmallest2Childs

public boolean mergeSmallest2Childs()
Deprecated. 

splitBiggestChild

public boolean splitBiggestChild()
Deprecated. 

pushDownChilds

public boolean pushDownChilds(int start,
                              int quantity)
Deprecated. 
removes a range of childs and replaces them with 1 new StringTree containing them


splitBigLeafs

public int splitBigLeafs()
Deprecated. 
splits leafs that are bigger than maxLeafSize, increasing childs.length by 1


childSizes

public int[] childSizes()
Deprecated. 

isLeaf

public boolean isLeaf(CS treeNode)
Deprecated. 
a hack, checks if treeNode instanceof S, the default string type.


approximateheight

public int approximateheight(int randomPathsToMeasure)
Deprecated. 
Returns the approximate height of this StringTree as a tree node above its lowest leaf. Height of any leaf is 0. height of parent of parent of any leaf is 2. A good value for randomPathsToMeasure is 5, or 50 if you use this function rarely.