More specifically, there's something wrong with my nearest neighbor search. I've confirmed that the tree is built correctly, and that all the helper functions work as expected.
Note this differs slightly from standard KD-trees in that I'm looking for the closest 3 points.
struct Node
{
unsigned int axis;
Point* obj;
struct Node* left...
I consider myself an experienced Java developer and am planning to get started with learning C++.
If you had same experience, i.e learn C++ after Java, I would like to hear your thoughts on what is the best approach at doing this.
[Update] "the best approach" was not well quantified. What I am looking for is to leverage my existing j...
I'm tasked with implementing a messaging system for a real-time simulation. There are several different kinds of messaging objects that need to exist in this system, and more might be added in the future. These objects represent the primary means of communication between the players in the sim. Assuming I fully understand my requireme...
I would like to parse a group of elements out of a TinyXml output. Essentially, I need to pick out any port element's "portid" attribute of the port has a state of "open" (shown below for port 23).
What's the best way to do this? Here's the (simplified) listing for the output from TinyXml:
<?xml version="1.0" ?>
<?xml ?>
<nmaprun>
...
How do I get the OpenGL color matrix transforms working?
I've modified a sample program that just draws a triangle, and added some color matrix code to see if I can change the colors of the triangle but it doesn't seem to work.
static float theta = 0.0f;
glClearColor( 1.0f, 1.0f, 1.0f, 1.0f );
glClearDepth(1.0);
glClear( GL_COLOR_B...
A textbook I recently read discussed row major & column major arrays. The book primarily focused on 1 and 2 dimensional arrays but didn't really discuss 3 dimensional arrays. I'm looking for some good examples to help solidify my understanding of addressing an element within a multi-dimensional array using row major & column major arra...
How would i make it so in my program there is a button when that button is clicked i want it to play a .wma file without opening and media player?
...
I am passed an Iterator and I have to pass it on to another function -- but filtered so that certain elements are skipped (it's a range of pointers, and I want to filter out the NULL pointers).
I googled for "stl filter iterator" to see how to do this, and boost::filter_iterator came up.
That looks nice and I could use it, but could ...
Hello all :)
I am trying to get version information from a file. My code works perfectly for me, but fails on several others' machines. Because I can't reproduce the bug, I'm having quite a time finding the issue.
Does anyone see anything majorly wrong with this?
LPBYTE versionInformationBlock;
struct LANGANDCODEPAGE {
WORD wLanguage...
It is mostly out of boredom, really... This afternoon I decided to make a simple 3D Game on Cocoa & OpenGL based on what I've done on one of my OpenGL class. I'm using the MD2 loading code that is posted at David Henry's "The Quake II's MD2 file format" and I like how it's put together, giving nice explanations, and nice C++ code. I wan...
I am a beginner in GDB and I got it working correctly. However, I am wondering how this is used in big projects. I have a project where build is done using makefile and g++. For GDB to work, we need to compile with debug symbols on, right (g++ -g files)?
Question
Do I need to create a new target in makefile something like "debug", so...
We all know the usual use of templates to design containers and we all know that you can do things with templates that will make your head spin.
When I first encoutered static polymorphism I was really struck on what you can do with templates. It's obvious that templates are useful for more than for designing containers. I bought Andrei...
I have a space separated file which contains some key->value pairs. These are to be loaded to a structure of the type given below:
#define FV_PARAM1 "A"
#define FV_PARAM2 "B"
parameter_t & parameterFeatureVector (
parameter_t & param,
int param1,
int param2,
) {
param.addParam(FV_PARAM1, par...
I have a function which needs to be invoked with a different number of threads each time (am doing some performance calculation, so need to know when the performance starts deteriorating). Example is given below:
getTime() {
return 0;
}
int main() {
boost::threadpool::thread_pool<> threads(nThreads);
for(int j = 0; j <= nL...
I'm new to C++ and am writing a multi-threaded app whereby different writers will be pushing objects onto a stack and readers pulling them off the stack (or at least pushing the pointer to an object)..
Are there any structures built-into C++ which can handle this without adding locking code etc.? If not, what about the Boost libraries?
...
Hello everybody,
I'm working on amr speech codec (porting/optimization)
I have an arm (for WinCE) optimized version from voiceage and I use it as a reference in performance testing. So far, binary produced with my lib beats the other one by around 20-30%! I use Vs2008 and I have limited access to ARM instruction set I can generate with M...
Initialization order of free objects is undefined in C++. But what about the following?
namespace foo {
char const* str = "hey";
struct A {
A() { cout << str; }
} obj;
}
Is this still undefined behavior, or is there a special provision for pointers initialized with string literals?
Aside from that: what if str was...
I am using joySetCapture with fChanged (4'th parameter) = true.
I am getting the messages only when position is changed, as I should.
However, I am not getting any message when a joystick button is pressed.
If I use fChanged = false, the wParam of the periodic messages is updated correctly.
How can I get messages only when either posi...
Windows provides a lockless singly linked list, as documented at this page:
Win32 SList
I'm wondering if there's an existing good C++ wrapper around this functionality. When I say good, I mean it exports the usual STL interface as much as possible, supports iterators, etc. I'd much rather use someone else's implementation than sit down ...
I've just started learning Qt, using their tutorial. I'm currently on tutorial 7, where we've made a new LCDRange class. The implementation of LCDRange (the .cpp file) uses the Qt QSlider class, so in the .cpp file is
#include <QSlider>
but in the header is a forward declaration:
class QSlider;
According to Qt,
This is another...