SNAP Library 2.0, User Reference
2013-05-13 16:33:57
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <unicode.h>
Classes | |
class | TNode |
Public Types | |
typedef TItem_ | TItem |
Public Member Functions | |
TUniTrie () | |
void | Clr () |
bool | Empty () const |
bool | Has1Gram (const TItem &item) const |
bool | Has2Gram (const TItem &last, const TItem &butLast) const |
int | Get3GramRoot (const TItem &last, const TItem &butLast, const TItem &butButLast) const |
int | GetChild (const int parentIdx, const TItem &item) const |
bool | IsNodeTerminal (const int nodeIdx) const |
template<typename TSrcVec > | |
void | Add (const TSrcVec &src, const size_t srcIdx, const size_t srcCount) |
template<typename TSrcVec > | |
void | Add (const TSrcVec &src) |
Protected Types | |
typedef TVec< TNode > | TNodeV |
typedef TPair< TItem, TItem > | TItemPr |
typedef TTriple< TItem, TItem, TItem > | TItemTr |
typedef TUniVecIdx | TVecIdx |
Protected Attributes | |
THash< TItem, TVoid > | singles |
THash< TItemPr, TVoid > | pairs |
THash< TItemTr, TInt > | roots |
TNodeV | nodes |
typedef TUniVecIdx TUniTrie< TItem_ >::TVecIdx [protected] |
void TUniTrie< TItem_ >::Add | ( | const TSrcVec & | src, |
const size_t | srcIdx, | ||
const size_t | srcCount | ||
) | [inline] |
Definition at line 1220 of file unicode.h.
{ IAssert(srcCount > 0); if (srcCount == 1) { singles.AddKey(TItem(src[TVecIdx(srcIdx)])); return; } if (srcCount == 2) { pairs.AddKey(TItemPr(TItem(src[TVecIdx(srcIdx + 1)]), TItem(src[TVecIdx(srcIdx)]))); return; } size_t srcLast = srcIdx + (srcCount - 1); TItemTr tr = TItemTr(TItem(src[TVecIdx(srcLast)]), TItem(src[TVecIdx(srcLast - 1)]), TItem(src[TVecIdx(srcLast - 2)])); int keyId = roots.GetKeyId(tr), curNodeIdx = -1; if (keyId >= 0) curNodeIdx = roots[keyId]; else { curNodeIdx = nodes.Add(TNode(TItem(0), -1, -1, false)); roots.AddDat(tr, curNodeIdx); } // if (srcCount > 3) for (size_t srcPos = srcLast - 3; ; ) { const TItem curItem = src[TVecIdx(srcPos)]; int childNodeIdx = nodes[curNodeIdx].child; while (childNodeIdx >= 0) { TNode &childNode = nodes[childNodeIdx]; if (childNode.item == curItem) break; childNodeIdx = childNode.sib; } if (childNodeIdx < 0) { childNodeIdx = nodes.Add(TNode(curItem, -1, nodes[curNodeIdx].child, false)); nodes[curNodeIdx].child = childNodeIdx; } curNodeIdx = childNodeIdx; if (srcPos == srcIdx) break; else srcPos--; } nodes[curNodeIdx].terminal = true; }
int TUniTrie< TItem_ >::Get3GramRoot | ( | const TItem & | last, |
const TItem & | butLast, | ||
const TItem & | butButLast | ||
) | const [inline] |
bool TUniTrie< TItem_ >::IsNodeTerminal | ( | const int | nodeIdx | ) | const [inline] |