Merge "Add node flags creating methods."
commit
48554e22e0
|
@ -56,6 +56,15 @@ class DynamicPatriciaTrieReadingUtils {
|
|||
return FLAG_IS_DELETED == (MASK_MOVED & flags);
|
||||
}
|
||||
|
||||
static AK_FORCE_INLINE NodeFlags updateAndGetFlags(const NodeFlags originalFlags,
|
||||
const bool isMoved, const bool isDeleted) {
|
||||
NodeFlags flags = originalFlags;
|
||||
flags = isMoved ? ((flags & (!MASK_MOVED)) | FLAG_IS_MOVED) : flags;
|
||||
flags = isDeleted ? ((flags & (!MASK_MOVED)) | FLAG_IS_DELETED) : flags;
|
||||
flags = (!isMoved && !isDeleted) ? ((flags & (!MASK_MOVED)) | FLAG_IS_NOT_MOVED) : flags;
|
||||
return flags;
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(DynamicPatriciaTrieReadingUtils);
|
||||
|
||||
|
|
|
@ -119,6 +119,29 @@ class PatriciaTrieReadingUtils {
|
|||
return FLAG_CHILDREN_POSITION_TYPE_NOPOSITION != (MASK_CHILDREN_POSITION_TYPE & flags);
|
||||
}
|
||||
|
||||
static AK_FORCE_INLINE NodeFlags createAndGetFlags(const bool isBlacklisted,
|
||||
const bool isNotAWord, const bool isTerminal, const bool hasShortcutTargets,
|
||||
const bool hasBigrams, const bool hasMultipleChars,
|
||||
const int childrenPositionFieldSize) {
|
||||
NodeFlags nodeFlags = 0;
|
||||
nodeFlags = isBlacklisted ? (nodeFlags | FLAG_IS_BLACKLISTED) : nodeFlags;
|
||||
nodeFlags = isNotAWord ? (nodeFlags | FLAG_IS_NOT_A_WORD) : nodeFlags;
|
||||
nodeFlags = isTerminal ? (nodeFlags | FLAG_IS_TERMINAL) : nodeFlags;
|
||||
nodeFlags = hasShortcutTargets ? (nodeFlags | FLAG_HAS_SHORTCUT_TARGETS) : nodeFlags;
|
||||
nodeFlags = hasBigrams ? (nodeFlags | FLAG_HAS_BIGRAMS) : nodeFlags;
|
||||
nodeFlags = hasMultipleChars ? (nodeFlags | FLAG_HAS_MULTIPLE_CHARS) : nodeFlags;
|
||||
if (childrenPositionFieldSize == 1) {
|
||||
nodeFlags |= FLAG_CHILDREN_POSITION_TYPE_ONEBYTE;
|
||||
} else if (childrenPositionFieldSize == 2) {
|
||||
nodeFlags |= FLAG_CHILDREN_POSITION_TYPE_TWOBYTES;
|
||||
} else if (childrenPositionFieldSize == 3) {
|
||||
nodeFlags |= FLAG_CHILDREN_POSITION_TYPE_THREEBYTES;
|
||||
} else {
|
||||
nodeFlags |= FLAG_CHILDREN_POSITION_TYPE_NOPOSITION;
|
||||
}
|
||||
return nodeFlags;
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(PatriciaTrieReadingUtils);
|
||||
|
||||
|
|
Loading…
Reference in New Issue