ekg / intervaltree

a minimal C++ interval tree implementation
MIT License
222 stars 66 forks source link

Cleanup: Remove "using namespace std;" and add constness to searches. #7

Closed BenFrantzDale closed 10 years ago

BenFrantzDale commented 10 years ago

Also new instead of malloc.

ekg commented 10 years ago

Wow, thanks. This is a great cleanup!

I just have one question before I merge.

I'm a bit concerned about the effect of const-ness. Would you describe the objective of this part of the change?

BenFrantzDale commented 10 years ago

Sure thing. I added the constness because the search functionality doesn't modify the data, so, for example, a function should be able to take a const IntervalTree<T,K>& as an argument and query it. Without the constness, the compiler wouldn't allow you to query a const IntervalTree<T,K> even though querying it doesn't actually modify it.

The namespace stuff is because headers should never do "using namespace ...;" since it pollutes the global namespace.