... | ... |
@@ -1263,132 +1263,132 @@ |
1263 | 1263 |
: _begin(it), _end(it), _functor(functor) {} |
1264 | 1264 |
|
1265 | 1265 |
/// Gives back the given iterator set for the first key |
1266 | 1266 |
Iterator begin() const { |
1267 | 1267 |
return _begin; |
1268 | 1268 |
} |
1269 | 1269 |
|
1270 | 1270 |
/// Gives back the the 'after the last' iterator |
1271 | 1271 |
Iterator end() const { |
1272 | 1272 |
return _end; |
1273 | 1273 |
} |
1274 | 1274 |
|
1275 | 1275 |
/// The \c set function of the map |
1276 | 1276 |
void set(const Key& key, Value value) const { |
1277 | 1277 |
if (value) { |
1278 | 1278 |
*_end++ = _functor(key); |
1279 | 1279 |
} |
1280 | 1280 |
} |
1281 | 1281 |
|
1282 | 1282 |
private: |
1283 | 1283 |
Iterator _begin; |
1284 | 1284 |
mutable Iterator _end; |
1285 | 1285 |
Functor _functor; |
1286 | 1286 |
}; |
1287 | 1287 |
|
1288 | 1288 |
/// \brief Writable bool map for logging each \c true assigned element in |
1289 | 1289 |
/// a back insertable container. |
1290 | 1290 |
/// |
1291 | 1291 |
/// Writable bool map for logging each \c true assigned element by pushing |
1292 | 1292 |
/// them into a back insertable container. |
1293 | 1293 |
/// It can be used to retrieve the items into a standard |
1294 | 1294 |
/// container. The next example shows how you can store the |
1295 | 1295 |
/// edges found by the Prim algorithm in a vector. |
1296 | 1296 |
/// |
1297 | 1297 |
///\code |
1298 | 1298 |
/// vector<Edge> span_tree_edges; |
1299 | 1299 |
/// BackInserterBoolMap<vector<Edge> > inserter_map(span_tree_edges); |
1300 | 1300 |
/// prim(graph, cost, inserter_map); |
1301 | 1301 |
///\endcode |
1302 | 1302 |
/// |
1303 | 1303 |
///\sa StoreBoolMap |
1304 | 1304 |
///\sa FrontInserterBoolMap |
1305 | 1305 |
///\sa InserterBoolMap |
1306 | 1306 |
template <typename Container, |
1307 | 1307 |
typename Functor = |
1308 | 1308 |
_maps_bits::Identity<typename Container::value_type> > |
1309 | 1309 |
class BackInserterBoolMap { |
1310 | 1310 |
public: |
1311 |
typedef typename |
|
1311 |
typedef typename Functor::argument_type Key; |
|
1312 | 1312 |
typedef bool Value; |
1313 | 1313 |
|
1314 | 1314 |
/// Constructor |
1315 | 1315 |
BackInserterBoolMap(Container& _container, |
1316 | 1316 |
const Functor& _functor = Functor()) |
1317 | 1317 |
: container(_container), functor(_functor) {} |
1318 | 1318 |
|
1319 | 1319 |
/// The \c set function of the map |
1320 | 1320 |
void set(const Key& key, Value value) { |
1321 | 1321 |
if (value) { |
1322 | 1322 |
container.push_back(functor(key)); |
1323 | 1323 |
} |
1324 | 1324 |
} |
1325 | 1325 |
|
1326 | 1326 |
private: |
1327 | 1327 |
Container& container; |
1328 | 1328 |
Functor functor; |
1329 | 1329 |
}; |
1330 | 1330 |
|
1331 | 1331 |
/// \brief Writable bool map for logging each \c true assigned element in |
1332 | 1332 |
/// a front insertable container. |
1333 | 1333 |
/// |
1334 | 1334 |
/// Writable bool map for logging each \c true assigned element by pushing |
1335 | 1335 |
/// them into a front insertable container. |
1336 | 1336 |
/// It can be used to retrieve the items into a standard |
1337 | 1337 |
/// container. For example see \ref BackInserterBoolMap. |
1338 | 1338 |
/// |
1339 | 1339 |
///\sa BackInserterBoolMap |
1340 | 1340 |
///\sa InserterBoolMap |
1341 | 1341 |
template <typename Container, |
1342 | 1342 |
typename Functor = |
1343 | 1343 |
_maps_bits::Identity<typename Container::value_type> > |
1344 | 1344 |
class FrontInserterBoolMap { |
1345 | 1345 |
public: |
1346 |
typedef typename |
|
1346 |
typedef typename Functor::argument_type Key; |
|
1347 | 1347 |
typedef bool Value; |
1348 | 1348 |
|
1349 | 1349 |
/// Constructor |
1350 | 1350 |
FrontInserterBoolMap(Container& _container, |
1351 | 1351 |
const Functor& _functor = Functor()) |
1352 | 1352 |
: container(_container), functor(_functor) {} |
1353 | 1353 |
|
1354 | 1354 |
/// The \c set function of the map |
1355 | 1355 |
void set(const Key& key, Value value) { |
1356 | 1356 |
if (value) { |
1357 | 1357 |
container.push_front(functor(key)); |
1358 | 1358 |
} |
1359 | 1359 |
} |
1360 | 1360 |
|
1361 | 1361 |
private: |
1362 | 1362 |
Container& container; |
1363 | 1363 |
Functor functor; |
1364 | 1364 |
}; |
1365 | 1365 |
|
1366 | 1366 |
/// \brief Writable bool map for storing each \c true assigned element in |
1367 | 1367 |
/// an insertable container. |
1368 | 1368 |
/// |
1369 | 1369 |
/// Writable bool map for storing each \c true assigned element in an |
1370 | 1370 |
/// insertable container. It will insert all the keys set to \c true into |
1371 | 1371 |
/// the container. |
1372 | 1372 |
/// |
1373 | 1373 |
/// For example, if you want to store the cut arcs of the strongly |
1374 | 1374 |
/// connected components in a set you can use the next code: |
1375 | 1375 |
/// |
1376 | 1376 |
///\code |
1377 | 1377 |
/// set<Arc> cut_arcs; |
1378 | 1378 |
/// InserterBoolMap<set<Arc> > inserter_map(cut_arcs); |
1379 | 1379 |
/// stronglyConnectedCutArcs(digraph, cost, inserter_map); |
1380 | 1380 |
///\endcode |
1381 | 1381 |
/// |
1382 | 1382 |
///\sa BackInserterBoolMap |
1383 | 1383 |
///\sa FrontInserterBoolMap |
1384 | 1384 |
template <typename Container, |
1385 | 1385 |
typename Functor = |
1386 | 1386 |
_maps_bits::Identity<typename Container::value_type> > |
1387 | 1387 |
class InserterBoolMap { |
1388 | 1388 |
public: |
1389 | 1389 |
typedef typename Container::value_type Key; |
1390 | 1390 |
typedef bool Value; |
1391 | 1391 |
|
1392 | 1392 |
/// Constructor with specified iterator |
1393 | 1393 |
|
1394 | 1394 |
/// Constructor with specified iterator. |
0 comments (0 inline)