1*06c3fb27SDimitry Andric //===- llvm/ADT/SuffixTreeNode.cpp - Nodes for SuffixTrees --------*- C++ 2*06c3fb27SDimitry Andric //-*-===// 3*06c3fb27SDimitry Andric // 4*06c3fb27SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5*06c3fb27SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 6*06c3fb27SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7*06c3fb27SDimitry Andric // 8*06c3fb27SDimitry Andric //===----------------------------------------------------------------------===// 9*06c3fb27SDimitry Andric // 10*06c3fb27SDimitry Andric // This file defines nodes for use within a SuffixTree. 11*06c3fb27SDimitry Andric // 12*06c3fb27SDimitry Andric //===----------------------------------------------------------------------===// 13*06c3fb27SDimitry Andric 14*06c3fb27SDimitry Andric #include "llvm/Support/SuffixTreeNode.h" 15*06c3fb27SDimitry Andric #include "llvm/Support/Casting.h" 16*06c3fb27SDimitry Andric 17*06c3fb27SDimitry Andric using namespace llvm; 18*06c3fb27SDimitry Andric getStartIdx() const19*06c3fb27SDimitry Andricunsigned SuffixTreeNode::getStartIdx() const { return StartIdx; } incrementStartIdx(unsigned Inc)20*06c3fb27SDimitry Andricvoid SuffixTreeNode::incrementStartIdx(unsigned Inc) { StartIdx += Inc; } setConcatLen(unsigned Len)21*06c3fb27SDimitry Andricvoid SuffixTreeNode::setConcatLen(unsigned Len) { ConcatLen = Len; } getConcatLen() const22*06c3fb27SDimitry Andricunsigned SuffixTreeNode::getConcatLen() const { return ConcatLen; } 23*06c3fb27SDimitry Andric isRoot() const24*06c3fb27SDimitry Andricbool SuffixTreeInternalNode::isRoot() const { 25*06c3fb27SDimitry Andric return getStartIdx() == EmptyIdx; 26*06c3fb27SDimitry Andric } getEndIdx() const27*06c3fb27SDimitry Andricunsigned SuffixTreeInternalNode::getEndIdx() const { return EndIdx; } setLink(SuffixTreeInternalNode * L)28*06c3fb27SDimitry Andricvoid SuffixTreeInternalNode::setLink(SuffixTreeInternalNode *L) { 29*06c3fb27SDimitry Andric assert(L && "Cannot set a null link?"); 30*06c3fb27SDimitry Andric Link = L; 31*06c3fb27SDimitry Andric } getLink() const32*06c3fb27SDimitry AndricSuffixTreeInternalNode *SuffixTreeInternalNode::getLink() const { return Link; } 33*06c3fb27SDimitry Andric getEndIdx() const34*06c3fb27SDimitry Andricunsigned SuffixTreeLeafNode::getEndIdx() const { 35*06c3fb27SDimitry Andric assert(EndIdx && "EndIdx is empty?"); 36*06c3fb27SDimitry Andric return *EndIdx; 37*06c3fb27SDimitry Andric } 38*06c3fb27SDimitry Andric getSuffixIdx() const39*06c3fb27SDimitry Andricunsigned SuffixTreeLeafNode::getSuffixIdx() const { return SuffixIdx; } setSuffixIdx(unsigned Idx)40*06c3fb27SDimitry Andricvoid SuffixTreeLeafNode::setSuffixIdx(unsigned Idx) { SuffixIdx = Idx; } 41