Package org.eclipse.cdt.core.parser.util

## Class CharArrayUtils

- java.lang.Object
- - org.eclipse.cdt.core.parser.util.CharArrayUtils

    public class CharArrayUtils
    extends Object

A static utility class for char arrays

### Field Summary

Fields
`static char[]` `EMPTY`
`static char[][]` `EMPTY_ARRAY_OF_CHAR_ARRAYS`
`static char[]` `EMPTY_CHAR_ARRAY`

### Method Summary

All Methods Static Methods Concrete Methods
`static int` `compare​(char[] str1, char[] str2)` Implements a lexicographical comparator for char arrays.
`static char[]` `concat​(char[] first, char[] second)`
`static boolean` `equals​(char[][] strarr1, char[][] strarr2)`
`static boolean` `equals​(char[] str1, char[] str2)`
`static boolean` `equals​(char[] str1, int start1, int length1, char[] str2)` Returns `true` if the contents of a section of a character array are the same as contents of another character array.
`static boolean` `equals​(char[] str1, int start1, int length1, char[] str2, boolean ignoreCase)`
`static boolean` `equals​(char[] str1, int start1, int length1, String str2)` Returns `true` if the contents of a section of a character array are the same as contents of a string.
`static boolean` `equals​(char[] str1, String str2)` Returns `true` if the contents of a character array are the same as contents of a string.
`static char[]` `extract​(char[] str, int start, int length)`
`static char[]` `extractChars​(StringBuilder buf)` Converts a `StringBuilder` to a character array.
`static int` `hash​(char[] str)`
`static int` `hash​(char[] str, int start, int length)`
`static int` `indexOf​(char[] toBeFound, char[] array)`
`static int` `indexOf​(char[] searchFor, char[][] searchIn)` Finds an array of chars in an array of arrays of chars.
`static int` `indexOf​(char toBeFound, char[] array)`
`static int` `indexOf​(char toBeFound, char[] buffer, int start, int end)`
`static int` `lastIndexOf​(char[] toBeFound, char[] array)`
`static int` `lastIndexOf​(char[] toBeFound, char[] array, int fromIndex)`
`static int` `lastIndexOf​(char toBeFound, char[] array)`
`static int` `lastIndexOf​(char toBeFound, char[] array, int fromIndex)`
`static char[]` `lastSegment​(char[] array, char[] separator)`
`static void` `overWrite​(char[] buff, int i, char[] charImage)`
`static char[]` `replace​(char[] array, char[] toBeReplaced, char[] replacementChars)`
`static boolean` `startsWith​(char[] str1, String str2)` Returns `true` if a prefix of the character array is the same as contents of a string.
`static char[][]` `subarray​(char[][] array, int start, int end)`
`static char[]` `subarray​(char[] array, int start, int end)`
`static char[]` `trim​(char[] chars)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### EMPTY_CHAR_ARRAY

    public static final char[] EMPTY_CHAR_ARRAY

Since:
  5.4

#### EMPTY

    public static final char[] EMPTY

#### EMPTY_ARRAY_OF_CHAR_ARRAYS

    public static final char[][] EMPTY_ARRAY_OF_CHAR_ARRAYS

Since:
  5.7

### Method Detail

#### hash

    public static final int hash​(char[] str,
                                 int start,
                                 int length)

#### hash

    public static final int hash​(char[] str)

#### equals

    public static final boolean equals​(char[] str1,
                                       char[] str2)

#### equals

    public static final boolean equals​(char[][] strarr1,
                                       char[][] strarr2)

#### equals

    public static final boolean equals​(char[] str1,
                                       String str2)

Returns `true` if the contents of a character array are the same as contents of a string.

Since:
  5.4

#### equals

    public static final boolean equals​(char[] str1,
                                       int start1,
                                       int length1,
                                       String str2)

Returns `true` if the contents of a section of a character array are the same as contents of a string.

Since:
  5.5

#### startsWith

    public static final boolean startsWith​(char[] str1,
                                           String str2)

Returns `true` if a prefix of the character array is the same as contents of a string.

Since:
  5.4

#### compare

    public static final int compare​(char[] str1,
                                    char[] str2)

Implements a lexicographical comparator for char arrays. Comparison is done on a per char basis, not a code-point basis.

Parameters:
  `str1` - the first of the two char arrays to compare
  `str2` - the second of the two char arrays to compare
Returns:
  0 if str1==str2, -1 if str1 < str2 and 1 if str1 > str2

#### equals

    public static final boolean equals​(char[] str1,
                                       int start1,
                                       int length1,
                                       char[] str2)

Returns `true` if the contents of a section of a character array are the same as contents of another character array.

#### equals

    public static final boolean equals​(char[] str1,
                                       int start1,
                                       int length1,
                                       char[] str2,
                                       boolean ignoreCase)

#### extract

    public static final char[] extract​(char[] str,
                                       int start,
                                       int length)

#### concat

    public static final char[] concat​(char[] first,
                                      char[] second)

#### replace

    public static final char[] replace​(char[] array,
                                       char[] toBeReplaced,
                                       char[] replacementChars)

#### subarray

    public static final char[][] subarray​(char[][] array,
                                          int start,
                                          int end)

#### subarray

    public static final char[] subarray​(char[] array,
                                        int start,
                                        int end)

#### indexOf

    public static final int indexOf​(char toBeFound,
                                    char[] array)

#### indexOf

    public static int indexOf​(char toBeFound,
                              char[] buffer,
                              int start,
                              int end)

#### indexOf

    public static final int indexOf​(char[] toBeFound,
                                    char[] array)

#### lastIndexOf

    public static final int lastIndexOf​(char[] toBeFound,
                                        char[] array)

#### lastIndexOf

    public static int lastIndexOf​(char toBeFound,
                                  char[] array)

Since:
  5.11

#### lastIndexOf

    public static int lastIndexOf​(char toBeFound,
                                  char[] array,
                                  int fromIndex)

Since:
  5.11

#### lastIndexOf

    public static int lastIndexOf​(char[] toBeFound,
                                  char[] array,
                                  int fromIndex)

Since:
  5.11

#### trim

    public static final char[] trim​(char[] chars)

#### lastSegment

    public static final char[] lastSegment​(char[] array,
                                           char[] separator)

#### overWrite

    public static void overWrite​(char[] buff,
                                 int i,
                                 char[] charImage)

Parameters:
  `buff` -
  `i` -
  `charImage` -

#### indexOf

    public static int indexOf​(char[] searchFor,
                              char[][] searchIn)

Finds an array of chars in an array of arrays of chars.

Returns:
  offset where the array was found or `-1`

#### extractChars

    public static char[] extractChars​(StringBuilder buf)

Converts a `StringBuilder` to a character array.

Since:
  5.5