| 1 | // =============================================================== // |
|---|
| 2 | // // |
|---|
| 3 | // File : PRD_SearchFIFO.hxx // |
|---|
| 4 | // Purpose : // |
|---|
| 5 | // // |
|---|
| 6 | // Coded by Wolfram Foerster in February 2001 // |
|---|
| 7 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 8 | // http://www.arb-home.de/ // |
|---|
| 9 | // // |
|---|
| 10 | // =============================================================== // |
|---|
| 11 | |
|---|
| 12 | #ifndef PRD_SEARCHFIFO_HXX |
|---|
| 13 | #define PRD_SEARCHFIFO_HXX |
|---|
| 14 | |
|---|
| 15 | #ifndef PRD_NODE_HXX |
|---|
| 16 | #include "PRD_Node.hxx" |
|---|
| 17 | #endif |
|---|
| 18 | #ifndef PRD_RANGE_HXX |
|---|
| 19 | #include "PRD_Range.hxx" |
|---|
| 20 | #endif |
|---|
| 21 | |
|---|
| 22 | struct SearchParameter { |
|---|
| 23 | Node *node; // where am i currently in the tree |
|---|
| 24 | SearchParameter *next; |
|---|
| 25 | SearchParameter *previous; |
|---|
| 26 | }; |
|---|
| 27 | |
|---|
| 28 | class SearchFIFO : virtual Noncopyable { |
|---|
| 29 | SearchParameter *begin; // start of list of positions in tree |
|---|
| 30 | SearchParameter *end; // end of list of positions in tree |
|---|
| 31 | SearchParameter *current; // points to the currently examined position in the list |
|---|
| 32 | |
|---|
| 33 | Node *root; // rootnode of primertree to be searched in |
|---|
| 34 | bool expand_IUPAC_Codes; // enable/disable expansion of IUPAC codes |
|---|
| 35 | PRD_Sequence_Pos min_distance_to_next_match; // if a match is found out of that distance its ignored (not deleted) |
|---|
| 36 | |
|---|
| 37 | void init(Node *root_, PRD_Sequence_Pos min_distance_to_next_match_, bool expand_IUPAC_Codes_); |
|---|
| 38 | void erase (SearchParameter *param_); // erase the position from the list (tries not to invalidate current) |
|---|
| 39 | void push_front (Node *child_of_current_); // append new position in front of the list |
|---|
| 40 | |
|---|
| 41 | public: |
|---|
| 42 | |
|---|
| 43 | SearchFIFO (Node *root_, PRD_Sequence_Pos min_distance_to_next_match_, bool expand_IUPAC_Codes_); |
|---|
| 44 | SearchFIFO (); |
|---|
| 45 | ~SearchFIFO (); |
|---|
| 46 | |
|---|
| 47 | void push (unsigned char base_); // append new position (node=root) to the end of the list |
|---|
| 48 | void iterateWith (PRD_Sequence_Pos pos_, unsigned char base_); // tries to iterate all positions in the list with the given base |
|---|
| 49 | void flush (); // erase all positions of the list |
|---|
| 50 | void print (); // print all positions in the list |
|---|
| 51 | }; |
|---|
| 52 | |
|---|
| 53 | #else |
|---|
| 54 | #error PRD_SearchFIFO.hxx included twice |
|---|
| 55 | #endif // PRD_SEARCHFIFO_HXX |
|---|