MCPcopy Create free account
hub / github.com/Illumina/hap.py / computeDistance

Method computeDistance

external/jsoncpp/jsoncpp.cpp:1274–1308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1272
1273
1274ValueIteratorBase::difference_type
1275ValueIteratorBase::computeDistance( const SelfType &other ) const
1276{
1277#ifndef JSON_VALUE_USE_INTERNAL_MAP
1278# ifdef JSON_USE_CPPTL_SMALLMAP
1279 return current_ - other.current_;
1280# else
1281 // Iterator for null value are initialized using the default
1282 // constructor, which initialize current_ to the default
1283 // std::map::iterator. As begin() and end() are two instance
1284 // of the default std::map::iterator, they can not be compared.
1285 // To allow this, we handle this comparison specifically.
1286 if ( isNull_ && other.isNull_ )
1287 {
1288 return 0;
1289 }
1290
1291
1292 // Usage of std::distance is not portable (does not compile with Sun Studio 12 RogueWave STL,
1293 // which is the one used by default).
1294 // Using a portable hand-made version for non random iterator instead:
1295 // return difference_type( std::distance( current_, other.current_ ) );
1296 difference_type myDistance = 0;
1297 for ( Value::ObjectValues::iterator it = current_; it != other.current_; ++it )
1298 {
1299 ++myDistance;
1300 }
1301 return myDistance;
1302# endif
1303#else
1304 if ( isArray_ )
1305 return ValueInternalArray::distance( iterator_.array_, other.iterator_.array_ );
1306 return ValueInternalMap::distance( iterator_.map_, other.iterator_.map_ );
1307#endif
1308}
1309
1310
1311bool

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected