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