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