org.amino.alg.scan
Class AbstractScanner

java.lang.Object
  extended by org.amino.alg.scan.AbstractScanner
All Implemented Interfaces:
Scanner
Direct Known Subclasses:
ParallelScanner

public abstract class AbstractScanner
extends java.lang.Object
implements Scanner

Abstract class for searching byte arrays.

Author:
donawa

Constructor Summary
AbstractScanner()
           
 
Method Summary
 int binarySearch(byte[] a, byte v)
          
 int[] findAll(byte[] a, byte v)
          Find the indices of all occurrences of the given value in the array.
 int[] findAll(byte[] a, byte[] v)
          Find the index of the any occurrence of the given sequence in the array.
 int findAny(byte[] a, byte v)
          Find the index of the any occurrence of the given value in the array.
 int findAny(byte[] a, byte[] v)
          Find the index of the any occurrence of the given sequence in the array.
 int findFirst(byte[] a, byte v)
          Find the index of the first occurrence of the given value in the array.
 int findFirst(byte[] a, byte[] v)
          Find the index of the first occurrence of the given sequence in the array.
 int findLast(byte[] a, byte v)
          Find the index of the last occurrence of the given value in the array.
 int findLast(byte[] a, byte[] v)
          Find the index of the last occurrence of the given sequence in the array.
 int replaceAll(byte[] a, byte[] v, byte[] r)
          Replace all occurrences of the search sequence with the replacement sequence.
 int replaceAll(byte[] a, byte v, byte r)
          Replace all occurrences of the search value with the replacement value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.amino.alg.scan.Scanner
binarySearch, findAll, findAll, findAny, findAny, findNext, findNext, findPrevious, findPrevious, replaceAll, replaceAll
 

Constructor Detail

AbstractScanner

public AbstractScanner()
Method Detail

binarySearch

public int binarySearch(byte[] a,
                        byte v)

Specified by:
binarySearch in interface Scanner
Parameters:
a - The array to search.
v - The value to search for
Returns:
index of the search value if it succeeds; otherwise, (-(insertion point) - 1)

findAll

public int[] findAll(byte[] a,
                     byte v)
Find the indices of all occurrences of the given value in the array.

Specified by:
findAll in interface Scanner
Parameters:
a - The array to search.
v - The value to search for.
Returns:
The array of indices of occurrences or null if none found.

findAll

public int[] findAll(byte[] a,
                     byte[] v)
Find the index of the any occurrence of the given sequence in the array.

Specified by:
findAll in interface Scanner
Parameters:
a - The array to search.
v - The sequence to search for.
Returns:
The array of indices of occurrences or null if none found.

findAny

public int findAny(byte[] a,
                   byte v)
Find the index of the any occurrence of the given value in the array.

Specified by:
findAny in interface Scanner
Parameters:
a - The array to search.
v - The value to search for.
Returns:
The index of the an occurrence or a negative value if not found.

findAny

public int findAny(byte[] a,
                   byte[] v)
Find the index of the any occurrence of the given sequence in the array.

Specified by:
findAny in interface Scanner
Parameters:
a - The array to search.
v - The sequence to search for.
Returns:
The index of the an occurrence or a negative value if not found.

findFirst

public int findFirst(byte[] a,
                     byte v)
Find the index of the first occurrence of the given value in the array.

Specified by:
findFirst in interface Scanner
Parameters:
a - The array to search.
v - The value to search for.
Returns:
The index of the first occurrence or a negative value if not found.

findFirst

public int findFirst(byte[] a,
                     byte[] v)
Find the index of the first occurrence of the given sequence in the array.

Specified by:
findFirst in interface Scanner
Parameters:
a - The array to search.
v - The sequence to search for.
Returns:
The index of the first occurrence or a negative value if not found.

findLast

public int findLast(byte[] a,
                    byte v)
Find the index of the last occurrence of the given value in the array.

Specified by:
findLast in interface Scanner
Parameters:
a - The array to search.
v - The value to search for.
Returns:
The index of the last occurrence or a negative value if not found.

findLast

public int findLast(byte[] a,
                    byte[] v)
Find the index of the last occurrence of the given sequence in the array.

Specified by:
findLast in interface Scanner
Parameters:
a - The array to search.
v - The sequence to search for.
Returns:
The index of the last occurrence or a negative value if not found.

replaceAll

public int replaceAll(byte[] a,
                      byte v,
                      byte r)
Replace all occurrences of the search value with the replacement value.

Specified by:
replaceAll in interface Scanner
Parameters:
a - The array to search.
v - The value to search for.
r - The replacement value.
Returns:
The number of occurrences found and replaced.

replaceAll

public int replaceAll(byte[] a,
                      byte[] v,
                      byte[] r)
Replace all occurrences of the search sequence with the replacement sequence. The search and replacement sequence must be identical in length.

Specified by:
replaceAll in interface Scanner
Parameters:
a - The array to search.
v - The sequence to search for.
r - The replacement sequence.
Returns:
The number of occurrences found and replaced.


Copyright © 2008. All Rights Reserved.