Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » how can i use iterators with NTL?
how can i use iterators with NTL? [message #16261] Wed, 04 June 2008 23:46 Go to next message
ajmf77 is currently offline  ajmf77
Messages: 6
Registered: December 2006
Location: Santiago de Chile
Promising Member
Hi everyone!
My question arises from my need to translate a KD-tree header. In the STL view of the world, initializing a vector variable with another previous existent vector, we can use iterators in one line.
How can i do the same with NTL?

ALA STL example:

vector<float> v1;
***
vector<float> v2(v1.begin,v2.begin+some_int);


thanxs in advance!

Alejandro Muņoz Fonttz
from Chile
Re: how can i use iterators with NTL? [message #16262 is a reply to message #16261] Thu, 05 June 2008 05:37 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14261
Registered: November 2005
Ultimate Member
v2.begin() + some_int?

Does not make sense to me.

Anyway, in U++ closest equivalent is

Vector<int> a;
....
Vector<int> b;
b.Append(a, pos, count);

if you insist on iterators, you have to "translate" them

b.Append(a, begin - a.Begin(), end - begin);

Mirek
Re: how can i use iterators with NTL? [message #16269 is a reply to message #16262] Thu, 05 June 2008 14:30 Go to previous messageGo to next message
ajmf77 is currently offline  ajmf77
Messages: 6
Registered: December 2006
Location: Santiago de Chile
Promising Member
thax for your quick reply!
i has some errors in my former explanation, but you catch my idea.
Well, i use Insert(...), altought Append(...) is more appropiate.
And, again over iterators, in
template <class T, class Less> void Sort(T& c, const Less& less)
if my class T have two components, i. e.
class Point
{
float x,y
.
.
.
}
and i want to use in a class like
kdtree
{
.
. some declarations
.
}
i can employ, in a STL style, a
class PXorder{
bool operator () (point &u, point &v)
{
.
. some returns, based on if u>v or u<v
.
}
}
declared and implemented within kdtree class
but if we use
Vector<point> v;
Sort(v,PXorder());

the compiler returns ERROR: 'const PXorder' as argument 'this' in PXorder(Point,Point), discard qualifiers?
any suggestion?
PD: I will post source code later, thanx!
Re: how can i use iterators with NTL? [message #16273 is a reply to message #16269] Thu, 05 June 2008 16:40 Go to previous message
mirek is currently offline  mirek
Messages: 14261
Registered: November 2005
Ultimate Member
bool operator () (const point &u, const point &v) const

Mirek
Previous Topic: Can we get a Join that uses WString?
Next Topic: MemoryBreakpoint definition?
Goto Forum:
  


Current Time: Sat Jun 14 15:31:55 CEST 2025

Total time taken to generate the page: 0.04306 seconds