Factor (NeoBio API)

Overview | Package | Class | Tree | Index | Help
| NeoBio API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## neobio.alignment
Class Factor

    java.lang.Object
      |
      +--neobio.alignment.Factor

public class Factor
extends java.lang.Object

This class is used by FactorSequence to create a linked list of factors of a text as induced by its Lempel-Ziv (LZ78) factorisation.

Each instance of this class represent a string composed of its an ancestor factor's string plus one character, and contains:

- a pointer to its ancestor factor (the longest factor previously seen in the text during its LZ78 factorisation);
- the new character;
- a serial number (which represents its order in the text)
- a pointer to the next factor of the text
- its length (number of characters, which is equal to its ancestor's length plus one)

Author:
  Sergio A. de Carvalho Jr.
See Also:
  `FactorSequence`

Field Summary
`protected Factor` | `ancestor` A pointer to this factor's ancestor, which represents a prefix of this factor's text.
`protected int` | `length` The number of characters of the text represented by this factor.
`protected char` | `new_char` The new character of this factor.
`protected Factor` | `next` A pointer to the next factor.
`protected int` | `serial_number` This factor's serial number, which indicates the order of this factor inside the linked list of factors of a text.

Constructor Summary
`Factor()` Creates a new empty `Factor`.
`Factor(Factor ancestor, int serial_number, char new_char)` Creates a new `Factor` instance with the specified serial number and new character, and pointing to the given ancestor.

Method Summary
`Factor` | `getAncestor()` Returns this factor's ancestor factor.
`int` | `getAncestorSerialNumber()` This method is a shorthand to return the serial number of this factor's ancestor.
`char` | `getNewChar()` Returns this factor's new character.
`Factor` | `getNext()` Returns this factor's next factor.
`int` | `getSerialNumber()` Returns this factor's serial number.
`int` | `length()` Returns this factor's length.
`void` | `setNext(Factor next)` Sets this factor's `next` pointer to point to the specified factor.
`java.lang.String` | `toString()` Returns a string representation of the text represented by this factor.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### ancestor

    protected Factor ancestor

  A pointer to this factor's ancestor, which represents a prefix of this factor's text.

### next

    protected Factor next

  A pointer to the next factor.

### serial_number

    protected int serial_number

  This factor's serial number, which indicates the order of this factor inside the linked list of factors of a text.

### length

    protected int length

  The number of characters of the text represented by this factor.

### new_char

    protected char new_char

  The new character of this factor.

Constructor Detail

### Factor

    public Factor()

  Creates a new empty `Factor`. It has no ancestor and no character (both are set to `null`). Its serial number is set to zero as well as its length.

  This constructor is used to initiate the a linked list of factors of a text. Its `next` pointer is initially `null`, but it is typically set to point to the first factor afterwards (with the `setNext` method).

See Also:
  `setNext(neobio.alignment.Factor)`

### Factor

    public Factor(Factor ancestor,
                  int serial_number,
                  char new_char)

  Creates a new `Factor` instance with the specified serial number and new character, and pointing to the given ancestor. Its length is set to its ancestor's length plus 1.

  Its `next` pointer is initially `null`, but it is typically set to point to the next factor afterwards (with the `setNext` method).

Parameters:
  `ancestor` - this factor's ancestor
  `serial_number` - this factor's serial number
  `new_char` - this factor's new character
See Also:
  `setNext(neobio.alignment.Factor)`

Method Detail

### setNext

    public void setNext(Factor next)

  Sets this factor's `next` pointer to point to the specified factor. Although the next factor has typically a serial number equal to this factor's serial number plus 1, no attempt is made to guarantee this rule. This allows special constructs or a different order in the factorisation.

  Parameters:
    `next` - the factor that will be pointed to
  See Also:
    `getNext()`

### getAncestor

    public Factor getAncestor()

  Returns this factor's ancestor factor.

  Returns:
    this factor's ancestor factor

### getAncestorSerialNumber

    public int getAncestorSerialNumber()

  This method is a shorthand to return the serial number of this factor's ancestor. Note that it does not check if this factor has an ancestor or not, therefore, if it is called on the root factor, a NullPointerException is raised.

  Returns:
    the serial number of this factor's ancestor

### getNext

    public Factor getNext()

  Returns this factor's next factor.

  Returns:
    this factor's next factor
  See Also:
    `setNext(neobio.alignment.Factor)`

### getSerialNumber

    public int getSerialNumber()

  Returns this factor's serial number.

  Returns:
    this factor's serial number

### length

    public int length()

  Returns this factor's length.

  Returns:
    this factor's length

### getNewChar

    public char getNewChar()

  Returns this factor's new character.

  Returns:
    this factor's new character

### toString

    public java.lang.String toString()

  Returns a string representation of the text represented by this factor. It inspects its chain of ancestors up until as far as the root factor, spelling their new characters out.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    a string representation of the text denoted by this factor

Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

http://neobio.sourceforge.net
NeoBio is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. NeoBio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with NeoBio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.