[Liblas-commits] hg: Iterator changes: Simpler syntax found. Resolved ambiguity s...

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Nov 16 18:55:38 EST 2010


changeset 54c162c138f2 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=54c162c138f2
summary: Iterator changes: Simpler syntax found. Resolved ambiguity surrounding meaning of advance(0) in favor of treating it same as operator++ instead of operator--. Changed operator[] and operator() to act like array indexing instead of seeking nth member.

diffstat:

 src/lasindex.cpp |  31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)

diffs (46 lines):

diff -r 50d7bae327ba -r 54c162c138f2 src/lasindex.cpp
--- a/src/lasindex.cpp	Tue Nov 16 11:54:41 2010 -0600
+++ b/src/lasindex.cpp	Tue Nov 16 16:53:10 2010 -0700
@@ -2127,24 +2127,29 @@
 
 const std::vector<boost::uint32_t>& IndexIterator::operator()(boost::int32_t n)
 {
-	if (n < 0)
-		n = 0;
-	if ((boost::uint32_t)n <= m_conformingPtsFound)
+	if (n <= 0)
+	{
 		ResetPosition();
-	n -= m_conformingPtsFound;
-	return (advance(n));
+		m_advance = 1;
+	} // if
+	else if (n < m_conformingPtsFound)
+	{
+		ResetPosition();
+		m_advance = n + 1;
+	} // if
+	else
+	{
+		m_advance = n - m_conformingPtsFound + 1;
+	} // else
+	m_indexData.SetIterator(this);
+	return (m_index->Filter(m_indexData));
 } // IndexIterator::operator++
 
 const std::vector<boost::uint32_t>& IndexIterator::advance(boost::int32_t n)
 {
-	if (n < 0)
-	{
-		n = m_conformingPtsFound + n;
-		return((*this)(n));
-	} // if
-	m_advance = n;
-	m_indexData.SetIterator(this);
-	return (m_index->Filter(m_indexData));
+	if (n > 0)
+		--n;
+	return ((*this)(m_conformingPtsFound + n));
 } // IndexIterator::advance
 
 } // namespace liblas


More information about the Liblas-commits mailing list