Package io.netty.util.internal
Class SWARUtil
- java.lang.Object
-
- io.netty.util.internal.SWARUtil
-
public final class SWARUtil extends java.lang.Object
Utility class for SWAR (SIMD within a register) operations.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
applyPattern(long word, long pattern)
Applies a compiled pattern to given word.static long
compilePattern(byte byteToFind)
Compiles given byte into a long pattern suitable for SWAR operations.static boolean
containsLowerCase(int word)
Returns true if the given word contains at least one ASCII lowercase byte.static boolean
containsLowerCase(long word)
Returns true if the given word contains at least one ASCII lowercase byte.static boolean
containsUpperCase(int word)
Returns true if the given word contains at least one ASCII uppercase byte.static boolean
containsUpperCase(long word)
Returns true if the given word contains at least one ASCII uppercase byte.static int
getIndex(long word, boolean isBigEndian)
Returns the index of the first occurrence of byte that specificied in the pattern.static int
toLowerCase(int word)
Returns a word with all bytes converted to lowercase ASCII.static long
toLowerCase(long word)
Returns a word with all bytes converted to lowercase ASCII.static int
toUpperCase(int word)
Returns a word with all bytes converted to uppercase ASCII.static long
toUpperCase(long word)
Returns a word with all bytes converted to uppercase ASCII.
-
-
-
Method Detail
-
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.
-
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.
-
-