-
Notifications
You must be signed in to change notification settings - Fork 1
/
LongestCommonPrefix.h
89 lines (77 loc) · 2.29 KB
/
LongestCommonPrefix.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* LongestCommonPrefix.h
*
* This is the header file for the LongestCommonPrefix object. The Longest
* CommonPrefix object holds all information pertaining to the longest common
* prefix shared by two or more suffixes. The main attributes are:
*
* prefix - the prefix shared by the suffixes
* suffixes - a collection of Suffix objects that share the prefix
* length - the length of the prefix
* sortIndex - the index of the first suffix in the main sorted suffixes
* collection on the LongestCommonPrefixUtil object
*
* Typical use:
* 1. LongestCommonPrefix(aPrefix, aSortIndex) - instantiate object
* 2. addSuffix(aSuffix) - add a suffix that shares the prefix (repeat
* until all suffixes that share the prefix have
* been added
* 3. toString() - returns a XML result string representing the object
*
* Created on: 1-11-13
* Author: tomkolar
*/
#ifndef LONGESTCOMMONPREFIX_H
#define LONGESTCOMMONPREFIX_H
#include "Suffix.h"
#include <string>
#include <vector>
using namespace std;
class LongestCommonPrefix {
public:
// Constuctors
// ==============================================
LongestCommonPrefix();
LongestCommonPrefix(string aPrefix, int aSortIndex);
// Destructor
// =============================================
~LongestCommonPrefix();
// Public Methods
// =============================================
// addSuffix(Suffix*& aSuffix)
// Purpose:
// Adds aSuffix to the suffixes collection
// Preconditions:
// Postconditions:
// aSuffixe added to suffixes vector
void addSuffix(Suffix*& aSuffix);
// string toString()
// Purpose:
// Returns a formatted XML element representing the prefix and
// the suffixes it contains
//
// format:
// <result type='DNA Sequence'> >
// <<suffix1.toString(length)>>
// <<suffix2.toString(length)>>
// ...
// <<suffixN.toString(length)>>
// <<prefix>>
// </result>
// Preconditions:
// Object has been fully populated
string toString();
// Public Accessors
// =============================================
string& getPrefix();
int& getLength();
int& getSortIndex();
private:
// Attributes
// =============================================
vector<Suffix*> suffixes;
string prefix;
int length;
int sortIndex;
};
#endif /* LONGESTCOMMONPREFIX_H */