Package io.netty.util.internal
Class SWARUtil
java.lang.Object
io.netty.util.internal.SWARUtil
Utility class for SWAR (SIMD within a register) operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static intapplyLowerCasePattern(int word) Returns a word where each lowercase ASCII byte has the highest bit set.private static longapplyLowerCasePattern(long word) Returns a word where each ASCII lowercase byte has the highest bit set.static longapplyPattern(long word, long pattern) Applies a compiled pattern to given word.private static intapplyUpperCasePattern(int word) Returns a word where each ASCII uppercase byte has the highest bit set.private static longapplyUpperCasePattern(long word) Returns a word where each ASCII uppercase byte has the highest bit set.static longcompilePattern(byte byteToFind) Compiles given byte into a long pattern suitable for SWAR operations.static booleancontainsLowerCase(int word) Returns true if the given word contains at least one ASCII lowercase byte.static booleancontainsLowerCase(long word) Returns true if the given word contains at least one ASCII lowercase byte.static booleancontainsUpperCase(int word) Returns true if the given word contains at least one ASCII uppercase byte.static booleancontainsUpperCase(long word) Returns true if the given word contains at least one ASCII uppercase byte.static intgetIndex(long word, boolean isBigEndian) Returns the index of the first occurrence of byte that specificied in the pattern.static inttoLowerCase(int word) Returns a word with all bytes converted to lowercase ASCII.static longtoLowerCase(long word) Returns a word with all bytes converted to lowercase ASCII.static inttoUpperCase(int word) Returns a word with all bytes converted to uppercase ASCII.static longtoUpperCase(long word) Returns a word with all bytes converted to uppercase ASCII.
-
Constructor Details
-
SWARUtil
private SWARUtil()
-
-
Method Details
-
compilePattern
public static long compilePattern(byte byteToFind) Compiles given byte into a long pattern suitable for SWAR operations. -
applyPattern
public static long applyPattern(long word, long pattern) Applies a compiled pattern to given word. Returns a word where each byte that matches the pattern has the highest bit set.- Parameters:
word- the word to apply the pattern topattern- the pattern to apply- Returns:
- a word where each byte that matches the pattern has the highest bit set
-
getIndex
public static int getIndex(long word, boolean isBigEndian) Returns the index of the first occurrence of byte that specificied in the pattern. If no pattern is found, returns 8.- Parameters:
word- the return value ofapplyPattern(long, long)isBigEndian- if true, if given word is big endian if false, if given word is little endian- Returns:
- the index of the first occurrence of the specified pattern in the specified word. If no pattern is found, returns 8.
-
applyUpperCasePattern
private static long applyUpperCasePattern(long word) Returns a word where each ASCII uppercase byte has the highest bit set. -
applyUpperCasePattern
private static int applyUpperCasePattern(int word) Returns a word where each ASCII uppercase byte has the highest bit set. -
applyLowerCasePattern
private static long applyLowerCasePattern(long word) Returns a word where each ASCII lowercase byte has the highest bit set. -
applyLowerCasePattern
private static int applyLowerCasePattern(int word) Returns a word where each lowercase ASCII byte has the highest bit set. -
containsUpperCase
public static boolean containsUpperCase(long word) Returns true if the given word contains at least one ASCII uppercase byte. -
containsUpperCase
public static boolean containsUpperCase(int word) Returns true if the given word contains at least one ASCII uppercase byte. -
containsLowerCase
public static boolean containsLowerCase(long word) Returns true if the given word contains at least one ASCII lowercase byte. -
containsLowerCase
public static boolean containsLowerCase(int word) Returns true if the given word contains at least one ASCII lowercase byte. -
toLowerCase
public static long toLowerCase(long word) Returns a word with all bytes converted to lowercase ASCII. -
toLowerCase
public static int toLowerCase(int word) Returns a word with all bytes converted to lowercase ASCII. -
toUpperCase
public static long toUpperCase(long word) Returns a word with all bytes converted to uppercase ASCII. -
toUpperCase
public static int toUpperCase(int word) Returns a word with all bytes converted to uppercase ASCII.
-