Documentation of 'edu.princeton.cs.algs4.Alphabet' Java class
Alphabet
edu.princeton.cs.algs4

Class Alphabet



  • public class Alphabet
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor and Description
      Alphabet()
      Initializes a new alphabet using characters 0 through 255.
      Alphabet(java.lang.String alpha)
      Initializes a new alphabet from the given set of characters.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method and Description
      boolean contains(char c)
      Returns true if the argument is a character in this alphabet.
      int lgR()
      Returns the binary logarithm of the number of characters in this alphabet.
      static void main(java.lang.String[] args)
      Unit tests the Alphabet data type.
      int R()
      Deprecated. 
      Replaced by radix().
      int radix()
      Returns the number of characters in this alphabet (the radix).
      char toChar(int index)
      Returns the character corresponding to the argument index.
      java.lang.String toChars(int[] indices)
      Returns the characters corresponding to the argument indices.
      int toIndex(char c)
      Returns the index corresponding to the argument character.
      int[] toIndices(java.lang.String s)
      Returns the indices corresponding to the argument characters.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • BINARY

        public static final Alphabet BINARY
        The binary alphabet { 0, 1 }.
      • OCTAL

        public static final Alphabet OCTAL
        The octal alphabet { 0, 1, 2, 3, 4, 5, 6, 7 }.
      • DECIMAL

        public static final Alphabet DECIMAL
        The decimal alphabet { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }.
      • HEXADECIMAL

        public static final Alphabet HEXADECIMAL
        The hexadecimal alphabet { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F }.
      • DNA

        public static final Alphabet DNA
        The DNA alphabet { A, C, T, G }.
      • LOWERCASE

        public static final Alphabet LOWERCASE
        The lowercase alphabet { a, b, c, ..., z }.
      • UPPERCASE

        public static final Alphabet UPPERCASE
        The uppercase alphabet { A, B, C, ..., Z }.
      • PROTEIN

        public static final Alphabet PROTEIN
        The protein alphabet { A, C, D, E, F, G, H, I, K, L, M, N, P, Q, R, S, T, V, W, Y }.
      • BASE64

        public static final Alphabet BASE64
        The base-64 alphabet (64 characters).
      • ASCII

        public static final Alphabet ASCII
        The ASCII alphabet (0-127).
      • EXTENDED_ASCII

        public static final Alphabet EXTENDED_ASCII
        The extended ASCII alphabet (0-255).
      • UNICODE16

        public static final Alphabet UNICODE16
        The Unicode 16 alphabet (0-65,535).
    • Constructor Detail

      • Alphabet

        public Alphabet(java.lang.String alpha)
        Initializes a new alphabet from the given set of characters.
        Parameters:
        alpha - the set of characters
      • Alphabet

        public Alphabet()
        Initializes a new alphabet using characters 0 through 255.
    • Method Detail

      • contains

        public boolean contains(char c)
        Returns true if the argument is a character in this alphabet.
        Parameters:
        c - the character
        Returns:
        true if c is a character in this alphabet; false otherwise
      • R

        @Deprecated
        public int R()
        Deprecated. Replaced by radix().
        Returns the number of characters in this alphabet (the radix).
        Returns:
        the number of characters in this alphabet
      • radix

        public int radix()
        Returns the number of characters in this alphabet (the radix).
        Returns:
        the number of characters in this alphabet
      • lgR

        public int lgR()
        Returns the binary logarithm of the number of characters in this alphabet.
        Returns:
        the binary logarithm (rounded up) of the number of characters in this alphabet
      • toIndex

        public int toIndex(char c)
        Returns the index corresponding to the argument character.
        Parameters:
        c - the character
        Returns:
        the index corresponding to the character c
        Throws:
        java.lang.IllegalArgumentException - unless c is a character in this alphabet
      • toIndices

        public int[] toIndices(java.lang.String s)
        Returns the indices corresponding to the argument characters.
        Parameters:
        s - the characters
        Returns:
        the indices corresponding to the characters s
        Throws:
        java.lang.IllegalArgumentException - unless every character in s is a character in this alphabet
      • toChar

        public char toChar(int index)
        Returns the character corresponding to the argument index.
        Parameters:
        index - the index
        Returns:
        the character corresponding to the index index
        Throws:
        java.lang.IllegalArgumentException - unless 0 <= index < R
      • toChars

        public java.lang.String toChars(int[] indices)
        Returns the characters corresponding to the argument indices.
        Parameters:
        indices - the indices
        Returns:
        the characters corresponding to the indices indices
        Throws:
        java.lang.IllegalArgumentException - unless 0 < indices[i] < R for every i
      • main

        public static void main(java.lang.String[] args)
        Unit tests the Alphabet data type.
        Parameters:
        args - the command-line arguments

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.