Hey Jos,
I agree it isn't psychic. My guess behind the STL algorithm is a top down bubbling for the heap. When I pop the top element, it exchanges the right most leaf node in the heap with the root, puts that leaf at root and bubbles down to maintain the heap. But this still won't guarantee that the heap is proper anymore if I've changed too many keys. Probably a bad question, but I thought I'd ask. The only thing I can do in...
User Profile
Collapse
-
Is a priority_queue dynamic?
I was wondering if anyone has a definitive answer on whether the STL priority_queue is dynamic? What I mean by this is best illustrated by a simple example. Suppose I have a priority queue of class called Position with a comparator class called PositionCompare as follows:
Now, I go along and keep inserting Position objects into _pQ....Code:priority_queue<Position, vector<Position>, PositionCompare> _pQ;
-
Boxfish, you've come through again! I think I tried every permutation but that one. Many thanks.Leave a comment:
-
Member Function of Templated Class Defined Outside Class Body
Ah, the joy of generic programming. Ok. Here's my problem. I have a templated class with a internally defined structure type. Within the class, I have some member functions whose return value is this structure. I want to define one of these member functions outside the body. An example is this:
...Code:template <class T, class E> class MyClass { private: T val; E key; -
Yeah, sorry about leaving the "test.h" include in there. Thanks for the reply. Works great.Leave a comment:
-
Templates and Iterators
Hi everyone,
Can anybody explain why this won't build and what the error is? The error is with the list iterator in the TestClass class. Basically, I have a two templated classes, Item and TestClass. TestClass uses Item to define on of its template parameters.
...Code:#include <iostream> #include <string> #include <vector> #include <list> #include "test.h"
-
Thanks boxfish! I've been pulling my hair out for a couple hours. That did the trick....Leave a comment:
-
Templated classes with nested classes
Hi everyone,
I have a question about referencing a nested class contained within a templated class. Of course the best way to show you is by example. Here's my templated classes:
...Code:#include <stack> template <class T> class A { public: // constructor A(const T &zz): z(zz) {} T z; // nested class class -
New Types
Hey Everyone,
I have a question about new types in Python. *Just finished reading up and
trying a few things out, but I'm a little confused about one thing. *When
declaring a new type, we basically have two new structures. *One is the per
instance structure (your PyObject structure), which is basically an expansion
of the PyObject structure. *At the beginning of that structure is the macro
declaration... -
Did you ever figure this out? I'm new to the forum, but I have the answer if you still need it.Leave a comment:
No activity results to display
Show More
Leave a comment: