Skip to content

Instantly share code, notes, and snippets.

@StonedXander
Created May 14, 2011 20:00
Show Gist options
  • Save StonedXander/972568 to your computer and use it in GitHub Desktop.
Save StonedXander/972568 to your computer and use it in GitHub Desktop.
Priority Queue Solver
#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;
}
@StonedXander
Copy link
Author

Too many method call, isn't it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment