类 Alphabet
- java.lang.Object
-
- edu.princeton.cs.algs4.Alphabet
-
public class Alphabet extends java.lang.Object
-
-
字段概要
字段 修饰符和类型 字段 说明 static AlphabetASCIIThe ASCII alphabet (0-127).static AlphabetBASE64The base-64 alphabet (64 characters).static AlphabetBINARYThe binary alphabet { 0, 1 }.static AlphabetDECIMALThe decimal alphabet { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }.static AlphabetDNAThe DNA alphabet { A, C, T, G }.static AlphabetEXTENDED_ASCIIThe extended ASCII alphabet (0-255).static AlphabetHEXADECIMALThe hexadecimal alphabet { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F }.static AlphabetLOWERCASEThe lowercase alphabet { a, b, c, ..., z }.static AlphabetOCTALThe octal alphabet { 0, 1, 2, 3, 4, 5, 6, 7 }.static AlphabetPROTEINThe protein alphabet { A, C, D, E, F, G, H, I, K, L, M, N, P, Q, R, S, T, V, W, Y }.static AlphabetUNICODE16The Unicode 16 alphabet (0-65,535).static AlphabetUPPERCASEThe uppercase alphabet { A, B, C, ..., Z }.
-
方法概要
修饰符和类型 方法 说明 booleancontains(char c)Returns true if the argument is a character in this alphabet.intlgR()Returns the binary logarithm of the number of characters in this alphabet.static voidmain(java.lang.String[] args)Unit tests theAlphabetdata type.intR()已过时。Replaced byradix().intradix()Returns the number of characters in this alphabet (the radix).chartoChar(int index)Returns the character corresponding to the argument index.java.lang.StringtoChars(int[] indices)Returns the characters corresponding to the argument indices.inttoIndex(char c)Returns the index corresponding to the argument character.int[]toIndices(java.lang.String s)Returns the indices corresponding to the argument characters.
-
-
-
字段详细资料
-
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).
-
-
方法详细资料
-
contains
public boolean contains(char c)
Returns true if the argument is a character in this alphabet.- 参数:
c- the character- 返回:
trueifcis a character in this alphabet;falseotherwise
-
R
@Deprecated public int R()
已过时。Replaced byradix().Returns the number of characters in this alphabet (the radix).- 返回:
- the number of characters in this alphabet
-
radix
public int radix()
Returns the number of characters in this alphabet (the radix).- 返回:
- the number of characters in this alphabet
-
lgR
public int lgR()
Returns the binary logarithm of the number of characters in this alphabet.- 返回:
- 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.- 参数:
c- the character- 返回:
- the index corresponding to the character
c - 抛出:
java.lang.IllegalArgumentException- unlesscis a character in this alphabet
-
toIndices
public int[] toIndices(java.lang.String s)
Returns the indices corresponding to the argument characters.- 参数:
s- the characters- 返回:
- the indices corresponding to the characters
s - 抛出:
java.lang.IllegalArgumentException- unless every character insis a character in this alphabet
-
toChar
public char toChar(int index)
Returns the character corresponding to the argument index.- 参数:
index- the index- 返回:
- the character corresponding to the index
index - 抛出:
java.lang.IllegalArgumentException- unless0 <= index < R
-
toChars
public java.lang.String toChars(int[] indices)
Returns the characters corresponding to the argument indices.- 参数:
indices- the indices- 返回:
- the characters corresponding to the indices
indices - 抛出:
java.lang.IllegalArgumentException- unless0 < indices[i] < Rfor everyi
-
main
public static void main(java.lang.String[] args)
Unit tests theAlphabetdata type.- 参数:
args- the command-line arguments
-
-