org.ahmadsoft.ropes.impl
Class ReverseRope

java.lang.Object
  extended by org.ahmadsoft.ropes.impl.AbstractRope
      extended by org.ahmadsoft.ropes.impl.ReverseRope
All Implemented Interfaces:
java.io.Serializable, java.lang.CharSequence, java.lang.Comparable<java.lang.CharSequence>, java.lang.Iterable<java.lang.Character>, Rope

public final class ReverseRope
extends AbstractRope

A rope representing the reversal of character sequence. Internal implementation only.

Author:
Amin Ahmad
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.ahmadsoft.ropes.Rope
BUILDER
 
Constructor Summary
ReverseRope(Rope rope)
          Constructs a new rope from an underlying rope.
 
Method Summary
 char charAt(int index)
           
 byte depth()
           
 java.util.Iterator<java.lang.Character> iterator(int start)
          Returns an iterator positioned to start at the specified index.
 int length()
           
 Rope reverse()
          Reverses this rope.
 java.util.Iterator<java.lang.Character> reverseIterator(int start)
          Returns a reverse iterator positioned to start at the specified index.
 Rope subSequence(int start, int end)
           
 void write(java.io.Writer out)
          Write this rope to a Writer.
 void write(java.io.Writer out, int offset, int length)
          Write a range of this rope to a Writer.
 
Methods inherited from class org.ahmadsoft.ropes.impl.AbstractRope
append, append, append, compareTo, delete, endsWith, endsWith, equals, hashCode, indexOf, indexOf, indexOf, indexOf, insert, isEmpty, iterator, matcher, matches, matches, padEnd, padEnd, padStart, padStart, rebalance, reverseIterator, startsWith, startsWith, toString, trim, trimEnd, trimStart, writeReplace
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReverseRope

public ReverseRope(Rope rope)
Constructs a new rope from an underlying rope.

Balancing algorithm works optimally when only FlatRopes or SubstringRopes are supplied. Framework must guarantee this as no runtime check is performed.

Parameters:
rope -
Method Detail

charAt

public char charAt(int index)

depth

public byte depth()
Specified by:
depth in class AbstractRope

iterator

public java.util.Iterator<java.lang.Character> iterator(int start)
Description copied from interface: Rope
Returns an iterator positioned to start at the specified index.

Parameters:
start - the start position.
Returns:
an iterator positioned to start at the specified index.

length

public int length()

reverse

public Rope reverse()
Description copied from interface: Rope
Reverses this rope.

Returns:
a reversed copy of this rope.

reverseIterator

public java.util.Iterator<java.lang.Character> reverseIterator(int start)
Description copied from interface: Rope
Returns a reverse iterator positioned to start at the specified index. A reverse iterator moves backwards instead of forwards through a rope.

Parameters:
start - the start position.
Returns:
a reverse iterator positioned to start at the specified index from the end of the rope. For example, a value of 1 indicates the iterator should start 1 character before the end of the rope.
See Also:
Rope.reverseIterator()

subSequence

public Rope subSequence(int start,
                        int end)

write

public void write(java.io.Writer out)
           throws java.io.IOException
Description copied from interface: Rope
Write this rope to a Writer.

Parameters:
out - the writer object.
Throws:
java.io.IOException

write

public void write(java.io.Writer out,
                  int offset,
                  int length)
           throws java.io.IOException
Description copied from interface: Rope
Write a range of this rope to a Writer.

Parameters:
out - the writer object.
offset - the range offset.
length - the range length.
Throws:
java.io.IOException


Copyright © 2007 Amin Ahmad. All Rights Reserved.