Created
May 14, 2011 20:00
-
-
Save StonedXander/972568 to your computer and use it in GitHub Desktop.
Priority Queue Solver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define DEVEL_BUFFER_SIZE 128 | |
/** | |
* Priority queue solver. | |
* <P> implements the concept of ordered list. | |
* <T> implements the concept of weighted solution. | |
* <E> is an environment object (should be reentrant). | |
*/ | |
template <class P, class T, typename E> void solve(T**seeds, | |
int seedSize, | |
E *context, | |
int threshold) { | |
P<T> *queue = new P<T>(threshold); | |
T *tmp; | |
T **buffer = new T*[DEVEL_BUFFER_SIZE]; | |
int size; | |
queue->insert(seeds, seedSize); | |
while(!(queue->empty() || context->solved())) { | |
tmp = queue.pool(); | |
size = tmp->compute(buffer, DEVEL_BUFFER_SIZE, threshold, context); | |
queue->insert(buffer, size); | |
} | |
delete []buffer; | |
delete queue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Too many method call, isn't it ?