0
15
2
3
15
49
8
2
20
57
12
12
| 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
|
| 2 |
* |
|
| 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
|
| 4 |
* |
|
| 5 |
* Copyright (C) 2003-2008 |
|
| 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
|
| 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
|
| 8 |
* |
|
| 9 |
* Permission to use, modify and distribute this software is granted |
|
| 10 |
* provided that this copyright notice appears in all copies. For |
|
| 11 |
* precise terms see the accompanying LICENSE file. |
|
| 12 |
* |
|
| 13 |
* This software is provided "AS IS" with no warranty of any kind, |
|
| 14 |
* express or implied, and with no claim as to its suitability for any |
|
| 15 |
* purpose. |
|
| 16 |
* |
|
| 17 |
*/ |
|
| 18 |
|
|
| 19 |
/*! |
|
| 20 |
|
|
| 21 |
\page named-param Named Parameters |
|
| 22 |
|
|
| 23 |
\section named-func-param Named Function Parameters |
|
| 24 |
|
|
| 25 |
Several modern languages provide a convenient way to refer the |
|
| 26 |
function parameters by name also when you call the function. It is |
|
| 27 |
especially comfortable in case of a function having tons of parameters |
|
| 28 |
with natural default values. Sadly, C++ lack this amenity. |
|
| 29 |
|
|
| 30 |
However, with a crafty trick and with some little |
|
| 31 |
inconvenience, it is possible to emulate is. |
|
| 32 |
The example below shows how to do it. |
|
| 33 |
|
|
| 34 |
\code |
|
| 35 |
class namedFn |
|
| 36 |
{
|
|
| 37 |
int _id; |
|
| 38 |
double _val; |
|
| 39 |
int _dim; |
|
| 40 |
|
|
| 41 |
public: |
|
| 42 |
namedFn() : _id(0), _val(1), _dim(2) {}
|
|
| 43 |
namedFn& id(int p) { _id = p ; return *this; }
|
|
| 44 |
namedFn& val(double p) { _val = p ; return *this; }
|
|
| 45 |
namedFn& dim(int p) { _dim = p ; return *this; }
|
|
| 46 |
|
|
| 47 |
run() {
|
|
| 48 |
std::cout << "Here comes the function itself\n" << |
|
| 49 |
<< "With parameters " |
|
| 50 |
<< _id << ", " << _val << ", " << _dim << std::endl; |
|
| 51 |
} |
|
| 52 |
}; |
|
| 53 |
\endcode |
|
| 54 |
|
|
| 55 |
Then you can use it like this. |
|
| 56 |
|
|
| 57 |
\code |
|
| 58 |
namedFn().id(3).val(2).run(); |
|
| 59 |
\endcode |
|
| 60 |
|
|
| 61 |
The trick is obvious, each "named parameter" changes one component of |
|
| 62 |
the underlying class, then gives back a reference to it. Finally, |
|
| 63 |
<tt>run()</tt> executes the algorithm itself. |
|
| 64 |
|
|
| 65 |
\note Although it is a class, namedFn is used pretty much like as it were |
|
| 66 |
a function. That it why we called it namedFn instead of \c NamedFn. |
|
| 67 |
|
|
| 68 |
\note In fact, the final <tt>.run()</tt> could be made unnecessary, |
|
| 69 |
because the algorithm could also be implemented in the destructor of |
|
| 70 |
\c namedFn instead. This however would make it impossible to implement |
|
| 71 |
functions with return values, and would also cause serious problems when |
|
| 72 |
implementing \ref named-templ-func-param "named template parameters". |
|
| 73 |
<b>Therefore, by convention, <tt>.run()</tt> must be used |
|
| 74 |
explicitly to execute a function having named parameters |
|
| 75 |
everywhere in LEMON.</b> |
|
| 76 |
|
|
| 77 |
\section named-templ-func-param Named Function Template Parameters |
|
| 78 |
|
|
| 79 |
A named parameter can also be a template function. The usage is |
|
| 80 |
exactly the same, but the implementation behind is a kind of black |
|
| 81 |
magic and they are the dirtiest part of the LEMON code. |
|
| 82 |
|
|
| 83 |
You will probably never need to know how it works, but if you really |
|
| 84 |
committed, have a look at \ref lemon/graph_to_eps.h for an example. |
|
| 85 |
|
|
| 86 |
\section traits-classes Traits Classes |
|
| 87 |
|
|
| 88 |
A similar game can also be played when defining classes. In this case |
|
| 89 |
the type of the class attributes can be changed. Initially we have to |
|
| 90 |
define a special class called <em>Traits Class</em> defining the |
|
| 91 |
default type of the attributes. Then the types of these attributes can |
|
| 92 |
be changed in the same way as described in the next section. |
|
| 93 |
|
|
| 94 |
See \ref lemon::DijkstraDefaultTraits for an |
|
| 95 |
example how a traits class implementation looks like. |
|
| 96 |
|
|
| 97 |
\section named-templ-param Named Class Template Parameters |
|
| 98 |
|
|
| 99 |
If we would like to change the type of an attribute in a class that |
|
| 100 |
was instantiated by using a traits class as a template parameter, and |
|
| 101 |
the class contains named parameters, we do not have to instantiate again |
|
| 102 |
the class with new traits class, but instead adaptor classes can |
|
| 103 |
be used as shown in the following example. |
|
| 104 |
|
|
| 105 |
\code |
|
| 106 |
Dijkstra<>::SetPredMap<NullMap<Node,Arc> >::Create |
|
| 107 |
\endcode |
|
| 108 |
|
|
| 109 |
It can also be used in conjunction with other named template |
|
| 110 |
parameters in arbitrary order. |
|
| 111 |
|
|
| 112 |
\code |
|
| 113 |
Dijkstra<>::SetDistMap<MyMap>::SetPredMap<NullMap<Node,Arc> >::Create |
|
| 114 |
\endcode |
|
| 115 |
|
|
| 116 |
The result will be an instantiated Dijkstra class, in which the |
|
| 117 |
DistMap and the PredMap is modified. |
|
| 118 |
|
|
| 119 |
*/ |
| 1 |
#! /usr/bin/env python |
|
| 2 |
|
|
| 3 |
import sys |
|
| 4 |
import os |
|
| 5 |
|
|
| 6 |
if len(sys.argv)>1 and sys.argv[1] in ["-h","--help"]: |
|
| 7 |
print """ |
|
| 8 |
This utility just prints the length of the longest path |
|
| 9 |
in the revision graph from revison 0 to the current one. |
|
| 10 |
""" |
|
| 11 |
exit(0) |
|
| 12 |
plist = os.popen("hg parents --template='{rev}\n'").readlines()
|
|
| 13 |
if len(plist)>1: |
|
| 14 |
print "You are in the process of merging" |
|
| 15 |
exit(1) |
|
| 16 |
PAR = int(plist[0]) |
|
| 17 |
|
|
| 18 |
f = os.popen("hg log -r 0:tip --template='{rev} {parents}\n'").readlines()
|
|
| 19 |
REV = -1 |
|
| 20 |
lengths=[] |
|
| 21 |
for l in f: |
|
| 22 |
REV+=1 |
|
| 23 |
s = l.split() |
|
| 24 |
rev = int(s[0]) |
|
| 25 |
if REV != rev: |
|
| 26 |
print "Something is seriously wrong" |
|
| 27 |
exit(1) |
|
| 28 |
if len(s) == 1: |
|
| 29 |
par1 = par2 = rev - 1 |
|
| 30 |
elif len(s) == 2: |
|
| 31 |
par1 = par2 = int(s[1].split(":")[0])
|
|
| 32 |
else: |
|
| 33 |
par1 = int(s[1].split(":")[0])
|
|
| 34 |
par2 = int(s[2].split(":")[0])
|
|
| 35 |
if rev == 0: |
|
| 36 |
lengths.append(0) |
|
| 37 |
else: |
|
| 38 |
lengths.append(max(lengths[par1],lengths[par2])+1) |
|
| 39 |
print lengths[PAR] |
| 1 | 1 |
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) |
| 2 | 2 |
|
| 3 |
#EXECUTE_PROCESS( |
|
| 4 |
# COMMAND hg id -i |
|
| 5 |
# OUTPUT_VARIABLE HG_REVISION |
|
| 6 |
# OUTPUT_STRIP_TRAILING_WHITESPACE) |
|
| 7 |
|
|
| 8 | 3 |
SET(PROJECT_NAME "LEMON") |
| 9 |
SET(PROJECT_VERSION_MAJOR "0") |
|
| 10 |
SET(PROJECT_VERSION_MINOR "99") |
|
| 11 |
SET(PROJECT_VERSION_PATCH "0") |
|
| 12 |
SET(PROJECT_VERSION |
|
| 13 |
|
|
| 4 |
SET(PROJECT_VERSION "hg-tip" CACHE STRING "The version string.") |
|
| 14 | 5 |
|
| 15 | 6 |
PROJECT(${PROJECT_NAME})
|
| 16 | 7 |
|
| 17 | 8 |
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
| 18 | 9 |
|
| 19 | 10 |
INCLUDE(FindDoxygen) |
| 20 | 11 |
INCLUDE(FindGhostscript) |
| 21 | 12 |
|
| 22 | 13 |
ENABLE_TESTING() |
| 23 | 14 |
|
| 24 | 15 |
ADD_SUBDIRECTORY(lemon) |
| 25 | 16 |
ADD_SUBDIRECTORY(demo) |
| ... | ... |
@@ -30,33 +21,30 @@ |
| 30 | 21 |
INSTALL(FILES ${CMAKE_SOURCE_DIR}/cmake/nsis/lemon.ico
|
| 31 | 22 |
DESTINATION bin) |
| 32 | 23 |
ENDIF(WIN32) |
| 33 | 24 |
|
| 34 | 25 |
IF(WIN32) |
| 35 | 26 |
SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
|
| 36 | 27 |
SET(CPACK_PACKAGE_VENDOR |
| 37 | 28 |
"EGRES - Egervary Research Group on Combinatorial Optimization") |
| 38 | 29 |
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY |
| 39 | 30 |
"LEMON - Library of Efficient Models and Optimization in Networks") |
| 40 | 31 |
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
|
| 41 | 32 |
|
| 42 |
SET(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
|
| 43 |
SET(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
|
| 44 |
SET(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
|
| 45 | 33 |
SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
| 46 | 34 |
|
| 47 | 35 |
SET(CPACK_PACKAGE_INSTALL_DIRECTORY |
| 48 |
"${PROJECT_NAME} ${
|
|
| 36 |
"${PROJECT_NAME} ${PROJECT_VERSION}")
|
|
| 49 | 37 |
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY |
| 50 |
"${PROJECT_NAME} ${
|
|
| 38 |
"${PROJECT_NAME} ${PROJECT_VERSION}")
|
|
| 51 | 39 |
|
| 52 | 40 |
# Variables to generate a component-based installer. |
| 53 | 41 |
#SET(CPACK_COMPONENTS_ALL headers library html_documentation) |
| 54 | 42 |
|
| 55 | 43 |
#SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers") |
| 56 | 44 |
#SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Static library") |
| 57 | 45 |
#SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation") |
| 58 | 46 |
|
| 59 | 47 |
#SET(CPACK_COMPONENT_HEADERS_DESCRIPTION |
| 60 | 48 |
# "C++ header files for use with the LEMON library") |
| 61 | 49 |
#SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION |
| 62 | 50 |
# "Static library used to build programs with LEMON") |
| 1 |
20XX-XX-XX Version 1.0 released |
|
| 2 |
|
|
| 3 |
This is the first stable release of LEMON. Compared to the 0.x |
|
| 4 |
release series, it features a considerably smaller but more |
|
| 5 |
matured set of tools. The API has also completely revised and |
|
| 6 |
changed in several places. |
|
| 7 |
|
|
| 8 |
* The major name changes compared to the 0.x series |
|
| 9 |
* Graph -> Digraph, UGraph -> Graph |
|
| 10 |
* Edge -> Arc, UEdge -> Edge |
|
| 11 |
* source(UEdge)/target(UEdge) -> u(Edge)/v(Edge) |
|
| 12 |
* Other improvements |
|
| 13 |
* Better documentation |
|
| 14 |
* Reviewed and cleaned up codebase |
|
| 15 |
* CMake based build system (along with the autotools based one) |
|
| 16 |
* Contents of the library (ported from 0.x) |
|
| 17 |
* Algorithms |
|
| 18 |
* breadth-first search (bfs.h) |
|
| 19 |
* depth-first search (dfs.h) |
|
| 20 |
* Dijkstra's algorithm (dijkstra.h) |
|
| 21 |
* Kruskal's algorithm (kruskal.h) |
|
| 22 |
* Data structures |
|
| 23 |
* graph data structures (list_graph.h, smart_graph.h) |
|
| 24 |
* path data structures (path.h) |
|
| 25 |
* binary heap data structure (bin_heap.h) |
|
| 26 |
* union-find data structures (unionfind.h) |
|
| 27 |
* miscellaneous property maps (maps.h) |
|
| 28 |
* two dimensional vector and bounding box (dim2.h) |
|
| 29 |
* Concepts |
|
| 30 |
* graph structure concepts (concepts/digraph.h, concepts/graph.h, |
|
| 31 |
concepts/graph_components.h) |
|
| 32 |
* concepts for other structures (concepts/heap.h, concepts/maps.h, |
|
| 33 |
concepts/path.h) |
|
| 34 |
* Tools |
|
| 35 |
* Mersenne twister random number generator (random.h) |
|
| 36 |
* tools for measuring cpu and wall clock time (time_measure.h) |
|
| 37 |
* tools for counting steps and events (counter.h) |
|
| 38 |
* tool for parsing command line arguments (arg_parser.h) |
|
| 39 |
* tool for visualizing graphs (graph_to_eps.h) |
|
| 40 |
* tools for reading and writing data in LEMON Graph Format |
|
| 41 |
(lgf_reader.h, lgf_writer.h) |
|
| 42 |
* tools to handle the anomalies of calculations with |
|
| 43 |
floating point numbers (tolerance.h) |
|
| 44 |
* tools to manage RGB colors (color.h) |
|
| 45 |
* Infrastructure |
|
| 46 |
* extended assertion handling (assert.h) |
|
| 47 |
* exception classes and error handling (error.h) |
|
| 48 |
* concept checking (concept_check.h) |
|
| 49 |
* commonly used mathematical constants (math.h) |
| 1 | 1 |
dnl Process this file with autoconf to produce a configure script. |
| 2 | 2 |
|
| 3 | 3 |
dnl Version information. |
| 4 |
m4_define([lemon_version_number], |
|
| 4 |
m4_define([lemon_version_number], |
|
| 5 |
[m4_normalize(esyscmd([echo ${LEMON_VERSION}]))])
|
|
| 6 |
dnl m4_define([lemon_version_number], []) |
|
| 7 |
m4_define([lemon_hg_path], [m4_normalize(esyscmd([./scripts/chg-len.py]))]) |
|
| 5 | 8 |
m4_define([lemon_hg_revision], [m4_normalize(esyscmd([hg id -i]))]) |
| 6 |
m4_define([lemon_version], [ifelse(lemon_version_number(), |
|
| 9 |
m4_define([lemon_version], [ifelse(lemon_version_number(), |
|
| 10 |
[], |
|
| 11 |
[lemon_hg_path().lemon_hg_revision()], |
|
| 12 |
[lemon_version_number()])]) |
|
| 7 | 13 |
|
| 8 | 14 |
AC_PREREQ([2.59]) |
| 9 | 15 |
AC_INIT([LEMON], [lemon_version()], [lemon-user@lemon.cs.elte.hu], [lemon]) |
| 10 | 16 |
AC_CONFIG_AUX_DIR([build-aux]) |
| 11 | 17 |
AC_CONFIG_MACRO_DIR([m4]) |
| 12 | 18 |
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects nostdinc]) |
| 13 | 19 |
AC_CONFIG_SRCDIR([lemon/list_graph.h]) |
| 14 | 20 |
AC_CONFIG_HEADERS([config.h lemon/config.h]) |
| 15 | 21 |
|
| 16 | 22 |
lx_cmdline_cxxflags_set=${CXXFLAGS+set}
|
| 17 | 23 |
|
| 18 | 24 |
dnl Checks for programs. |
| 1 | 1 |
EXTRA_DIST += \ |
| 2 | 2 |
doc/Doxyfile.in \ |
| 3 | 3 |
doc/coding_style.dox \ |
| 4 | 4 |
doc/dirs.dox \ |
| 5 | 5 |
doc/groups.dox \ |
| 6 | 6 |
doc/lgf.dox \ |
| 7 | 7 |
doc/license.dox \ |
| 8 | 8 |
doc/mainpage.dox \ |
| 9 |
doc/named-param.dox \ |
|
| 9 | 10 |
doc/namespaces.dox \ |
| 10 | 11 |
doc/html \ |
| 11 | 12 |
doc/CMakeLists.txt |
| 12 | 13 |
|
| 13 | 14 |
DOC_EPS_IMAGES18 = \ |
| 14 | 15 |
nodeshape_0.eps \ |
| 15 | 16 |
nodeshape_1.eps \ |
| 16 | 17 |
nodeshape_2.eps \ |
| 17 | 18 |
nodeshape_3.eps \ |
| 18 | 19 |
nodeshape_4.eps |
| 19 | 20 |
|
| 20 | 21 |
DOC_EPS_IMAGES = \ |
| ... | ... |
@@ -7,26 +7,26 @@ |
| 7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
| 8 | 8 |
* |
| 9 | 9 |
* Permission to use, modify and distribute this software is granted |
| 10 | 10 |
* provided that this copyright notice appears in all copies. For |
| 11 | 11 |
* precise terms see the accompanying LICENSE file. |
| 12 | 12 |
* |
| 13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
| 14 | 14 |
* express or implied, and with no claim as to its suitability for any |
| 15 | 15 |
* purpose. |
| 16 | 16 |
* |
| 17 | 17 |
*/ |
| 18 | 18 |
|
| 19 |
#ifndef LEMON_ARG_PARSER |
|
| 20 |
#define LEMON_ARG_PARSER |
|
| 19 |
#ifndef LEMON_ARG_PARSER_H |
|
| 20 |
#define LEMON_ARG_PARSER_H |
|
| 21 | 21 |
|
| 22 | 22 |
#include <vector> |
| 23 | 23 |
#include <map> |
| 24 | 24 |
#include <list> |
| 25 | 25 |
#include <string> |
| 26 | 26 |
#include <iostream> |
| 27 | 27 |
#include <sstream> |
| 28 | 28 |
#include <algorithm> |
| 29 | 29 |
#include <lemon/assert.h> |
| 30 | 30 |
|
| 31 | 31 |
///\ingroup misc |
| 32 | 32 |
///\file |
| ... | ... |
@@ -373,13 +373,13 @@ |
| 373 | 373 |
return RefType(*this, n); |
| 374 | 374 |
} |
| 375 | 375 |
|
| 376 | 376 |
///Give back the non-option type arguments. |
| 377 | 377 |
|
| 378 | 378 |
///Give back a reference to a vector consisting of the program arguments |
| 379 | 379 |
///not starting with a '-' character. |
| 380 | 380 |
const std::vector<std::string> &files() const { return _file_args; }
|
| 381 | 381 |
|
| 382 | 382 |
}; |
| 383 | 383 |
} |
| 384 | 384 |
|
| 385 |
#endif // |
|
| 385 |
#endif // LEMON_ARG_PARSER_H |
| ... | ... |
@@ -18,145 +18,130 @@ |
| 18 | 18 |
|
| 19 | 19 |
#ifndef LEMON_ASSERT_H |
| 20 | 20 |
#define LEMON_ASSERT_H |
| 21 | 21 |
|
| 22 | 22 |
/// \ingroup exceptions |
| 23 | 23 |
/// \file |
| 24 | 24 |
/// \brief Extended assertion handling |
| 25 | 25 |
|
| 26 | 26 |
#include <lemon/error.h> |
| 27 | 27 |
|
| 28 | 28 |
namespace lemon {
|
| 29 | 29 |
|
| 30 |
inline void assert_fail_log(const char *file, int line, const char *function, |
|
| 31 |
const char *message, const char *assertion) |
|
| 30 |
inline void assert_fail_abort(const char *file, int line, |
|
| 31 |
const char *function, const char* message, |
|
| 32 |
const char *assertion) |
|
| 32 | 33 |
{
|
| 33 | 34 |
std::cerr << file << ":" << line << ": "; |
| 34 | 35 |
if (function) |
| 35 | 36 |
std::cerr << function << ": "; |
| 36 | 37 |
std::cerr << message; |
| 37 | 38 |
if (assertion) |
| 38 | 39 |
std::cerr << " (assertion '" << assertion << "' failed)"; |
| 39 | 40 |
std::cerr << std::endl; |
| 40 |
} |
|
| 41 |
|
|
| 42 |
inline void assert_fail_abort(const char *file, int line, |
|
| 43 |
const char *function, const char* message, |
|
| 44 |
const char *assertion) |
|
| 45 |
{
|
|
| 46 |
assert_fail_log(file, line, function, message, assertion); |
|
| 47 | 41 |
std::abort(); |
| 48 | 42 |
} |
| 49 | 43 |
|
| 50 | 44 |
namespace _assert_bits {
|
| 51 | 45 |
|
| 52 | 46 |
|
| 53 | 47 |
inline const char* cstringify(const std::string& str) {
|
| 54 | 48 |
return str.c_str(); |
| 55 | 49 |
} |
| 56 | 50 |
|
| 57 | 51 |
inline const char* cstringify(const char* str) {
|
| 58 | 52 |
return str; |
| 59 | 53 |
} |
| 60 | 54 |
} |
| 61 | 55 |
} |
| 62 | 56 |
|
| 63 | 57 |
#endif // LEMON_ASSERT_H |
| 64 | 58 |
|
| 65 | 59 |
#undef LEMON_ASSERT |
| 66 |
#undef LEMON_FIXME |
|
| 67 | 60 |
#undef LEMON_DEBUG |
| 68 | 61 |
|
| 69 |
#if (defined(LEMON_ASSERT_LOG) ? 1 : 0) + \ |
|
| 70 |
(defined(LEMON_ASSERT_ABORT) ? 1 : 0) + \ |
|
| 62 |
#if (defined(LEMON_ASSERT_ABORT) ? 1 : 0) + \ |
|
| 71 | 63 |
(defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) > 1 |
| 72 | 64 |
#error "LEMON assertion system is not set properly" |
| 73 | 65 |
#endif |
| 74 | 66 |
|
| 75 |
#if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) + \ |
|
| 76 |
(defined(LEMON_ASSERT_ABORT) ? 1 : 0) + \ |
|
| 67 |
#if ((defined(LEMON_ASSERT_ABORT) ? 1 : 0) + \ |
|
| 77 | 68 |
(defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 || \ |
| 78 | 69 |
defined(LEMON_ENABLE_ASSERTS)) && \ |
| 79 | 70 |
(defined(LEMON_DISABLE_ASSERTS) || \ |
| 80 | 71 |
defined(NDEBUG)) |
| 81 | 72 |
#error "LEMON assertion system is not set properly" |
| 82 | 73 |
#endif |
| 83 | 74 |
|
| 84 | 75 |
|
| 85 |
#if defined LEMON_ASSERT_LOG |
|
| 86 |
# undef LEMON_ASSERT_HANDLER |
|
| 87 |
# define LEMON_ASSERT_HANDLER ::lemon::assert_fail_log |
|
| 88 |
#elif defined LEMON_ASSERT_ABORT |
|
| 76 |
#if defined LEMON_ASSERT_ABORT |
|
| 89 | 77 |
# undef LEMON_ASSERT_HANDLER |
| 90 | 78 |
# define LEMON_ASSERT_HANDLER ::lemon::assert_fail_abort |
| 91 | 79 |
#elif defined LEMON_ASSERT_CUSTOM |
| 92 | 80 |
# undef LEMON_ASSERT_HANDLER |
| 93 | 81 |
# ifndef LEMON_CUSTOM_ASSERT_HANDLER |
| 94 | 82 |
# error "LEMON_CUSTOM_ASSERT_HANDLER is not set" |
| 95 | 83 |
# endif |
| 96 | 84 |
# define LEMON_ASSERT_HANDLER LEMON_CUSTOM_ASSERT_HANDLER |
| 97 | 85 |
#elif defined LEMON_DISABLE_ASSERTS |
| 98 | 86 |
# undef LEMON_ASSERT_HANDLER |
| 99 | 87 |
#elif defined NDEBUG |
| 100 | 88 |
# undef LEMON_ASSERT_HANDLER |
| 101 | 89 |
#else |
| 102 | 90 |
# define LEMON_ASSERT_HANDLER ::lemon::assert_fail_abort |
| 103 | 91 |
#endif |
| 104 | 92 |
|
| 105 | 93 |
#ifndef LEMON_FUNCTION_NAME |
| 106 | 94 |
# if defined __GNUC__ |
| 107 | 95 |
# define LEMON_FUNCTION_NAME (__PRETTY_FUNCTION__) |
| 108 | 96 |
# elif defined _MSC_VER |
| 109 | 97 |
# define LEMON_FUNCTION_NAME (__FUNCSIG__) |
| 98 |
# elif __STDC_VERSION__ >= 199901L |
|
| 99 |
# define LEMON_FUNCTION_NAME (__func__) |
|
| 110 | 100 |
# else |
| 111 |
# define LEMON_FUNCTION_NAME ( |
|
| 101 |
# define LEMON_FUNCTION_NAME ("<unknown>")
|
|
| 112 | 102 |
# endif |
| 113 | 103 |
#endif |
| 114 | 104 |
|
| 115 | 105 |
#ifdef DOXYGEN |
| 116 | 106 |
|
| 117 | 107 |
/// \ingroup exceptions |
| 118 | 108 |
/// |
| 119 | 109 |
/// \brief Macro for assertion with customizable message |
| 120 | 110 |
/// |
| 121 |
/// Macro for assertion with customizable message. \param exp An |
|
| 122 |
/// expression that must be convertible to \c bool. If it is \c |
|
| 123 |
/// false, then an assertion is raised. The concrete behaviour depends |
|
| 124 |
/// on the settings of the assertion system. \param msg A <tt>const |
|
| 125 |
/// char*</tt> parameter, which can be used to provide information |
|
| 126 |
/// about the circumstances of the failed assertion. |
|
| 111 |
/// Macro for assertion with customizable message. |
|
| 112 |
/// \param exp An expression that must be convertible to \c bool. If it is \c |
|
| 113 |
/// false, then an assertion is raised. The concrete behaviour depends on the |
|
| 114 |
/// settings of the assertion system. |
|
| 115 |
/// \param msg A <tt>const char*</tt> parameter, which can be used to provide |
|
| 116 |
/// information about the circumstances of the failed assertion. |
|
| 127 | 117 |
/// |
| 128 | 118 |
/// The assertions are enabled in the default behaviour. |
| 129 | 119 |
/// You can disable them with the following code: |
| 130 | 120 |
/// \code |
| 131 | 121 |
/// #define LEMON_DISABLE_ASSERTS |
| 132 | 122 |
/// \endcode |
| 133 | 123 |
/// or with compilation parameters: |
| 134 | 124 |
/// \code |
| 135 | 125 |
/// g++ -DLEMON_DISABLE_ASSERTS |
| 136 | 126 |
/// make CXXFLAGS='-DLEMON_DISABLE_ASSERTS' |
| 137 | 127 |
/// \endcode |
| 138 | 128 |
/// The checking is also disabled when the standard macro \c NDEBUG is defined. |
| 139 | 129 |
/// |
| 140 |
/// The LEMON assertion system has a wide range of customization |
|
| 141 |
/// properties. As a default behaviour the failed assertion prints a |
|
| 142 |
/// short log message to |
|
| 130 |
/// As a default behaviour the failed assertion prints a short log message to |
|
| 131 |
/// the standard error and aborts the execution. |
|
| 143 | 132 |
/// |
| 144 |
/// The following modes can be used in the assertion system: |
|
| 145 |
/// |
|
| 146 |
/// - \c LEMON_ASSERT_LOG The failed assertion prints a short log |
|
| 147 |
/// message to the standard error and continues the execution. |
|
| 148 |
/// - \c LEMON_ASSERT_ABORT This mode is similar to the \c |
|
| 149 |
/// LEMON_ASSERT_LOG, but it aborts the program. It is the default |
|
| 150 |
/// |
|
| 133 |
/// However, the following modes can be used in the assertion system: |
|
| 134 |
/// - \c LEMON_ASSERT_ABORT The failed assertion prints a short log message to |
|
| 135 |
/// the standard error and aborts the program. It is the default behaviour. |
|
| 151 | 136 |
/// - \c LEMON_ASSERT_CUSTOM The user can define own assertion handler |
| 152 | 137 |
/// function. |
| 153 | 138 |
/// \code |
| 154 | 139 |
/// void custom_assert_handler(const char* file, int line, |
| 155 | 140 |
/// const char* function, const char* message, |
| 156 | 141 |
/// const char* assertion); |
| 157 | 142 |
/// \endcode |
| 158 | 143 |
/// The name of the function should be defined as the \c |
| 159 | 144 |
/// LEMON_CUSTOM_ASSERT_HANDLER macro name. |
| 160 | 145 |
/// \code |
| 161 | 146 |
/// #define LEMON_CUSTOM_ASSERT_HANDLER custom_assert_handler |
| 162 | 147 |
/// \endcode |
| ... | ... |
@@ -166,40 +151,24 @@ |
| 166 | 151 |
/// The assertion mode can also be changed within one compilation unit. |
| 167 | 152 |
/// If the macros are redefined with other settings and the |
| 168 | 153 |
/// \ref lemon/assert.h "assert.h" file is reincluded, then the |
| 169 | 154 |
/// behaviour is changed appropiately to the new settings. |
| 170 | 155 |
# define LEMON_ASSERT(exp, msg) \ |
| 171 | 156 |
(static_cast<void> (!!(exp) ? 0 : ( \ |
| 172 | 157 |
LEMON_ASSERT_HANDLER(__FILE__, __LINE__, \ |
| 173 | 158 |
LEMON_FUNCTION_NAME, \ |
| 174 | 159 |
::lemon::_assert_bits::cstringify(msg), #exp), 0))) |
| 175 | 160 |
|
| 176 | 161 |
/// \ingroup exceptions |
| 177 | 162 |
/// |
| 178 |
/// \brief Macro for mark not yet implemented features. |
|
| 179 |
/// |
|
| 180 |
/// Macro for mark not yet implemented features and outstanding bugs. |
|
| 181 |
/// It is close to be the shortcut of the following code: |
|
| 182 |
/// \code |
|
| 183 |
/// LEMON_ASSERT(false, msg); |
|
| 184 |
/// \endcode |
|
| 185 |
/// |
|
| 186 |
/// \see LEMON_ASSERT |
|
| 187 |
# define LEMON_FIXME(msg) \ |
|
| 188 |
(LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME, \ |
|
| 189 |
::lemon::_assert_bits::cstringify(msg), \ |
|
| 190 |
static_cast<const char*>(0))) |
|
| 191 |
|
|
| 192 |
/// \ingroup exceptions |
|
| 193 |
/// |
|
| 194 | 163 |
/// \brief Macro for internal assertions |
| 195 | 164 |
/// |
| 196 | 165 |
/// Macro for internal assertions, it is used in the library to check |
| 197 | 166 |
/// the consistency of results of algorithms, several pre- and |
| 198 | 167 |
/// postconditions and invariants. The checking is disabled by |
| 199 | 168 |
/// default, but it can be turned on with the macro \c |
| 200 | 169 |
/// LEMON_ENABLE_DEBUG. |
| 201 | 170 |
/// \code |
| 202 | 171 |
/// #define LEMON_ENABLE_DEBUG |
| 203 | 172 |
/// \endcode |
| 204 | 173 |
/// or with compilation parameters: |
| 205 | 174 |
/// \code |
| ... | ... |
@@ -213,38 +182,32 @@ |
| 213 | 182 |
/// |
| 214 | 183 |
/// \see LEMON_ASSERT |
| 215 | 184 |
# define LEMON_DEBUG(exp, msg) \ |
| 216 | 185 |
(static_cast<void> (!!(exp) ? 0 : ( \ |
| 217 | 186 |
LEMON_ASSERT_HANDLER(__FILE__, __LINE__, \ |
| 218 | 187 |
LEMON_FUNCTION_NAME, \ |
| 219 | 188 |
::lemon::_assert_bits::cstringify(msg), #exp), 0))) |
| 220 | 189 |
|
| 221 | 190 |
#else |
| 222 | 191 |
|
| 223 | 192 |
# ifndef LEMON_ASSERT_HANDLER |
| 224 | 193 |
# define LEMON_ASSERT(exp, msg) (static_cast<void>(0)) |
| 225 |
# define LEMON_FIXME(msg) (static_cast<void>(0)) |
|
| 226 | 194 |
# define LEMON_DEBUG(exp, msg) (static_cast<void>(0)) |
| 227 | 195 |
# else |
| 228 | 196 |
# define LEMON_ASSERT(exp, msg) \ |
| 229 | 197 |
(static_cast<void> (!!(exp) ? 0 : ( \ |
| 230 | 198 |
LEMON_ASSERT_HANDLER(__FILE__, __LINE__, \ |
| 231 | 199 |
LEMON_FUNCTION_NAME, \ |
| 232 | 200 |
::lemon::_assert_bits::cstringify(msg), \ |
| 233 | 201 |
#exp), 0))) |
| 234 |
# define LEMON_FIXME(msg) \ |
|
| 235 |
(LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME, \ |
|
| 236 |
::lemon::_assert_bits::cstringify(msg), \ |
|
| 237 |
static_cast<const char*>(0))) |
|
| 238 |
|
|
| 239 | 202 |
# if LEMON_ENABLE_DEBUG |
| 240 | 203 |
# define LEMON_DEBUG(exp, msg) \ |
| 241 | 204 |
(static_cast<void> (!!(exp) ? 0 : ( \ |
| 242 | 205 |
LEMON_ASSERT_HANDLER(__FILE__, __LINE__, \ |
| 243 | 206 |
LEMON_FUNCTION_NAME, \ |
| 244 | 207 |
::lemon::_assert_bits::cstringify(msg), \ |
| 245 | 208 |
#exp), 0))) |
| 246 | 209 |
# else |
| 247 | 210 |
# define LEMON_DEBUG(exp, msg) (static_cast<void>(0)) |
| 248 | 211 |
# endif |
| 249 | 212 |
# endif |
| 250 | 213 |
| ... | ... |
@@ -94,24 +94,25 @@ |
| 94 | 94 |
/// It constructs a map and initialize all of the the map. |
| 95 | 95 |
ArrayMap(const Graph& graph, const Value& value) {
|
| 96 | 96 |
Parent::attach(graph.notifier(Item())); |
| 97 | 97 |
allocate_memory(); |
| 98 | 98 |
Notifier* nf = Parent::notifier(); |
| 99 | 99 |
Item it; |
| 100 | 100 |
for (nf->first(it); it != INVALID; nf->next(it)) {
|
| 101 | 101 |
int id = nf->id(it);; |
| 102 | 102 |
allocator.construct(&(values[id]), value); |
| 103 | 103 |
} |
| 104 | 104 |
} |
| 105 | 105 |
|
| 106 |
private: |
|
| 106 | 107 |
/// \brief Constructor to copy a map of the same map type. |
| 107 | 108 |
/// |
| 108 | 109 |
/// Constructor to copy a map of the same map type. |
| 109 | 110 |
ArrayMap(const ArrayMap& copy) : Parent() {
|
| 110 | 111 |
if (copy.attached()) {
|
| 111 | 112 |
attach(*copy.notifier()); |
| 112 | 113 |
} |
| 113 | 114 |
capacity = copy.capacity; |
| 114 | 115 |
if (capacity == 0) return; |
| 115 | 116 |
values = allocator.allocate(capacity); |
| 116 | 117 |
Notifier* nf = Parent::notifier(); |
| 117 | 118 |
Item it; |
| ... | ... |
@@ -141,24 +142,25 @@ |
| 141 | 142 |
/// is assigned by the value of the given ReadMap. |
| 142 | 143 |
template <typename CMap> |
| 143 | 144 |
ArrayMap& operator=(const CMap& cmap) {
|
| 144 | 145 |
checkConcept<concepts::ReadMap<Key, _Value>, CMap>(); |
| 145 | 146 |
const typename Parent::Notifier* nf = Parent::notifier(); |
| 146 | 147 |
Item it; |
| 147 | 148 |
for (nf->first(it); it != INVALID; nf->next(it)) {
|
| 148 | 149 |
set(it, cmap[it]); |
| 149 | 150 |
} |
| 150 | 151 |
return *this; |
| 151 | 152 |
} |
| 152 | 153 |
|
| 154 |
public: |
|
| 153 | 155 |
/// \brief The destructor of the map. |
| 154 | 156 |
/// |
| 155 | 157 |
/// The destructor of the map. |
| 156 | 158 |
virtual ~ArrayMap() {
|
| 157 | 159 |
if (attached()) {
|
| 158 | 160 |
clear(); |
| 159 | 161 |
detach(); |
| 160 | 162 |
} |
| 161 | 163 |
} |
| 162 | 164 |
|
| 163 | 165 |
protected: |
| 164 | 166 |
| ... | ... |
@@ -218,48 +218,50 @@ |
| 218 | 218 |
template <typename _Value> |
| 219 | 219 |
class NodeMap |
| 220 | 220 |
: public MapExtender<DefaultMap<Digraph, Node, _Value> > {
|
| 221 | 221 |
public: |
| 222 | 222 |
typedef DigraphExtender Digraph; |
| 223 | 223 |
typedef MapExtender<DefaultMap<Digraph, Node, _Value> > Parent; |
| 224 | 224 |
|
| 225 | 225 |
explicit NodeMap(const Digraph& digraph) |
| 226 | 226 |
: Parent(digraph) {}
|
| 227 | 227 |
NodeMap(const Digraph& digraph, const _Value& value) |
| 228 | 228 |
: Parent(digraph, value) {}
|
| 229 | 229 |
|
| 230 |
private: |
|
| 230 | 231 |
NodeMap& operator=(const NodeMap& cmap) {
|
| 231 | 232 |
return operator=<NodeMap>(cmap); |
| 232 | 233 |
} |
| 233 | 234 |
|
| 234 | 235 |
template <typename CMap> |
| 235 | 236 |
NodeMap& operator=(const CMap& cmap) {
|
| 236 | 237 |
Parent::operator=(cmap); |
| 237 | 238 |
return *this; |
| 238 | 239 |
} |
| 239 | 240 |
|
| 240 | 241 |
}; |
| 241 | 242 |
|
| 242 | 243 |
template <typename _Value> |
| 243 | 244 |
class ArcMap |
| 244 | 245 |
: public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
|
| 245 | 246 |
public: |
| 246 | 247 |
typedef DigraphExtender Digraph; |
| 247 | 248 |
typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent; |
| 248 | 249 |
|
| 249 | 250 |
explicit ArcMap(const Digraph& digraph) |
| 250 | 251 |
: Parent(digraph) {}
|
| 251 | 252 |
ArcMap(const Digraph& digraph, const _Value& value) |
| 252 | 253 |
: Parent(digraph, value) {}
|
| 253 | 254 |
|
| 255 |
private: |
|
| 254 | 256 |
ArcMap& operator=(const ArcMap& cmap) {
|
| 255 | 257 |
return operator=<ArcMap>(cmap); |
| 256 | 258 |
} |
| 257 | 259 |
|
| 258 | 260 |
template <typename CMap> |
| 259 | 261 |
ArcMap& operator=(const CMap& cmap) {
|
| 260 | 262 |
Parent::operator=(cmap); |
| 261 | 263 |
return *this; |
| 262 | 264 |
} |
| 263 | 265 |
}; |
| 264 | 266 |
|
| 265 | 267 |
|
| ... | ... |
@@ -599,48 +601,50 @@ |
| 599 | 601 |
template <typename _Value> |
| 600 | 602 |
class NodeMap |
| 601 | 603 |
: public MapExtender<DefaultMap<Graph, Node, _Value> > {
|
| 602 | 604 |
public: |
| 603 | 605 |
typedef GraphExtender Graph; |
| 604 | 606 |
typedef MapExtender<DefaultMap<Graph, Node, _Value> > Parent; |
| 605 | 607 |
|
| 606 | 608 |
NodeMap(const Graph& graph) |
| 607 | 609 |
: Parent(graph) {}
|
| 608 | 610 |
NodeMap(const Graph& graph, const _Value& value) |
| 609 | 611 |
: Parent(graph, value) {}
|
| 610 | 612 |
|
| 613 |
private: |
|
| 611 | 614 |
NodeMap& operator=(const NodeMap& cmap) {
|
| 612 | 615 |
return operator=<NodeMap>(cmap); |
| 613 | 616 |
} |
| 614 | 617 |
|
| 615 | 618 |
template <typename CMap> |
| 616 | 619 |
NodeMap& operator=(const CMap& cmap) {
|
| 617 | 620 |
Parent::operator=(cmap); |
| 618 | 621 |
return *this; |
| 619 | 622 |
} |
| 620 | 623 |
|
| 621 | 624 |
}; |
| 622 | 625 |
|
| 623 | 626 |
template <typename _Value> |
| 624 | 627 |
class ArcMap |
| 625 | 628 |
: public MapExtender<DefaultMap<Graph, Arc, _Value> > {
|
| 626 | 629 |
public: |
| 627 | 630 |
typedef GraphExtender Graph; |
| 628 | 631 |
typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent; |
| 629 | 632 |
|
| 630 | 633 |
ArcMap(const Graph& graph) |
| 631 | 634 |
: Parent(graph) {}
|
| 632 | 635 |
ArcMap(const Graph& graph, const _Value& value) |
| 633 | 636 |
: Parent(graph, value) {}
|
| 634 | 637 |
|
| 638 |
private: |
|
| 635 | 639 |
ArcMap& operator=(const ArcMap& cmap) {
|
| 636 | 640 |
return operator=<ArcMap>(cmap); |
| 637 | 641 |
} |
| 638 | 642 |
|
| 639 | 643 |
template <typename CMap> |
| 640 | 644 |
ArcMap& operator=(const CMap& cmap) {
|
| 641 | 645 |
Parent::operator=(cmap); |
| 642 | 646 |
return *this; |
| 643 | 647 |
} |
| 644 | 648 |
}; |
| 645 | 649 |
|
| 646 | 650 |
|
| ... | ... |
@@ -648,24 +652,25 @@ |
| 648 | 652 |
class EdgeMap |
| 649 | 653 |
: public MapExtender<DefaultMap<Graph, Edge, _Value> > {
|
| 650 | 654 |
public: |
| 651 | 655 |
typedef GraphExtender Graph; |
| 652 | 656 |
typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent; |
| 653 | 657 |
|
| 654 | 658 |
EdgeMap(const Graph& graph) |
| 655 | 659 |
: Parent(graph) {}
|
| 656 | 660 |
|
| 657 | 661 |
EdgeMap(const Graph& graph, const _Value& value) |
| 658 | 662 |
: Parent(graph, value) {}
|
| 659 | 663 |
|
| 664 |
private: |
|
| 660 | 665 |
EdgeMap& operator=(const EdgeMap& cmap) {
|
| 661 | 666 |
return operator=<EdgeMap>(cmap); |
| 662 | 667 |
} |
| 663 | 668 |
|
| 664 | 669 |
template <typename CMap> |
| 665 | 670 |
EdgeMap& operator=(const CMap& cmap) {
|
| 666 | 671 |
Parent::operator=(cmap); |
| 667 | 672 |
return *this; |
| 668 | 673 |
} |
| 669 | 674 |
|
| 670 | 675 |
}; |
| 671 | 676 |
| ... | ... |
@@ -53,34 +53,36 @@ |
| 53 | 53 |
|
| 54 | 54 |
friend class MapIt; |
| 55 | 55 |
friend class ConstMapIt; |
| 56 | 56 |
|
| 57 | 57 |
public: |
| 58 | 58 |
|
| 59 | 59 |
MapExtender(const Graph& graph) |
| 60 | 60 |
: Parent(graph) {}
|
| 61 | 61 |
|
| 62 | 62 |
MapExtender(const Graph& graph, const Value& value) |
| 63 | 63 |
: Parent(graph, value) {}
|
| 64 | 64 |
|
| 65 |
private: |
|
| 65 | 66 |
MapExtender& operator=(const MapExtender& cmap) {
|
| 66 | 67 |
return operator=<MapExtender>(cmap); |
| 67 | 68 |
} |
| 68 | 69 |
|
| 69 | 70 |
template <typename CMap> |
| 70 | 71 |
MapExtender& operator=(const CMap& cmap) {
|
| 71 | 72 |
Parent::operator=(cmap); |
| 72 | 73 |
return *this; |
| 73 | 74 |
} |
| 74 | 75 |
|
| 76 |
public: |
|
| 75 | 77 |
class MapIt : public Item {
|
| 76 | 78 |
public: |
| 77 | 79 |
|
| 78 | 80 |
typedef Item Parent; |
| 79 | 81 |
typedef typename Map::Value Value; |
| 80 | 82 |
|
| 81 | 83 |
MapIt() {}
|
| 82 | 84 |
|
| 83 | 85 |
MapIt(Invalid i) : Parent(i) { }
|
| 84 | 86 |
|
| 85 | 87 |
explicit MapIt(Map& _map) : map(_map) {
|
| 86 | 88 |
map.notifier()->first(*this); |
| ... | ... |
@@ -191,38 +193,40 @@ |
| 191 | 193 |
|
| 192 | 194 |
friend class MapIt; |
| 193 | 195 |
friend class ConstMapIt; |
| 194 | 196 |
|
| 195 | 197 |
public: |
| 196 | 198 |
|
| 197 | 199 |
SubMapExtender(const Graph& _graph) |
| 198 | 200 |
: Parent(_graph), graph(_graph) {}
|
| 199 | 201 |
|
| 200 | 202 |
SubMapExtender(const Graph& _graph, const Value& _value) |
| 201 | 203 |
: Parent(_graph, _value), graph(_graph) {}
|
| 202 | 204 |
|
| 205 |
private: |
|
| 203 | 206 |
SubMapExtender& operator=(const SubMapExtender& cmap) {
|
| 204 | 207 |
return operator=<MapExtender>(cmap); |
| 205 | 208 |
} |
| 206 | 209 |
|
| 207 | 210 |
template <typename CMap> |
| 208 | 211 |
SubMapExtender& operator=(const CMap& cmap) {
|
| 209 | 212 |
checkConcept<concepts::ReadMap<Key, Value>, CMap>(); |
| 210 | 213 |
Item it; |
| 211 | 214 |
for (graph.first(it); it != INVALID; graph.next(it)) {
|
| 212 | 215 |
Parent::set(it, cmap[it]); |
| 213 | 216 |
} |
| 214 | 217 |
return *this; |
| 215 | 218 |
} |
| 216 | 219 |
|
| 220 |
public: |
|
| 217 | 221 |
class MapIt : public Item {
|
| 218 | 222 |
public: |
| 219 | 223 |
|
| 220 | 224 |
typedef Item Parent; |
| 221 | 225 |
typedef typename Map::Value Value; |
| 222 | 226 |
|
| 223 | 227 |
MapIt() {}
|
| 224 | 228 |
|
| 225 | 229 |
MapIt(Invalid i) : Parent(i) { }
|
| 226 | 230 |
|
| 227 | 231 |
explicit MapIt(Map& _map) : map(_map) {
|
| 228 | 232 |
map.graph.first(*this); |
| ... | ... |
@@ -91,24 +91,25 @@ |
| 91 | 91 |
container.resize(Parent::notifier()->maxId() + 1); |
| 92 | 92 |
} |
| 93 | 93 |
|
| 94 | 94 |
/// \brief Constructor uses given value to initialize the map. |
| 95 | 95 |
/// |
| 96 | 96 |
/// It constructs a map uses a given value to initialize the map. |
| 97 | 97 |
/// It adds all the items of the graph to the map. |
| 98 | 98 |
VectorMap(const Graph& graph, const Value& value) {
|
| 99 | 99 |
Parent::attach(graph.notifier(Item())); |
| 100 | 100 |
container.resize(Parent::notifier()->maxId() + 1, value); |
| 101 | 101 |
} |
| 102 | 102 |
|
| 103 |
private: |
|
| 103 | 104 |
/// \brief Copy constructor |
| 104 | 105 |
/// |
| 105 | 106 |
/// Copy constructor. |
| 106 | 107 |
VectorMap(const VectorMap& _copy) : Parent() {
|
| 107 | 108 |
if (_copy.attached()) {
|
| 108 | 109 |
Parent::attach(*_copy.notifier()); |
| 109 | 110 |
container = _copy.container; |
| 110 | 111 |
} |
| 111 | 112 |
} |
| 112 | 113 |
|
| 113 | 114 |
/// \brief Assign operator. |
| 114 | 115 |
/// |
| ... | ... |
@@ -425,46 +425,48 @@ |
| 425 | 425 |
/// |
| 426 | 426 |
/// ReadWrite map of the nodes to type \c T. |
| 427 | 427 |
/// \sa Reference |
| 428 | 428 |
template<class T> |
| 429 | 429 |
class NodeMap : public ReadWriteMap< Node, T > {
|
| 430 | 430 |
public: |
| 431 | 431 |
|
| 432 | 432 |
///\e |
| 433 | 433 |
NodeMap(const Digraph&) { }
|
| 434 | 434 |
///\e |
| 435 | 435 |
NodeMap(const Digraph&, T) { }
|
| 436 | 436 |
|
| 437 |
private: |
|
| 437 | 438 |
///Copy constructor |
| 438 | 439 |
NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
|
| 439 | 440 |
///Assignment operator |
| 440 | 441 |
template <typename CMap> |
| 441 | 442 |
NodeMap& operator=(const CMap&) {
|
| 442 | 443 |
checkConcept<ReadMap<Node, T>, CMap>(); |
| 443 | 444 |
return *this; |
| 444 | 445 |
} |
| 445 | 446 |
}; |
| 446 | 447 |
|
| 447 | 448 |
/// \brief Read write map of the arcs to type \c T. |
| 448 | 449 |
/// |
| 449 | 450 |
/// Reference map of the arcs to type \c T. |
| 450 | 451 |
/// \sa Reference |
| 451 | 452 |
template<class T> |
| 452 | 453 |
class ArcMap : public ReadWriteMap<Arc,T> {
|
| 453 | 454 |
public: |
| 454 | 455 |
|
| 455 | 456 |
///\e |
| 456 | 457 |
ArcMap(const Digraph&) { }
|
| 457 | 458 |
///\e |
| 458 | 459 |
ArcMap(const Digraph&, T) { }
|
| 460 |
private: |
|
| 459 | 461 |
///Copy constructor |
| 460 | 462 |
ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
|
| 461 | 463 |
///Assignment operator |
| 462 | 464 |
template <typename CMap> |
| 463 | 465 |
ArcMap& operator=(const CMap&) {
|
| 464 | 466 |
checkConcept<ReadMap<Arc, T>, CMap>(); |
| 465 | 467 |
return *this; |
| 466 | 468 |
} |
| 467 | 469 |
}; |
| 468 | 470 |
|
| 469 | 471 |
template <typename _Digraph> |
| 470 | 472 |
struct Constraints {
|
| ... | ... |
@@ -503,70 +503,73 @@ |
| 503 | 503 |
/// ReadWrite map of the nodes to type \c T. |
| 504 | 504 |
/// \sa Reference |
| 505 | 505 |
template<class T> |
| 506 | 506 |
class NodeMap : public ReadWriteMap< Node, T > |
| 507 | 507 |
{
|
| 508 | 508 |
public: |
| 509 | 509 |
|
| 510 | 510 |
///\e |
| 511 | 511 |
NodeMap(const Graph&) { }
|
| 512 | 512 |
///\e |
| 513 | 513 |
NodeMap(const Graph&, T) { }
|
| 514 | 514 |
|
| 515 |
private: |
|
| 515 | 516 |
///Copy constructor |
| 516 | 517 |
NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
|
| 517 | 518 |
///Assignment operator |
| 518 | 519 |
template <typename CMap> |
| 519 | 520 |
NodeMap& operator=(const CMap&) {
|
| 520 | 521 |
checkConcept<ReadMap<Node, T>, CMap>(); |
| 521 | 522 |
return *this; |
| 522 | 523 |
} |
| 523 | 524 |
}; |
| 524 | 525 |
|
| 525 | 526 |
/// \brief Read write map of the directed arcs to type \c T. |
| 526 | 527 |
/// |
| 527 | 528 |
/// Reference map of the directed arcs to type \c T. |
| 528 | 529 |
/// \sa Reference |
| 529 | 530 |
template<class T> |
| 530 | 531 |
class ArcMap : public ReadWriteMap<Arc,T> |
| 531 | 532 |
{
|
| 532 | 533 |
public: |
| 533 | 534 |
|
| 534 | 535 |
///\e |
| 535 | 536 |
ArcMap(const Graph&) { }
|
| 536 | 537 |
///\e |
| 537 | 538 |
ArcMap(const Graph&, T) { }
|
| 539 |
private: |
|
| 538 | 540 |
///Copy constructor |
| 539 | 541 |
ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
|
| 540 | 542 |
///Assignment operator |
| 541 | 543 |
template <typename CMap> |
| 542 | 544 |
ArcMap& operator=(const CMap&) {
|
| 543 | 545 |
checkConcept<ReadMap<Arc, T>, CMap>(); |
| 544 | 546 |
return *this; |
| 545 | 547 |
} |
| 546 | 548 |
}; |
| 547 | 549 |
|
| 548 | 550 |
/// Read write map of the edges to type \c T. |
| 549 | 551 |
|
| 550 | 552 |
/// Reference map of the arcs to type \c T. |
| 551 | 553 |
/// \sa Reference |
| 552 | 554 |
template<class T> |
| 553 | 555 |
class EdgeMap : public ReadWriteMap<Edge,T> |
| 554 | 556 |
{
|
| 555 | 557 |
public: |
| 556 | 558 |
|
| 557 | 559 |
///\e |
| 558 | 560 |
EdgeMap(const Graph&) { }
|
| 559 | 561 |
///\e |
| 560 | 562 |
EdgeMap(const Graph&, T) { }
|
| 563 |
private: |
|
| 561 | 564 |
///Copy constructor |
| 562 | 565 |
EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) {}
|
| 563 | 566 |
///Assignment operator |
| 564 | 567 |
template <typename CMap> |
| 565 | 568 |
EdgeMap& operator=(const CMap&) {
|
| 566 | 569 |
checkConcept<ReadMap<Edge, T>, CMap>(); |
| 567 | 570 |
return *this; |
| 568 | 571 |
} |
| 569 | 572 |
}; |
| 570 | 573 |
|
| 571 | 574 |
/// \brief Direct the given edge. |
| 572 | 575 |
/// |
| ... | ... |
@@ -996,56 +996,60 @@ |
| 996 | 996 |
typedef _Item Key; |
| 997 | 997 |
/// The value type of the map. |
| 998 | 998 |
typedef _Value Value; |
| 999 | 999 |
|
| 1000 | 1000 |
/// \brief Construct a new map. |
| 1001 | 1001 |
/// |
| 1002 | 1002 |
/// Construct a new map for the graph. |
| 1003 | 1003 |
explicit GraphMap(const Graph&) {}
|
| 1004 | 1004 |
/// \brief Construct a new map with default value. |
| 1005 | 1005 |
/// |
| 1006 | 1006 |
/// Construct a new map for the graph and initalise the values. |
| 1007 | 1007 |
GraphMap(const Graph&, const Value&) {}
|
| 1008 |
|
|
| 1009 |
private: |
|
| 1008 | 1010 |
/// \brief Copy constructor. |
| 1009 | 1011 |
/// |
| 1010 | 1012 |
/// Copy Constructor. |
| 1011 | 1013 |
GraphMap(const GraphMap&) : Parent() {}
|
| 1012 | 1014 |
|
| 1013 | 1015 |
/// \brief Assign operator. |
| 1014 | 1016 |
/// |
| 1015 | 1017 |
/// Assign operator. It does not mofify the underlying graph, |
| 1016 | 1018 |
/// it just iterates on the current item set and set the map |
| 1017 | 1019 |
/// with the value returned by the assigned map. |
| 1018 | 1020 |
template <typename CMap> |
| 1019 | 1021 |
GraphMap& operator=(const CMap&) {
|
| 1020 | 1022 |
checkConcept<ReadMap<Key, Value>, CMap>(); |
| 1021 | 1023 |
return *this; |
| 1022 | 1024 |
} |
| 1023 | 1025 |
|
| 1026 |
public: |
|
| 1024 | 1027 |
template<typename _Map> |
| 1025 | 1028 |
struct Constraints {
|
| 1026 | 1029 |
void constraints() {
|
| 1027 | 1030 |
checkConcept<ReadWriteMap<Key, Value>, _Map >(); |
| 1028 | 1031 |
// Construction with a graph parameter |
| 1029 | 1032 |
_Map a(g); |
| 1030 | 1033 |
// Constructor with a graph and a default value parameter |
| 1031 | 1034 |
_Map a2(g,t); |
| 1032 | 1035 |
// Copy constructor. |
| 1033 |
_Map b(c); |
|
| 1036 |
// _Map b(c); |
|
| 1034 | 1037 |
|
| 1035 |
ReadMap<Key, Value> cmap; |
|
| 1036 |
b = cmap; |
|
| 1038 |
// ReadMap<Key, Value> cmap; |
|
| 1039 |
// b = cmap; |
|
| 1037 | 1040 |
|
| 1041 |
ignore_unused_variable_warning(a); |
|
| 1038 | 1042 |
ignore_unused_variable_warning(a2); |
| 1039 |
ignore_unused_variable_warning(b); |
|
| 1043 |
// ignore_unused_variable_warning(b); |
|
| 1040 | 1044 |
} |
| 1041 | 1045 |
|
| 1042 | 1046 |
const _Map &c; |
| 1043 | 1047 |
const Graph &g; |
| 1044 | 1048 |
const typename GraphMap::Value &t; |
| 1045 | 1049 |
}; |
| 1046 | 1050 |
|
| 1047 | 1051 |
}; |
| 1048 | 1052 |
|
| 1049 | 1053 |
/// \brief An empty mappable digraph class. |
| 1050 | 1054 |
/// |
| 1051 | 1055 |
/// This class provides beside the core digraph features |
| ... | ... |
@@ -1073,24 +1077,25 @@ |
| 1073 | 1077 |
/// \brief Construct a new map. |
| 1074 | 1078 |
/// |
| 1075 | 1079 |
/// Construct a new map for the digraph. |
| 1076 | 1080 |
explicit NodeMap(const MappableDigraphComponent& digraph) |
| 1077 | 1081 |
: Parent(digraph) {}
|
| 1078 | 1082 |
|
| 1079 | 1083 |
/// \brief Construct a new map with default value. |
| 1080 | 1084 |
/// |
| 1081 | 1085 |
/// Construct a new map for the digraph and initalise the values. |
| 1082 | 1086 |
NodeMap(const MappableDigraphComponent& digraph, const _Value& value) |
| 1083 | 1087 |
: Parent(digraph, value) {}
|
| 1084 | 1088 |
|
| 1089 |
private: |
|
| 1085 | 1090 |
/// \brief Copy constructor. |
| 1086 | 1091 |
/// |
| 1087 | 1092 |
/// Copy Constructor. |
| 1088 | 1093 |
NodeMap(const NodeMap& nm) : Parent(nm) {}
|
| 1089 | 1094 |
|
| 1090 | 1095 |
/// \brief Assign operator. |
| 1091 | 1096 |
/// |
| 1092 | 1097 |
/// Assign operator. |
| 1093 | 1098 |
template <typename CMap> |
| 1094 | 1099 |
NodeMap& operator=(const CMap&) {
|
| 1095 | 1100 |
checkConcept<ReadMap<Node, _Value>, CMap>(); |
| 1096 | 1101 |
return *this; |
| ... | ... |
@@ -1110,24 +1115,25 @@ |
| 1110 | 1115 |
/// \brief Construct a new map. |
| 1111 | 1116 |
/// |
| 1112 | 1117 |
/// Construct a new map for the digraph. |
| 1113 | 1118 |
explicit ArcMap(const MappableDigraphComponent& digraph) |
| 1114 | 1119 |
: Parent(digraph) {}
|
| 1115 | 1120 |
|
| 1116 | 1121 |
/// \brief Construct a new map with default value. |
| 1117 | 1122 |
/// |
| 1118 | 1123 |
/// Construct a new map for the digraph and initalise the values. |
| 1119 | 1124 |
ArcMap(const MappableDigraphComponent& digraph, const _Value& value) |
| 1120 | 1125 |
: Parent(digraph, value) {}
|
| 1121 | 1126 |
|
| 1127 |
private: |
|
| 1122 | 1128 |
/// \brief Copy constructor. |
| 1123 | 1129 |
/// |
| 1124 | 1130 |
/// Copy Constructor. |
| 1125 | 1131 |
ArcMap(const ArcMap& nm) : Parent(nm) {}
|
| 1126 | 1132 |
|
| 1127 | 1133 |
/// \brief Assign operator. |
| 1128 | 1134 |
/// |
| 1129 | 1135 |
/// Assign operator. |
| 1130 | 1136 |
template <typename CMap> |
| 1131 | 1137 |
ArcMap& operator=(const CMap&) {
|
| 1132 | 1138 |
checkConcept<ReadMap<Arc, _Value>, CMap>(); |
| 1133 | 1139 |
return *this; |
| ... | ... |
@@ -1206,24 +1212,25 @@ |
| 1206 | 1212 |
/// \brief Construct a new map. |
| 1207 | 1213 |
/// |
| 1208 | 1214 |
/// Construct a new map for the graph. |
| 1209 | 1215 |
explicit EdgeMap(const MappableGraphComponent& graph) |
| 1210 | 1216 |
: Parent(graph) {}
|
| 1211 | 1217 |
|
| 1212 | 1218 |
/// \brief Construct a new map with default value. |
| 1213 | 1219 |
/// |
| 1214 | 1220 |
/// Construct a new map for the graph and initalise the values. |
| 1215 | 1221 |
EdgeMap(const MappableGraphComponent& graph, const _Value& value) |
| 1216 | 1222 |
: Parent(graph, value) {}
|
| 1217 | 1223 |
|
| 1224 |
private: |
|
| 1218 | 1225 |
/// \brief Copy constructor. |
| 1219 | 1226 |
/// |
| 1220 | 1227 |
/// Copy Constructor. |
| 1221 | 1228 |
EdgeMap(const EdgeMap& nm) : Parent(nm) {}
|
| 1222 | 1229 |
|
| 1223 | 1230 |
/// \brief Assign operator. |
| 1224 | 1231 |
/// |
| 1225 | 1232 |
/// Assign operator. |
| 1226 | 1233 |
template <typename CMap> |
| 1227 | 1234 |
EdgeMap& operator=(const CMap&) {
|
| 1228 | 1235 |
checkConcept<ReadMap<Edge, _Value>, CMap>(); |
| 1229 | 1236 |
return *this; |
| ... | ... |
@@ -38,63 +38,53 @@ |
| 38 | 38 |
//checking disabled asserts |
| 39 | 39 |
#define LEMON_DISABLE_ASSERTS |
| 40 | 40 |
#include <lemon/assert.h> |
| 41 | 41 |
|
| 42 | 42 |
void no_assertion_text_disable() {
|
| 43 | 43 |
LEMON_ASSERT(true, "This is a fault message"); |
| 44 | 44 |
} |
| 45 | 45 |
|
| 46 | 46 |
void assertion_text_disable() {
|
| 47 | 47 |
LEMON_ASSERT(false, "This is a fault message"); |
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 |
void fixme_disable() {
|
|
| 51 |
LEMON_FIXME("fixme_disable() is fixme!");
|
|
| 52 |
} |
|
| 53 |
|
|
| 54 | 50 |
void check_assertion_disable() {
|
| 55 | 51 |
no_assertion_text_disable(); |
| 56 | 52 |
assertion_text_disable(); |
| 57 |
fixme_disable(); |
|
| 58 | 53 |
} |
| 59 | 54 |
#undef LEMON_DISABLE_ASSERTS |
| 60 | 55 |
|
| 61 | 56 |
//checking custom assert handler |
| 62 | 57 |
#define LEMON_ASSERT_CUSTOM |
| 63 | 58 |
|
| 64 | 59 |
static int cnt = 0; |
| 65 | 60 |
void my_assert_handler(const char*, int, const char*, |
| 66 | 61 |
const char*, const char*) {
|
| 67 | 62 |
++cnt; |
| 68 | 63 |
} |
| 69 | 64 |
|
| 70 | 65 |
#define LEMON_CUSTOM_ASSERT_HANDLER my_assert_handler |
| 71 | 66 |
#include <lemon/assert.h> |
| 72 | 67 |
|
| 73 | 68 |
void no_assertion_text_custom() {
|
| 74 | 69 |
LEMON_ASSERT(true, "This is a fault message"); |
| 75 | 70 |
} |
| 76 | 71 |
|
| 77 | 72 |
void assertion_text_custom() {
|
| 78 | 73 |
LEMON_ASSERT(false, "This is a fault message"); |
| 79 | 74 |
} |
| 80 | 75 |
|
| 81 |
void fixme_custom() {
|
|
| 82 |
LEMON_FIXME("fixme_custom() is fixme!");
|
|
| 83 |
} |
|
| 84 |
|
|
| 85 | 76 |
void check_assertion_custom() {
|
| 86 | 77 |
no_assertion_text_custom(); |
| 87 | 78 |
assertion_text_custom(); |
| 88 |
fixme_custom(); |
|
| 89 |
check(cnt == 2, "The custom assert handler does not work"); |
|
| 79 |
check(cnt == 1, "The custom assert handler does not work"); |
|
| 90 | 80 |
} |
| 91 | 81 |
|
| 92 | 82 |
#undef LEMON_ASSERT_CUSTOM |
| 93 | 83 |
|
| 94 | 84 |
|
| 95 | 85 |
int main() {
|
| 96 | 86 |
check_assertion_disable(); |
| 97 | 87 |
check_assertion_custom(); |
| 98 | 88 |
|
| 99 | 89 |
return 0; |
| 100 | 90 |
} |
| ... | ... |
@@ -203,28 +203,28 @@ |
| 203 | 203 |
map[it] = 0; |
| 204 | 204 |
check(map[it] == 0, "Wrong operator[]."); |
| 205 | 205 |
map.set(it, s); |
| 206 | 206 |
check(map[it] == s, "Wrong set."); |
| 207 | 207 |
++s; |
| 208 | 208 |
} |
| 209 | 209 |
s = s * (s - 1) / 2; |
| 210 | 210 |
for (NodeIt it(G); it != INVALID; ++it) {
|
| 211 | 211 |
s -= map[it]; |
| 212 | 212 |
} |
| 213 | 213 |
check(s == 0, "Wrong sum."); |
| 214 | 214 |
|
| 215 |
map = constMap<Node>(12); |
|
| 216 |
for (NodeIt it(G); it != INVALID; ++it) {
|
|
| 217 |
check(map[it] == 12, "Wrong operator[]."); |
|
| 218 |
} |
|
| 215 |
// map = constMap<Node>(12); |
|
| 216 |
// for (NodeIt it(G); it != INVALID; ++it) {
|
|
| 217 |
// check(map[it] == 12, "Wrong operator[]."); |
|
| 218 |
// } |
|
| 219 | 219 |
} |
| 220 | 220 |
|
| 221 | 221 |
template <typename Graph> |
| 222 | 222 |
void checkGraphArcMap(const Graph& G) {
|
| 223 | 223 |
typedef typename Graph::Arc Arc; |
| 224 | 224 |
typedef typename Graph::ArcIt ArcIt; |
| 225 | 225 |
|
| 226 | 226 |
typedef typename Graph::template ArcMap<int> IntArcMap; |
| 227 | 227 |
IntArcMap map(G, 42); |
| 228 | 228 |
for (ArcIt it(G); it != INVALID; ++it) {
|
| 229 | 229 |
check(map[it] == 42, "Wrong map constructor."); |
| 230 | 230 |
} |
| ... | ... |
@@ -233,28 +233,28 @@ |
| 233 | 233 |
map[it] = 0; |
| 234 | 234 |
check(map[it] == 0, "Wrong operator[]."); |
| 235 | 235 |
map.set(it, s); |
| 236 | 236 |
check(map[it] == s, "Wrong set."); |
| 237 | 237 |
++s; |
| 238 | 238 |
} |
| 239 | 239 |
s = s * (s - 1) / 2; |
| 240 | 240 |
for (ArcIt it(G); it != INVALID; ++it) {
|
| 241 | 241 |
s -= map[it]; |
| 242 | 242 |
} |
| 243 | 243 |
check(s == 0, "Wrong sum."); |
| 244 | 244 |
|
| 245 |
map = constMap<Arc>(12); |
|
| 246 |
for (ArcIt it(G); it != INVALID; ++it) {
|
|
| 247 |
check(map[it] == 12, "Wrong operator[]."); |
|
| 248 |
} |
|
| 245 |
// map = constMap<Arc>(12); |
|
| 246 |
// for (ArcIt it(G); it != INVALID; ++it) {
|
|
| 247 |
// check(map[it] == 12, "Wrong operator[]."); |
|
| 248 |
// } |
|
| 249 | 249 |
} |
| 250 | 250 |
|
| 251 | 251 |
template <typename Graph> |
| 252 | 252 |
void checkGraphEdgeMap(const Graph& G) {
|
| 253 | 253 |
typedef typename Graph::Edge Edge; |
| 254 | 254 |
typedef typename Graph::EdgeIt EdgeIt; |
| 255 | 255 |
|
| 256 | 256 |
typedef typename Graph::template EdgeMap<int> IntEdgeMap; |
| 257 | 257 |
IntEdgeMap map(G, 42); |
| 258 | 258 |
for (EdgeIt it(G); it != INVALID; ++it) {
|
| 259 | 259 |
check(map[it] == 42, "Wrong map constructor."); |
| 260 | 260 |
} |
| ... | ... |
@@ -263,22 +263,22 @@ |
| 263 | 263 |
map[it] = 0; |
| 264 | 264 |
check(map[it] == 0, "Wrong operator[]."); |
| 265 | 265 |
map.set(it, s); |
| 266 | 266 |
check(map[it] == s, "Wrong set."); |
| 267 | 267 |
++s; |
| 268 | 268 |
} |
| 269 | 269 |
s = s * (s - 1) / 2; |
| 270 | 270 |
for (EdgeIt it(G); it != INVALID; ++it) {
|
| 271 | 271 |
s -= map[it]; |
| 272 | 272 |
} |
| 273 | 273 |
check(s == 0, "Wrong sum."); |
| 274 | 274 |
|
| 275 |
map = constMap<Edge>(12); |
|
| 276 |
for (EdgeIt it(G); it != INVALID; ++it) {
|
|
| 277 |
check(map[it] == 12, "Wrong operator[]."); |
|
| 278 |
} |
|
| 275 |
// map = constMap<Edge>(12); |
|
| 276 |
// for (EdgeIt it(G); it != INVALID; ++it) {
|
|
| 277 |
// check(map[it] == 12, "Wrong operator[]."); |
|
| 278 |
// } |
|
| 279 | 279 |
} |
| 280 | 280 |
|
| 281 | 281 |
|
| 282 | 282 |
} //namespace lemon |
| 283 | 283 |
|
| 284 | 284 |
#endif |
0 comments (0 inline)