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

## com.mindprod.fastcat
Class FastCat

    java.lang.Object
      com.mindprod.fastcat.FastCat

    public class FastCat

extends java.lang.Object

Stripped down, fast replacement for StringBuilder and StringWriter to build concatenated Strings.

For concatenating individual characters, StringBuilder will probably be faster. It has an overhead of 4 bytes per piece appended, which would be 50% if the Strings were only 2-bytes long. This algorithm works best with fairly long pieces.

Since:
  2009-09-29
Version:
  1.3 2010-02-13 - convert from JDK 1.6 to JDK 1.5
Author:
  Roedy Green, Canadian Mind Products

Constructor Summary
`FastCat()` no-arg constructor, defaults to 20 pieces as the estimate.
`FastCat(int estNumberOfPieces)` constructor

Method Summary
`FastCat` | `append(char c)` append char
`FastCat` | `append(java.lang.Object... oo)` append arbitrary number of Objects
`FastCat` | `append(java.lang.Object o)` append Object
`FastCat` | `append(java.lang.String... ss)` append arbitrary number of strings
`FastCat` | `append(java.lang.String s)` append String
`void` | `clear()` empty the concatenated String being created
`int` | `length()` current buffer length.
`static void` | `main(java.lang.String[] args)` test harness
`java.lang.String` | `toString()` Get the concatenation of all the strings appended so far

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

Constructor Detail

### FastCat

    public FastCat()

  no-arg constructor, defaults to 20 pieces as the estimate.

### FastCat

    public FastCat(int estNumberOfPieces)

  constructor

  Parameters:
    `estNumberOfPieces` - estimated number of chunks you will concatenate. If the estimate is low, you will get ArrayIndexOutOfBoundsExceptions.

Method Detail

### append

    public FastCat append(java.lang.String s)

  append String

  Parameters:
    `s` - String to append
  Returns:
    this

### append

    public FastCat append(java.lang.String... ss)

  append arbitrary number of strings

  Parameters:
    `ss` - comma-separated list of Strings to append
  Returns:
    this

### append

    public FastCat append(char c)

  append char

  Parameters:
    `c` - char to append. If you use this method extensively, you will probably get better performance from StringBuilder.
  Returns:
    this

### append

    public FastCat append(java.lang.Object o)

  append Object

  Parameters:
    `o` - Object to append. toString is called to acquire a String to concatenate.
  Returns:
    this

### append

    public FastCat append(java.lang.Object... oo)

  append arbitrary number of Objects

  Parameters:
    `oo` - comma-separated list of Objects to to append. toString is called to acquire a String to concatenate.
  Returns:
    this

### clear

    public void clear()

  empty the concatenated String being created

### length

    public int length()

  current buffer length.

  Returns:
    current total of count of chars appended

### toString

    public java.lang.String toString()

  Get the concatenation of all the strings appended so far

  Overrides:
    `toString` in class `java.lang.Object`

### main

    public static void main(java.lang.String[] args)

  test harness

  Parameters:
    `args` - not used.

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