diff options
author | Anas Nashif <anas.nashif@intel.com> | 2012-10-30 12:57:26 -0700 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2012-10-30 12:57:26 -0700 |
commit | 1a78a62555be32868418fe52f8e330c9d0f95d5a (patch) | |
tree | d3765a80e7d3b9640ec2e930743630cd6b9fce2b /libs/bimap | |
download | boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.gz boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.bz2 boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.zip |
Imported Upstream version 1.49.0upstream/1.49.0
Diffstat (limited to 'libs/bimap')
164 files changed, 31890 insertions, 0 deletions
diff --git a/libs/bimap/doc/acknowledgements.qbk b/libs/bimap/doc/acknowledgements.qbk new file mode 100644 index 0000000000..234b3be894 --- /dev/null +++ b/libs/bimap/doc/acknowledgements.qbk @@ -0,0 +1,66 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section Acknowledgements] + +This library was developed in the context of the Google SoC 2006. I +first want to thank my mentor, Joaquin, for his friendship during this +project. Not only did he help me go through the process of creating this +library, but he also did his best so we could have a great time doing +it. Also, Boost.Bimap would not exist had Boost.MultiIndex, Joaquin's +masterpiece, not existed. Thanks a lot! + +__GOOGLE_SOC_2006__ + +I want to thank Google for this amazing ['boost] to the open-source +community and to Boost mentors for trusting in my proposal in the first +place. Next on the list are my colleagues from SoC that helped me not +get bored during the long hours of coding. + +Special acknowledgements to the developers of the Boost libraries that +Boost.Bimap has abused. See the dependencies section for a complete list. + +I want to thank the open-source developers who wrote the tools I used +during this project. The list of names is infinitely long, so I +give a general huge thanks here. + +Thanks to Paul Giaccone for proof-reading this documentation. (He has +not finished yet -- the remaining typos and spelling errors are mine and +will be corrected as soon as possible.) + +Finally, thanks to my family, who had to see me at home all day during +the SoC. Special thanks to my brother Agustin, future famous novelist +(at the present time he is 19 years old), who patiently read every word +of these docs and while correcting them, barked at me for my bad written +English. I have learned a lot from his sermons. I want to thank my dog, +Mafalda, too for barking all day from my window and for being such a +good company. + +Thanks to Alisdair Meredith, Fernando Cacciola, Jeff Garland, John Maddock, +Thorsten Ottosen, Tony and Giovanni Piero Deretta for participating in +the formal review and give me useful advices to improve this library. +And thanks a lot to Ion Gaztañaga for managing the review. + +[heading Boost.Bimap Team] + +From Argentina... Matias and Mafalda and from Spain... Joaquin and Hector + +__MATIAS_PHOTO__ +__MAFALDA_PHOTO__ +__JOAQUIN_PHOTO__ +__HECTOR_PHOTO__ + +Luckily, the distance helps team members avoid eating each other. + +[endsect]
\ No newline at end of file diff --git a/libs/bimap/doc/bimap.hdf b/libs/bimap/doc/bimap.hdf new file mode 100644 index 0000000000..2ab400b9ba --- /dev/null +++ b/libs/bimap/doc/bimap.hdf @@ -0,0 +1,237 @@ +# Doxyfile 1.4.7 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = Boost.Bimap +PROJECT_NUMBER = +OUTPUT_DIRECTORY = html +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = YES +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = ../../../boost/bimap +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 4 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +BUILTIN_STL_SUPPORT = YES +DISTRIBUTE_GROUP_DOC = YES +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = NO +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = NO +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = YES +HIDE_UNDOC_CLASSES = YES +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = YES +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = YES +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = NO +GENERATE_TESTLIST = NO +GENERATE_BUGLIST = NO +GENERATE_DEPRECATEDLIST= NO +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = YES +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = NO +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = ../../../boost/bimap +FILE_PATTERNS = *.hpp +RECURSIVE = YES +EXCLUDE = ../../../boost/bimap/detail/test/check_metadata.hpp \ + ../../../boost/bimap/detail/test/check_size_of_pair.hpp +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = NO +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +REFERENCES_LINK_SOURCE = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 3 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = doxydoc +HTML_FILE_EXTENSION = .html +HTML_HEADER = style/doxyheader.html +HTML_FOOTER = style/doxyfooter.html +HTML_STYLESHEET = style/template/doxydoc/doxygen.css +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = YES +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = NO +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES \ + BOOST_BIMAP_ONLY_DOXYGEN_WILL_PROCESS_THE_FOLLOWING_LINES +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = NO +HAVE_DOT = YES +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = YES +TEMPLATE_RELATIONS = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = YES +CALLER_GRAPH = YES +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 2046 +MAX_DOT_GRAPH_DEPTH = 1000 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = YES +GENERATE_LEGEND = NO +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/libs/bimap/doc/bimap.qbk b/libs/bimap/doc/bimap.qbk new file mode 100644 index 0000000000..6fb29437af --- /dev/null +++ b/libs/bimap/doc/bimap.qbk @@ -0,0 +1,165 @@ +[library Boost.Bimap + [quickbook 1.4] + [authors [Capeletto, Matias]] + [copyright 2006-2007 Matias Capeletto] + [category container] + [id bimap] + [dirname bimap] + [purpose + Bidirectional map + ] + [source-mode c++] + [license +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +[@http://www.boost.org/LICENSE_1_0.txt]) + ] +] + +[/ QuickBook Document version 1.4 ] + +[/ Logos ] + +[def __BOOST_BIMAP_LOGO__ [$images/bimap/boost.bimap.logo.png]] +[def __GOOGLE_SOC_2006__ [$images/extern/googlesoc.png]] + +[/ Helpers ] + +[def __MI_FRAMEWORK__ [$images/bimap/miBimapFramework.png]] +[def __SIMPLE_BIMAP__ [$images/bimap/simple.bimap.png]] +[def __STANDARD_MAPPING_FRAMEWORK__ [$images/bimap/standard.mapping.framework.png]] +[def __EXTENDED_MAPPING_FRAMEWORK__ [$images/bimap/extended.mapping.framework.png]] +[def __RELATION__ [$images/bimap/relation.png]] +[def __STD_PAIR__ [$images/bimap/std_pair.png]] +[def __COLLECTION_TYPE_OF_RELATION__ [$images/bimap/collection.type.of.relation.png]] +[def __BIMAP_STRUCTURES__ [$images/bimap/bimap.structures.png]] +[def __TAGGED__ [$images/bimap/tagged.png]] +[def __MORE_BIMAP_STRUCTURES__ [$images/bimap/more.bimap.structures.png]] +[def __RELATION_AND_PAIR__ [$images/bimap/relation.and.pair.png]] +[def __RELATION_AND_PAIR_WITH_INFO__ [$images/bimap/relation.and.pair.with.info.png]] + + +[/ People ] + +[def __MATIAS_PHOTO__ [$images/people/matias.png]] +[def __JOAQUIN_PHOTO__ [$images/people/joaquin.png]] +[def __MAFALDA_PHOTO__ [$images/people/mafalda.png]] +[def __HECTOR_PHOTO__ [$images/people/hector.png]] + +[/ Icons ] + +[def __NOTE__ [$images/note.png]] +[def __ALERT__ [$images/caution.png]] +[def __DETAIL__ [$images/note.png]] +[def __TIP__ [$images/tip.png]] +[def __QUESTION_MARK__ [$images/question.png]] + + +[/ Boost Libraries ] + +[def __BOOST_MULTI_INDEX__ [@http://www.boost.org/libs/multi_index/doc/index.html [*Boost.MultiIndex]]] +[def __BOOST_MPL__ [@http://www.boost.org/libs/mpl/doc/index.html [*Boost.MPL]]] +[def __BOOST_TYPE_TRAITS__ [@http://www.boost.org/doc/html/boost_typetraits.html [*Boost.TypeTraits]]] +[def __BOOST_ENABLE_IF__ [@http://www.boost.org/libs/utility/enable_if.html [*Boost.enable_if]]] +[def __BOOST_ITERATORS__ [@http://www.boost.org/libs/iterator/doc/index.html [*Boost.Iterators]]] +[def __BOOST_CALL_TRAITS__ [@http://www.boost.org/libs/utility/call_traits.htm [*Boost.call_traits]]] +[def __BOOST_STATIC_ASSERT__ [@http://www.boost.org/doc/html/boost_staticassert.html [*Boost.StaticAssert]]] + +[def __BOOST_SERIALIZATION__ [@http://www.boost.org/libs/serialization/doc/index.html [*Boost.Serialization]]] +[def __BOOST_HASH__ [@http://www.boost.org/doc/html/hash.html [*Boost.Hash]]] +[def __BOOST_ASSIGN__ [@http://www.boost.org/libs/assign/doc/index.html [*Boost.Assign]]] +[def __BOOST_LAMBDA__ [@http://www.boost.org/doc/html/lambda.html [*Boost.Lambda]]] +[def __BOOST_PROPERTY_MAP__ [@http://www.boost.org/doc/html/property_map.html [*Boost.PropertyMap]]] +[def __BOOST_RANGE__ [@http://www.boost.org/doc/html/range.html [*Boost.Range]]] +[def __BOOST_FOREACH__ [@http://www.boost.org/doc/html/foreach.html [*Boost.Foreach]]] +[def __BOOST_TEST__ [@http://www.boost.org/libs/test/doc/index.html [*Boost.Test]]] +[def __BOOST_TYPEOF__ [@http://www.boost.org/libs/typeof/doc/index.html [*Boost.Typeof]]] +[def __BOOST_XPRESSIVE__ [@http://www.boost.org/libs/xpressive/doc/index.html [*Boost.Xpressive]]] + + +[/ Extern Links ] + +[def __CPP_STANDARD_LIBRARY_TECHNICAL_REPORT__ [@http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1836.pdf C++ Standard Library Technical Report]] +[def __CPP_DEFECT_REPORT_130__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#130 Defect Report 130]] +[def __TR1_ISSUES_LIST__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1837.pdf Issues List]] + +[def __BOOST_HASH_FUNCTION__ [@http://www.boost.org/regression-logs/cs-win32_metacomm/doc/html/hash.html boost::hash]] + +[def __BOOST_PERMUTATION_ITERATOR__ [@http://www.boost.org/libs/iterator/doc/permutation_iterator.html `permutation_iterator`]] + +[def __BOOST_ASSERT_MACRO__ [@where_it_is `BOOST_ASSERT`]] +[def __BOOST_MPL_FORWARD_SEQUENCE__ [@http://www.boost.org/libs/mpl/doc/refmanual/forward-sequence.html MPL Forward Sequence]] +[def __BOOST_MPL_RANDOM_ACCESS_SEQUENCE__ [@http://www.boost.org/libs/mpl/doc/refmanual/random-access-sequence.html MPL Random Access Sequence]] +[def __BOOST_MPL_EXTENSIBLE_SEQUENCE__ [@http://www.boost.org/libs/mpl/doc/refmanual/extensible-sequence.html MPL Extensible Sequence]] + +[def __SGI_UNARY_FUNCTION__ [@http://www.sgi.com/tech/stl/UnaryFunction.html Unary Function]] +[def __SGI_BINARY_FUNCTION__ [@http://www.sgi.com/tech/stl/BinaryFunction.html Binary Function]] + +[def __SGI_ASSIGNABLE__ [@http://www.sgi.com/tech/stl/Assignable.html Assignable]] +[def __SGI_DEFAULT_CONSTRUCTIBLE__ [@http://www.sgi.com/tech/stl/DefaultConstructible.html Default Constructible]] +[def __SGI_BINARY_PREDICATE__ [@http://www.sgi.com/tech/stl/BinaryPredicate.html Binary Predicate]] +[def __SGI_CONTAINER__ [@http://www.sgi.com/tech/stl/Container.html Container]] +[def __SGI_SORTED_ASSOCIATIVE_CONTAINER__ [@http://www.sgi.com/tech/stl/SortedAssociativeContainer.html Sorted Associative Container]] +[def __SGI_UNIQUE_ASSOCIATIVE_CONTAINER__ [@http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html Unique Associative Container]] +[def __SGI_REVERSIBLE_CONTAINER__ [@http://www.sgi.com/tech/stl/ReversibleContainer.html Reversible Container]] +[def __SGI_RANDOM_ACCESS_CONTAINER__ [@http://www.sgi.com/tech/stl/RandomAccessContainer.html Random Access Container]] +[def __SGI_FRONT_INSERTION_SEQUENCE__ [@http://www.sgi.com/tech/stl/FrontInsertionSequence.html Front Insertion Sequence]] +[def __SGI_BACK_INSERTION_SEQUENCE__ [@http://www.sgi.com/tech/stl/BackInsertionSequence.html Back Insertion Sequence]] +[def __SGI_INPUT_ITERATOR__ [@http://www.sgi.com/tech/stl/InputIterator.html Input Iterator]] +[def __SGI_FORWARD_ITERATOR__ [@http://www.sgi.com/tech/stl/ForwardIterator.html Forward Iterator]] +[def __SGI_STRICT_WEAK_ORDERING__ [@http://www.sgi.com/tech/stl/StrictWeakOrdering.html Strict Weak Ordering]] + +[def __EIFFEL__ [@http://www.eiffel.com/ Eiffel]] +[def __SAFE_STL__ [@http://www.horstmann.com/safestl.html Safe STL]] +[def __STL_PORT_DEBUG_MODE__ [@http://www.stlport.com/doc/debug_mode.html STLport Debug Mode]] + +[def __CGAL__ [@http://www.cgal.org/ CGAL]] +[def __MYSQLPP__ [@http://tangentsoft.net/mysql++/ MySQL++]] + + +[def __STL_TREE_H__ [@http://www.sgi.com/tech/stl/stl_tree.h stl_tree.h]] +[def __ORDER_STATISTICS_TREE__ [@http://pine.cs.yale.edu/pinewiki/OrderStatisticsTree ['order-statistics trees]]] + +[def __GENERIC_PROGRAMMING_MOVE_CONSTRUCTORS__ [@http://www.ddj.com/dept/cpp/184403855 "Generic<Programming>: Move Constructors]] +[def __CLARIFICATION_OF_INITIALIZATION__ [@http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2004/n1610.html "Clarification of Initialization of Class Objects by rvalues"]] + + +[/ Code snippets ] + +[import ../example/simple_bimap.cpp] +[import ../example/mighty_bimap.cpp] + +[section Preface] + +[heading Description] + +__BOOST_BIMAP_LOGO__ + +Boost.Bimap is a bidirectional maps library for C++. With Boost.Bimap you can create associative containers in which both types can be used as key. A `bimap<X,Y>` +can be thought of as a combination of a `std::map<X,Y>` and a `std::map<Y,X>`. +The learning curve of bimap is almost flat if you know how to use standard +containers. A great deal of effort has been put into mapping the naming scheme of the +STL in Boost.Bimap. The library is designed to match the common STL containers. + +[heading Influences and Related Work] + +The design of Boost.Bimap interface follows the standard template library. +It has been strongly influenced by Joaquin Lopez Muñoz's Boost.MultiIndex library +(the heart of bimaps) and codeproject::bimap library. + +[endsect] + +[include introduction.qbk] +[include quick_tutorial.qbk] +[include tutorial.qbk] +[include bimap_and_boost.qbk] +[include reference.qbk] +[include compiler_specifics.qbk] +[include performance.qbk] +[include examples.qbk] +[include test_suite.qbk] +[include future_work.qbk] +[include release_notes.qbk] +[include rationale.qbk] +[include history.qbk] +[include acknowledgements.qbk] diff --git a/libs/bimap/doc/bimap_and_boost.qbk b/libs/bimap/doc/bimap_and_boost.qbk new file mode 100644 index 0000000000..d6d8929c41 --- /dev/null +++ b/libs/bimap/doc/bimap_and_boost.qbk @@ -0,0 +1,477 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section Bimap and Boost] + +[section Bimap and MultiIndex] + +['MISC] - [*M]ulti-[*I]ndex [*S]pecialized [*C]ontainers + +[:[' +Let's be generic, construct frameworks, describe the world in an +unified way... +]] +[:[' +No!, it is better to be specialized, design easy-to-use components, +offer plug-and-play objects... +]] +[:[* +Why not take advantage of the best of both worlds? +]] + +__MI_FRAMEWORK__ + +With Boost.Bimap, you can build associative containers in which both +types can be used as key. There is a library in Boost that already +allows the creation of this kind of container: Boost.MultiIndex. It +offers great flexibility and lets you construct almost any container +that you could dream of. The framework is very clean. You migh want to +read this library's tutorial to learn about the power that has been +achieved. + + +But generality comes at a price: the interface that results might not be +the best for every specialization. People may end up wrapping a B.MI +container in its own class every time they want to use it as a +bidirectional map. Boost.Bimap takes advantage of the narrower scope to +produce a better interface for bidirectional maps +[footnote In the same fashion, Boost.MRU will allow the creation of ['most +recent updated] aware containers, hiding the complexity of Boost.MultiIndex.]. +There is no learning curve if you know how to use standard containers. +Great effort was put into mapping the naming scheme of the STL to Boost.Bimap. +The library is designed to match the common STL containers. + +Boost.MultiIndex is, in fact, the core of the bimap container. + +However, Boost.Bimap do not aim to tackle every problem with two indexed +types. There exist some problems that are better modelled with Boost.MultiIndex. + + +[blurb + +[*Problem I - An employee register] + +['Store an ID and a name for an employee, with fast search on each member.] + +This type of problem is better modelled as a database table, and +[*Boost.MultiIndex] is the preferred choice. It is possible that other data +will need to be indexed later. + +] + +[blurb + +[*Problem II - A partners container] + +['Store the names of couples and be able to get the name of a person's +partner.] + +This problem is better modelled as a collection of relations, and [*Boost.Bimap] +fits nicely here. + +] + +You can also read +[link boost_bimap.the_tutorial.additional_information Additional Information] for more +information about the relation of this two libraries. + +[endsect] + +[section Boost Libraries that work well with Boost.Bimap] + +[section Introduction] + +[table +[[Name][Description][author][Purpose]] + +[[ __BOOST_SERIALIZATION__ ][ +Serialization for persistence and marshalling] +[Robert Ramey] +[Serialization support for bimap containers and iterators]] + +[[ __BOOST_ASSIGN__ ][ +Filling containers with constant or generated data has never been easier] +[Thorsten Ottosen] +[Help to fill a bimap or views of it]] + +[[ __BOOST_HASH__ ][ +A TR1 hash function object that can be extended to hash user defined types] +[Daniel James] +[Default hashing function]] + +[[ __BOOST_LAMBDA__ ][ +Define small unnamed function objects at the actual call site, and more] +[from Jaakko Järvi, Gary Powell] +[Functors for modify, range, lower_bound and upper_bound]] + +[[ __BOOST_RANGE__ ][ +A new infrastructure for generic algorithms that builds on top of the new +iterator concepts] +[Thorsten Ottosen] +[Range based algorithms]] + +[[ __BOOST_FOREACH__ ][ +BOOST_FOREACH macro for easily iterating over the elements of a sequence] +[Eric Niebler] +[Iteration]] + +[[ __BOOST_TYPEOF__ ][ +Typeof operator emulation] +[Arkadiy Vertleyb, Peder Holt] +[Using BOOST_AUTO while we wait for C++0x]] + +[[ __BOOST_XPRESSIVE__ ][ +Regular expressions that can be written as strings or as expression templates] +[Eric Niebler] +[Help to fill a bimap from a string]] + +[[ __BOOST_PROPERTY_MAP__ ][ +Concepts defining interfaces which map key objects to value objects] +[Jeremy Siek] +[Integration with BGL]] +] + +[endsect] + +[section Boost.Serialization] + +A bimap can be archived and retrieved by means of the Boost.Serialization Library. +Both regular and XML archives are supported. The usage is straightforward and does +not differ from that of any other serializable type. For instance: + +[import ../example/bimap_and_boost/serialization.cpp] + +[@../../example/bimap_and_boost/serialization.cpp Go to source code] + +[code_bimap_and_boost_serialization] + +Serialization capabilities are automatically provided by just linking with the +appropriate Boost.Serialization library module: it is not necessary to explicitly +include any header from Boost.Serialization, apart from those declaring the type +of archive used in the process. If not used, however, serialization support can +be disabled by globally defining the macro BOOST_BIMAP_DISABLE_SERIALIZATION. +Disabling serialization for Boost.MultiIndex can yield a small improvement in +build times, and may be necessary in those defective compilers that fail to +correctly process Boost.Serialization headers. + +[warning Boost.Bimap and Boost.MultiIndex share a lot of serialization code. +The macro `BOOST_BIMAP_DISABLE_SERIALIZATION` disables serialization in *both* +libraries. The same happens when `BOOST_MULTI_INDEX_DISABLE_SERIALIZATION` is +defined. +] + +Retrieving an archived bimap restores not only the elements, but also the order +they were arranged in the views of the container. There is an exception to this rule, +though: for unordered sets, no guarantee is made about the order in which elements +will be iterated in the restored container; in general, it is unwise to rely on +the ordering of elements of a hashed view, since it can change in arbitrary ways +during insertion or rehashing --this is precisely the reason why hashed indices +and TR1 unordered associative containers do not define an equality operator. + +Iterators of a bimap can also be serialized. Serialization of an +iterator must be done only after serializing its corresponding container. + +[endsect] + +[section Boost.Assign] + +The purpose of this library is to make it easy to fill containers with data by +overloading operator,() and operator()(). These two operators make it possible +to construct lists of values that are then copied into a container. + +These lists are particularly useful in learning, testing, and prototyping +situations, but can also be handy otherwise. The library comes with predefined +operators for the containers of the standard library, but most functionality will +work with any standard compliant container. The library also makes it possible +to extend user defined types so for example a member function can be called for +a list of values instead of its normal arguments. + +Boost.Assign can be used with bimap containers. +The views of a bimap are signature-compatible with their standard +counterparts, so we can use other Boost.Assign utilities with them. + +[import ../example/bimap_and_boost/assign.cpp] + +[@../../example/bimap_and_boost/assign.cpp Go to source code] + +[code_bimap_and_boost_assign] + +[endsect] + +[section Boost.Hash] + +The hash function is the very core of the fast lookup capabilities of the +unordered sets: a hasher is just a Unary Function returning an std::size_t value +for any given key. In general, it is impossible that every key map to a +different hash value, for the space of keys can be greater than the number of permissible hash codes: what makes for a good hasher is that the probability of a collision (two different keys with the same hash value) is as close to zero as possible. + +This is a statistical property depending on the typical distribution of keys in a given application, so it is not feasible to have a general-purpose hash function with excellent results in every possible scenario; the default value for this parameter uses Boost.Hash, which often provides good enough results. + +Boost.Hash can be +[@http://www.boost.org/doc/html/hash/custom.html +extended for custom data types], +enabling to use the default parameter of the unordered set types with any user types. + +[endsect] + +[section Boost.Lambda] + +The Boost Lambda Library (BLL in the sequel) is a C++ template library, which implements +form of lambda abstractions for C++. The term originates from functional programming and +lambda calculus, where a lambda abstraction defines an unnamed function. +Lambda expressions are very useful to construct the function objects required by some of +the functions in a bimap view. + +Boost.Bimap defines new placeholders in `<boost/bimap/support/lambda.hpp>` +to allow a sounder solution. The placeholders are named _key and _data and both +are equivalent to boost::lambda::_1. There are two reasons to include this placeholders: +the code looks better with them and they avoid the clash problem between lambda::_1 and +boost::_1 from Boost.Bind. + +[import ../example/bimap_and_boost/lambda.cpp] + +[@../../example/bimap_and_boost/lambda.cpp Go to source code] + +[code_bimap_and_boost_lambda] + +[endsect] + +[section Boost.Range] + +Boost.Range is a collection of concepts and utilities that are particularly useful +for specifying and implementing generic algorithms. +Generic algorithms have so far been specified in terms of two or more iterators. +Two iterators would together form a range of values that the algorithm could +work on. This leads to a very general interface, but also to a somewhat clumsy +use of the algorithms with redundant specification of container names. Therefore +we would like to raise the abstraction level for algorithms so they specify their +interface in terms of Ranges as much as possible. + +As Boost.Bimap views are signature-compatible with their standard +container counterparts, they are compatible with the concept of a range. +As an additional feature, ordered bimap views offer a function named +`range` that allows a range of values to be obtained. + +[import ../example/bimap_and_boost/range.cpp] + +If we have some generic functions that accepts ranges: + +[code_bimap_and_boost_range_functions] + +We can use them with Boost.Bimap with the help of the `range` function. + +[code_bimap_and_boost_range] + +[@../../example/bimap_and_boost/range.cpp Go to source code] + +[endsect] + +[section Boost.Foreach] + +In C++, writing a loop that iterates over a sequence is tedious. +We can either use iterators, which requires a considerable amount of +boiler-plate, or we can use the std::for_each() algorithm and move our +loop body into a predicate, which requires no less boiler-plate and forces +us to move our logic far from where it will be used. In contrast, some other +languages, like Perl, provide a dedicated "foreach" construct that automates +this process. BOOST_FOREACH is just such a construct for C++. It iterates +over sequences for us, freeing us from having to deal directly with iterators +or write predicates. + +You can use BOOST_FOREACH macro with Boost.Bimap views. The generated code will +be as efficient as a std::for_each iteration. +Here are some examples: + +[import ../example/bimap_and_boost/foreach.cpp] + +[code_bimap_and_boost_foreach] + +You can use it directly with ranges too: + +[code_bimap_and_boost_foreach_using_range] + +[@../../example/bimap_and_boost/foreach.cpp Go to source code] + +[endsect] + +[section Boost.Typeof] + +[import ../example/bimap_and_boost/typeof.cpp] + +Once C++0x is out we are going to be able to write code like: + + auto iter = bm.by<name>().find("john"); + +instead of the more verbose + + bm_type::map_by<name>::iterator iter = bm.by<name>().find("john"); + +Boost.Typeof defines a macro BOOST_AUTO that can be used as a library +solution to the auto keyword while we wait for the next standard. + +If we have + +[code_bimap_and_boost_typeof_first] + +The following code snippet + +[code_bimap_and_boost_typeof_not_using_auto] + +can be rewrited as + +[code_bimap_and_boost_typeof_using_auto] + +[@../../example/bimap_and_boost/typeof.cpp Go to source code] + +[endsect] + +[section Boost.Xpressive] + +[import ../example/bimap_and_boost/xpressive.cpp] + +Using Boost.Xpressive we can parse a file and insert the relations in a bimap +in the same step. It is just amazing the power of four lines of code. +Here is an example (it is just beatifull) + +[code_bimap_and_boost_xpressive] + +[@../../example/bimap_and_boost/xpressive.cpp Go to source code] + +[endsect] + +[section Boost.Property_map] + +The Boost Property Map Library consists mainly of interface specifications in the form of +concepts (similar to the iterator concepts in the STL). These interface specifications +are intended for use by implementers of generic libraries in communicating requirements on +template parameters to their users. In particular, the Boost Property Map concepts define a +general purpose interface for mapping key objects to corresponding value objects, thereby +hiding the details of how the mapping is implemented from algorithms. + +The need for the property map interface came from the Boost Graph Library (BGL), which +contains many examples of algorithms that use the property map concepts to specify their +interface. For an example, note the ColorMap template parameter of the breadth_first_search. +In addition, the BGL contains many examples of concrete types that implement the property map +interface. The adjacency_list class implements property maps for accessing objects +(properties) that are attached to vertices and edges of the graph. + +The counterparts of two of the views of Boost.Bimap map, the `set` and +`unordered_set`, are read-write property maps. In order to use these, you +need to include one of the following headers: + + #include <boost/bimap/property_map/set_support.hpp> + #include <boost/bimap/property_map/unordered_set_support.hpp> + +The following is adapted from the example in the Boost.PropertyMap +documentation. + +[import ../example/bimap_and_boost/property_map.cpp] + +[@../../example/bimap_and_boost/property_map.cpp Go to source code] + +[code_bimap_and_boost_property_map] + +[endsect] + +[endsect] + +[section Dependencies] + +Boost.Bimap is built on top of several Boost libraries. The rationale +behind this decision is keeping the Boost code base small by reusing +existent code. The libraries used are well-established and have been +tested extensively, making this library easy to port since all the hard +work has already been done. The glue that holds everything together is +Boost.MPL. Clearly Boost.MultiIndex is the heart of this library. + +[table Boost Libraries needed by Boost.Bimap +[[Name][Description][author]] + +[[ __BOOST_MULTI_INDEX__ ][ +Containers with multiple STL-compatible access interfaces] +[JoaquÃn M López Muñoz]] + +[[ __BOOST_MPL__ ][ +Template metaprogramming framework of compile-time algorithms, sequences and metafunction classes] +[Aleksey Gurtovoy]] + +[[ __BOOST_TYPE_TRAITS__ ][ +Templates for fundamental properties of types.] +[John Maddock, Steve Cleary]] + +[[ __BOOST_ENABLE_IF__ ][ +Selective inclusion of function template overloads] +[Jaakko Järvi, Jeremiah Willcock, Andrew Lumsdaine]] + +[[ __BOOST_ITERATORS__ ][ +Iterator construction framework, adaptors, concepts, and more.] +[Dave Abrahams, Jeremy Siek, Thomas Witt]] + +[[ __BOOST_CALL_TRAITS__ ][ +Defines types for passing parameters.] +[John Maddock, Howard Hinnant]] + +[[ __BOOST_STATIC_ASSERT__ ][ +Static assertions (compile time assertions).] +[John Maddock]] + +] + +[table Optional Boost Libraries +[[Name][Description][author][Purpose]] + +[[ __BOOST_SERIALIZATION__ ][ +Serialization for persistence and marshalling] +[Robert Ramey] +[Serialization support for bimap containers and iterators]] + +[[ __BOOST_ASSIGN__ ][ +Filling containers with constant or generated data has never been easier] +[Thorsten Ottosen] +[Help to fill a bimap or views of it]] + +[[ __BOOST_HASH__ ][ +A TR1 hash function object that can be extended to hash user defined types] +[Daniel James] +[Default hashing function]] + +[[ __BOOST_LAMBDA__ ][ +Define small unnamed function objects at the actual call site, and more] +[from Jaakko Järvi, Gary Powell] +[Functors for modify, range, lower_bound and upper_bound]] + +[[ __BOOST_RANGE__ ][ +A new infrastructure for generic algorithms that builds on top of the new +iterator concepts] +[Thorsten Ottosen] +[Range based algorithms]] + +[[ __BOOST_PROPERTY_MAP__ ][ +Concepts defining interfaces which map key objects to value objects] +[Jeremy Siek] +[Integration with BGL]] +] + +[table Additional Boost Libraries needed to run the test-suite +[[Name][Description][author]] + +[[ __BOOST_TEST__ ][ +Support for simple program testing, full unit testing, and for program execution monitoring.] +[Gennadiy Rozental] +] +] + +[endsect] + +[endsect] diff --git a/libs/bimap/doc/compiler_specifics.qbk b/libs/bimap/doc/compiler_specifics.qbk new file mode 100644 index 0000000000..55dfda0393 --- /dev/null +++ b/libs/bimap/doc/compiler_specifics.qbk @@ -0,0 +1,61 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section Compiler specifics] + +[table +[[Compiler ][OS Tested ][State ]] +[[GCC 3.3 ][Linux ][Supported ]] +[[GCC 3.4 ][Linux ][Supported ]] +[[GCC 4.0 ][Linux, Mac][Supported ]] +[[GCC 4.1 ][Linux ][Supported ]] +[[GCC 4.2 ][Linux ][Supported ]] +[[ICC 8.0 ][Linux ][Supported ]] +[[ICC 9.0 ][Linux ][Supported ]] +[[ICC 9.1 ][Linux ][Supported ]] +[[GCC 4.2 ][Linux ][Supported ]] +[[GCC 4.2 ][Linux ][Supported ]] +[[VS 7.1 ][Windows ][Supported ]] +[[VS 8.0 ][Windows ][Supported ]] +[[ICC 7.1 ][Windows ][Not Supported ]] +[[ICC 8.0 ][Windows ][Supported ]] +[[ICC 9.1 ][Windows ][Supported ]] +[[CW 8.3 ][Windows ][Not Supported ]] +] + +[/ +[[Comeau C++][ ][Not yet tested (Will be supported) ]] +[[CW 8.3 ][Windows ][On going effort to support it ]] +] + +[h2 VS 7.1] + +If a .cpp file uses more than four differents bimaps the compiler will run +out of symbols and issue an internal compiler error. The official solution +in msdn is to split the .cpp in several files or upgrade your compiler. + +[h2 VS 8.0] + +VC++ 8.0 warns on usage of certain Standard Library and API functions that +can be cause buffer overruns or other possible security issues if misused. +See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +But the wording of the warning is misleading and unsettling, there are no +portable alternative functions, and VC++ 8.0's own libraries use the +functions in question. In order to turn off the warnings add the followings +defines at the begging of your .cpp files: + + #define _CRT_SECURE_NO_DEPRECATE + #define _SCL_SECURE_NO_DEPRECATE + +[endsect]
\ No newline at end of file diff --git a/libs/bimap/doc/directdoxygen.jam b/libs/bimap/doc/directdoxygen.jam new file mode 100644 index 0000000000..d36603d5ad --- /dev/null +++ b/libs/bimap/doc/directdoxygen.jam @@ -0,0 +1,22 @@ +# Boost.Bimap +# +# Copyright (c) 2006-2007 Matias Capeletto +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + + +import type ; +import generators ; + +type.register HTML_DOXYFILE : hdf ; +type.register HTML_DOXYDOCS : hdt ; + +generators.register-standard directdoxygen.run : HTML_DOXYFILE : HTML_DOXYDOCS ; + +actions run +{ + "doxygen" $(>) + echo "Stamped" > "$(<)" +} diff --git a/libs/bimap/doc/examples.qbk b/libs/bimap/doc/examples.qbk new file mode 100644 index 0000000000..5f05e2d7de --- /dev/null +++ b/libs/bimap/doc/examples.qbk @@ -0,0 +1,236 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section Examples] + +[section Examples list] + +In the folder [@../../example libs/bimap/example] you can find all the examples +used in bimap documentation. Here is a list of them: + + +[table Tutorial examples +[[Program ][Description ]] + +[[[@../../example/simple_bimap.cpp + simple_bimap.cpp ]] + [Soccer world cup example ]] + +[[[@../../example/tagged_simple_bimap.cpp + tagged_simple_bimap.cpp ]] + [Soccer world cup example using user defined names ]] + +[[[@../../example/step_by_step.cpp + step_by_step.cpp ]] + [Basic example of the three views of bimap ]] + +[[[@../../example/population_bimap.cpp + population_bimap.cpp ]] + [Countries populations, using `unordered_set_of` and `multiset_of` ]] + +[[[@../../example/repetitions_counter.cpp + repetitions_counter.cpp ]] + [Word repetitions counter, using `unordered_set_of` and `list_of` ]] + +[[[@../../example/mighty_bimap.cpp + mighty_bimap.cpp ]] + [Dictionary using `list_of_relation` ]] + +[[[@../../example/user_defined_names.cpp + user_defined_names.cpp ]] + [Equivalence between code with tagged and untagged code ]] + +[[[@../../example/standard_map_comparison.cpp + standard_map_comparison.cpp ]] + [Comparison between standard maps and bimap map views ]] + +[[[@../../example/at_function_examples.cpp + at_function_examples.cpp ]] + [Functions `at(key)` and `operator[](key)` examples ]] + +[[[@../../example/tutorial_modify_and_replace.cpp + tutorial_modify_and_replace.cpp ]] + [`modify` and `replace` examples ]] + +[[[@../../example/tutorial_range.cpp + tutorial_range.cpp ]] + [`range()` tutorial ]] + +[[[@../../example/tutorial_info_hook.cpp + tutorial_info_hook.cpp ]] + [Additional information hooking ]] + +[[[@../../example/unconstrained_collection.cpp + unconstrained_collection.cpp ]] + [Using `unconstrained_set_of` collection type ]] +] + + +[table Bimap and Boost examples +[[Program ][Description ]] + +[[[@../../example/bimap_and_boost/assign.cpp + assign.cpp ]] + [Bimap and Boost.Assign: Methods to insert elements ]] + +[[[@../../example/bimap_and_boost/lambda.cpp + lambda.cpp ]] + [Bimap and Boost.Lambda: new lambda placeholders ]] + +[[[@../../example/bimap_and_boost/property_map.cpp + property_map.cpp ]] + [Bimap and Boost.PropertyMap: PropertyMap support ]] + +[[[@../../example/bimap_and_boost/range.cpp + range.cpp ]] + [Bimap and Boost.Range: Using bimaps in the new range framework ]] + +[[[@../../example/bimap_and_boost/foreach.cpp + foreach.cpp ]] + [Bimap and Boost.Foreach: Iterating over bimaps ]] + +[[[@../../example/bimap_and_boost/typeof.cpp + typeof.cpp ]] + [Bimap and Boost.Typeof: using BOOST_AUTO while we wait for C++0x ]] + +[[[@../../example/bimap_and_boost/xpressive.cpp + xpressive.cpp ]] + [Bimap and Boost.Xpressive: Inserting elements in a bimap ]] + +[[[@../../example/bimap_and_boost/serialization.cpp + serialization.cpp: ]] + [Bimap and Boost.Serialization: Load and save bimaps and iterators ]] +] + + +[table Boost.MultiIndex to Boost.Bimap path examples +[[Program ][Description ]] + +[[[@../../example/mi_to_b_path/bidirectional_map.cpp + bidirectional_map.cpp ]] + [Boost.MultiIndex to Boost.Bimap path example ]] + +[[[@../../example/mi_to_b_path/hashed_indices.cpp + hashed_indices.cpp ]] + [Boost.MultiIndex to Boost.Bimap path example ]] + +[[[@../../example/mi_to_b_path/tagged_bidirectional_map.cpp + tagged_bidirectional_map.cpp ]] + [Boost.MultiIndex to Boost.Bimap path example ]] + +] + +[endsect] + +[section Simple Bimap] + +This is the example from the one minute tutorial section. + +[@../../example/simple_bimap.cpp Go to source code] + +[code_simple_bimap] + +You can rewrite it using tags to gain readability. + +[@../../example/tagged_simple_bimap.cpp Go to source code] + +[import ../example/tagged_simple_bimap.cpp] + +[code_tagged_simple_bimap] + + +[endsect] + +[section Mighty Bimap] + +This is the translator example from the tutorial. +In this example the collection type of relation is changed to allow the iteration +of the container. + +[@../../example/mighty_bimap.cpp Go to source code] + +[code_mighty_bimap] + + +[endsect] + +[section MultiIndex to Bimap Path - Bidirectional Map] + +This is example 4 in Boost.MultiIndex documentation. + +[blurb +This example shows how to construct a bidirectional map with multi_index_container. +By a bidirectional map we mean a container of elements of +`std::pair<const FromType,const ToType>` such that no two elements exists with the +same first or second value (`std::map` only guarantees uniqueness of the first member). +Fast look-up is provided for both keys. The program features a tiny Spanish-English +dictionary with on-line query of words in both languages. +] + +[heading Boost.MultiIndex] + +[@../../example/mi_to_b_path/mi_bidirectional_map.cpp Go to source code] + +[import ../example/mi_to_b_path/mi_bidirectional_map.cpp] + +[code_mi_to_b_path_mi_bidirectional_map] + +[heading Boost.Bimap] + +[@../../example/mi_to_b_path/bidirectional_map.cpp Go to source code] + +[import ../example/mi_to_b_path/bidirectional_map.cpp] + +[code_mi_to_b_path_bidirectional_map] + +Or better, using tags... + +[@../../example/mi_to_b_path/tagged_bidirectional_map.cpp Go to source code] + +[import ../example/mi_to_b_path/tagged_bidirectional_map.cpp] + +[code_mi_to_b_path_tagged_bidirectional_map] + +[endsect] + +[section MultiIndex to Bimap Path - Hashed indices] + +This is example 8 of Boost.MultiIndex. + +[blurb +Hashed indices can be used as an alternative to ordered indices when fast look-up is needed and sorting +information is of no interest. The example features a word counter where duplicate entries are checked by +means of a hashed index. +] + +[heading Boost.MultiIndex] + +[@../../example/mi_to_b_path/mi_hashed_indices.cpp Go to source code] + +[import ../example/mi_to_b_path/mi_hashed_indices.cpp] + +[code_mi_to_b_path_mi_hashed_indices] + +[heading Boost.Bimap] + +[@../../example/mi_to_b_path/hashed_indices.cpp Go to source code] + +[import ../example/mi_to_b_path/hashed_indices.cpp] + +[code_mi_to_b_path_hashed_indices] + + +[endsect] + +[endsect]
\ No newline at end of file diff --git a/libs/bimap/doc/future_work.qbk b/libs/bimap/doc/future_work.qbk new file mode 100644 index 0000000000..9118de5bbc --- /dev/null +++ b/libs/bimap/doc/future_work.qbk @@ -0,0 +1,23 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section Future work] + + +[heading Rearrange Function] + +Boost.MultiIndex includes some others functions that can be included in the views. + + +[endsect]
\ No newline at end of file diff --git a/libs/bimap/doc/history.qbk b/libs/bimap/doc/history.qbk new file mode 100644 index 0000000000..ddcfd10139 --- /dev/null +++ b/libs/bimap/doc/history.qbk @@ -0,0 +1,450 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section History] + +[section The long path from Code Project to Boost] + +[variablelist +[[2002 - bimap at Code Project] +[ +Joaquin Lopez Muñoz posted his first +[@http://www.codeproject.com/vcpp/stl/bimap.asp#test_suite bimap library] +in 2002. Tons of users have been using it. He then +[@http://aspn.activestate.com/ASPN/Mail/Message/boost/1404881 asked the +list for interest] in his library in 2003. Luckily, there was a lot of +interest and Joaquin started to boostify the code. At some point all the +developers seemed to agree that, rather than a bidirectional map, it would +be better to work on an N-indexed set that contained Joaquin's library as a +particular case. +]] + +[[2003 - multiindex_set] +[ +The library grew enormously and was ready for a formal review in +2003. At this point, the container was a lot more powerful, but +everything comes with a price and this new beast lacked the simplicity +of the original bimap. +]] + +[[2004 - indexed_set] +[ +In 2004, the formal review ended well for the new multi-indexed +container. This Swiss army knife introduced several new features, such +as non-unique indexes, hashed indices and sequenced indices. In the list +of improvements to the library, it was mentioned that a bidirectional +map should be coded in top of this container. +]] + +[[2005 - multi_index_container] +[ +Once in Boost, the library switched to the now familiar name +"Boost.MultiIndex". Late in 2004, it formally became a member of Boost. +Joaquin continued to enchance the library and added new features such as +composite keys and random-access indices. +]] + +[[2006 - Multi Index Specialized Containers SoC project] +[ +In 2006, during the formal review of Boost.Property_tree, the need +for a bidirectional map container built on top of Boost.MultiIndex arose +again. Boost entered the Google SoC 2006 as a mentor organization at the +same time. Joaquin put himself forward as a mentor. He proposed to build +not only a bidirectional map, but a myriad multi-indexed specialized +containers. Matias Capeletto presented an application to code Boost.Misc +for the SoC and was elected, along with nine other students. Matias's and +Joaquin's SoC project ends with a working implementation of the bimap +library that was presented in an informal review. By the end of the year +the library was queued for a formal review. +]] + +[[2007 - Boost.Bimap] +[ +The formal review took place at the beggining of the year and Boost.Bimap +was accepted in Boost. +]] +] + +[endsect] + +[section MultiIndex and Bimap] + +This is the conversation thread that began during Boost.PropertyTree formal +review process. The review was very interesting and very deep topics were +addressed. It is quite interesting and it is now part of this library history. +Enjoy! + + +[*Marcin] +[:[' +The biggest virtue of property_tree is easy to use interface. +If we try to make generic tree of it, it will be compromised. +]] + +[*Gennadiy] +[:[' +IMO the same result (as library presents) could be achieved +just by using multi_index. +]] + +[*Marcin] +[:[' +Could you elaborate more on that? I considered use of +multi_index to implement indexing for properties, but it only affected the +implementation part of library, not interface, and because I already had a +working, exception safe solution, I didn't see the reason to dump it and add +another dependency on another library. +]] + +[*Gennadiy] +[:[' +I mean why do I need this half baked property_tree as another +data structure? Property tree supports nothing in itself. It's just a data +structure. You have parsers that produce property tree out of different sources. +But you mat as well produce maps or something else. Here for example All that +I need to do to "implement" similar functionality as your property tree: +]] + +`` +// Data structure itself +template<typename ValueType,typename KeyType> +struct Node; +template<typename ValueType,typename KeyType> +struct ptree_gen { + typedef std::pair<KeyType,Node<ValueType,KeyType> > mi_value; + typedef multi_index_container<mi_value, indexed_by<...> > type; +}; +template<typename ValueType,typename KeyType> +struct Node { + ValueType v; + ptree_gen<ValueType,KeyType>::type children; +}; +// serialization support +template<class Archive,typename ValueType,typename KeyType> +void serialize(Archive & ar, Node<ValueType,KeyType>& n, + const unsigned int version) +{ + ar & n.v; + ar & n.children; +} +// some access methods +template<typename ValueType,typename KeyType> +ValueType const& +get( string const& keys, ptree_gen<ValueType,KeyType>::type const& src ) +{ + std::pait<string,string> sk = split( keys, "." ); + Node const& N = src.find( sk.first ); + return sk.second.empty() ? N.v : get( sk.second, N.children ); +} +`` + +[:[' +Use it like this: +]] + +`` +ptree_gen<string,string>::type PT; +boost::archive::text_iarchive ia( std::ifstream ifs("filename") ); +ia >> PT; +string value = get( "a.b.c.d", PT ); +`` + +[:[' +Now tell me how property_tree interface is easier? And what is the value in +50k of Code you need to implement this data structure. +]] + +[*Thorsten] +[:[' +Seriously Gennadiy, do you really see newbies writing +the code you just did? +]] + +[*Marcin] +[:[' +What you just implemented is stripped down, bare bones version +of property_tree that, among other things, does not allow you to produce human +editable XML files. Now add more interface (aka get functions), add more +archives to serialization lib, add customization, add transparent +translation from strings to arbitrary types and vice versa. Spend some weeks +trying to get all the corner cases right, and then some more weeks trying to +smooth rough edges in the interface. Then write tests. Write docs. At the +end, I believe you will not get much less code than there is in the library +already. Maybe you get some savings by using multi_index instead of manual +indexing. +]] +[:[' +The reason why ptree does not use multi index is because implementation +existed long before I considered submitting to boost, probably before even I +knew of multi index existence. It was working well. Later, when I was +improving it during pre-review process, I seriously considered using +multi-index. But I decided it is not worth throwing everything out. +]] +[:[' +Although ptree has large interface with many functions modifying state of +the tree, it uses "single point of change" approach. Every insert eventually +goes through one function, which takes care of exception safety and keeping +index in sync with data. The same applies to erase. This function has 9 +lines of code in case of insert, and (by coincidence) also 9 in case of +erase. By using multi index these functions would obviously be simplified, +maybe to 4 lines each. Net gain: 10 lines of code (out of several hundred in +ptree_implementation.hpp). +]] +[:[' +I'm aware that there are performance gains to be reaped as well, but at that +time I was rather focusing on getting the interface right. +]] + +[*Dave] +[:[' +That's perfectly reasonable, but (through no fault of yours) +it misses the point I was trying to make. I guess I should have said, +"...that demonstrates it to be the best implementation." +]] +[:[' +All I'm saying is that the extent to which a Boost library +implementation should leverage other Boost libraries is not a question +that can always be decided based on following simple guidelines, and +that if this library is accepted, it's worth revisiting your decision. +]] + +[*Thorsten] +[:[' +I think it is important to focus on the interface in +the review, but I also see several benefits of an implementation that builds on +Boost.MultiIndex:' +]] +[:['- fewer bugs like the one Joaquin found]] +[:['- better space efficiency]] +[:['- exception-safety guarantees are immediately full-filled (I haven't +looked, but I suspect that there are several bugs in this area)]] + +[*Daniel] +[:[' +Multi_index supports everything a bimap would, but its +interface is more cumbersome. I for one won't use a W3DOM-like library +if we get one, but I would happily use property_tree. I've also only +used multi_index once, and that was to use it as a bidirectional map. +Property_tree covers other areas as well as being a potential subset of +an XML library, but I still hold there is value in such a subset. +]] + +[*Boris] +[:[' +I haven't used program_options yet. But if I understand +correctly both libraries seem to support storing and accessing data with +strings that might describe some kind of hierarchy. This seems to be the core +idea of both libraries - is this correct? +]] +[:[' +Then it wouldn't matter much what container is used. However a generic tree +which can store data hierarchically probably makes most sense. If I +understand correctly both libraries could make use of such a class? +]] + +[*Marcin] +[:[' +I think generic tree container is material for another library. +Whether property_tree should be based on it or not is a matter of internal +implementation, and generally of little interest to users. The biggest value +of property_tree is in its easy to use interface, that should not be +compromised, if at all possible. I have been already reassured in this view +by quite many people who took their time to review the library. +]] + +[*Boris] +[:[' +I was trying to see the big picture: I rather prefer a C++ +standard based on a few well-known concepts like containers, iterators, +algorithms etc. instead of having a C++ standard with hundreds of components +which are tailored for specific needs, collaborate with only a handful of other +components and think they provide an easy-to-use interface while all the +easy-to-use interfaces make the whole standard less easy-to-use. +]] +[:[' +That said I have used your property tree library myself to read and write a +configuration file. It was indeed very easy to use. However it would have +been even easier if it was something I had known before like eg. an +iterator. For now I will definitely use your property tree library but would +appreciate if existing concepts were reused many C++ developers are familiar +with. My opinion is that your library should be a part of Boost but should +be more generalized in the future. +]] + +[*Thorsten] +[:[' +Well, I think we need both. Boost.MultiIndex is a great +library and can do all kinds of wonderful things. But I would still like to see +a bidirectional map (boost::bimap) written as a wrapper around it to +get an easy and specialized interface. +]] + +[*Pavel] +[:[' +Bimap is available in libs/multi-index/examples/bimap.cpp. +]] + +[*Thorsten] +[:[' +Right, but the real value comes when somebody designs a nice +STL-like interface and write docs etc, at least that was my point. +]] + +[*Dave] +[:[' +IMO Thorsten is exactly right. This is precisely the sort of +thing that could be added to the library as part of its ongoing maintenance +and development (without review, of course). +]] + +[*Joaquin] +[:[' +Thorsten, we have talked about this privately in the past, +but I feel like bringing it to the list in the hope of getting the attention +of potential contributors: +]] +[:[' +There are some data structures buildable with B.MI which are regarded as +particularly useful or common, like for instance the bidirectional map or +bimap. A lean and mean implementation is provided in the aforementioned +example, but certainly a much carefully crafted interface can be provided +keeping B.MI as the implementation core: operator\[\], selection of +1-1/1-N/N-1/N-N variants, hashing/ordering, etc. +]] +[:[' +I'm afraid I don't have the time to pursue this, as the current roadmap for +core features of B.MI is taking all the spare time I can dedicate to the +library. For this reason, I would love to see some volunteer jumping in who +can develop this and other singular containers using B.MI (a cache container +comes to mind) and then propose the results here either as a stand alone +library of as part of B.MI --I'd prefer the former so as to keep the size +of B.MI bounded. +]] +[:[' +If there's such a volunteer I can provide her with some help/mentoring. I also +wonder whether this is a task suitable to be proposed for Google Summer of +Code. +]] + +[*Thorsten] +[:[' +I think it would be good for SOC. All the really hard things +are taken care of by B.MI, and so it seems reasonable for a student to be able +to fill in the details. +]] + +[*Dave] +[:[' +Great! +]] + +[*Jeff] +[:[' +Please write a proposal! +]] + +[*Joaquin] +[:[' +I've just done so: +]] + +[blurb *Specialized containers with Boost.MultiIndex* + + *Introduction* + + Boost.MultiIndex allows the construction of complex data structures involving + two or more indexing mechanisms on the same set of elements. Out of the + unlimited range of possible data structures specifiable within + Boost.MultiIndex, some particular configurations arise recurrently: + + *a.* A bidirectional map or bimap is a container of elements of type pair<T,Q> + where fast look up is provided both for the T and the Q field, + in contrast with a regular STL map which only allows for fast look up on T. + + *b.* An MRU (most recently used) list keeps the n last referenced elements: + when a new item is inserted and the list has reached its maximum length, the + oldest element is erased, whereas if an insertion is tried of a preexistence + element, this gets promoted to the first position. MRU lists can be used to + implement dynamic caches and the kind of behavior exhibited by programs + featuring a "Recent files" menu command, for instance. + + Although Boost.MultiIndex provides the mechanisms to build these common structures, + the resulting interface can be cumbersome and too general in comparison with + specialized containers focusing on such particular structures. + + *Goal* + + To write a library of specialized containers like the ones described above, using + Boost.MultiIndex as the implementation core. Besides bimap and MRU list, the student + can also propose other specialized containers of interest in the community. It is + expected that the library meets the standards of quality required by Boost for an + eventual inclusion in this project, which implies a strong emphasis on interface + design, documentation and unit testing; the mentor will be guiding the student + through the complete cycle from specification and requirements gathering to + documentation and actual coding. The final result of the project must then contain: + + *a.* Source code following + [@http://boost.org/more/lib_guide.htm#Guidelines Boost programming guidelines]. + + *b.* User documentation. Requirements on the format are loose, though the + [@http://www.boost.org/tools/quickbook/ QuickBook] format is + gaining acceptance within Boost. + + *c.* Complete set of unit tests powered by + [@http://www.boost.org/boost-build2/ Boost Build System V2]. + + *Requirements* + + *a.* Intermediate-to-high level in C++, with emphasis in generic programming + (templates). + + *b.* Knowledge of the STL framework and design principles. Of course, knowledge + of Boost in general and Boost.MultiIndex in particular is a big plus. + + *c.* Acquaintance with at least two different C++ programming environments. + + *d.* Some fluency in the English language; subsequent reviews of the documentation + can help smooth rough edges here, though. + + *e.* A mathematical inclination and previous exposure to a formal Algorithms course + would help very much. + + *f.* A craving for extreme quality work. + + *Benefits for the student* + + The student taking on this project will have the opportunity to learn the complete + process of software production inside a highly regarded C++ open source institution, + and even see her work included in Boost eventually. The completion of the project + involves non-trivial problems in C++ interface design and so-called modern C++ + programming, high quality user documentation and unit testing. The student will + also learn, perhaps to her surprise, that most of the time will be spent gathering + and trying ideas and, in general, thinking, rather than writing actual code. +] + +[*Matias] +[:[' +I am planning to submit an application to SoC. I will love to make real +the specialized containers you mention and try to include some useful others. +]] + +[:[^ +And then... after long hours of coding (and fun) this library saw the light. +]] + +[:__BOOST_BIMAP_LOGO__] + +[endsect] + +[endsect] diff --git a/libs/bimap/doc/html/boost_bimap/acknowledgements.html b/libs/bimap/doc/html/boost_bimap/acknowledgements.html new file mode 100644 index 0000000000..167296f6dc --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/acknowledgements.html @@ -0,0 +1,100 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Acknowledgements</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="prev" href="history/multiindex_and_bimap.html" title="MultiIndex and Bimap"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> +<td align="center"><a href="../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="history/multiindex_and_bimap.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="boost_bimap.acknowledgements"></a><a class="link" href="acknowledgements.html" title="Acknowledgements">Acknowledgements</a> +</h2></div></div></div> +<p> + This library was developed in the context of the Google SoC 2006. I first want + to thank my mentor, Joaquin, for his friendship during this project. Not only + did he help me go through the process of creating this library, but he also + did his best so we could have a great time doing it. Also, Boost.Bimap would + not exist had Boost.MultiIndex, Joaquin's masterpiece, not existed. Thanks + a lot! + </p> +<p> + <span class="inlinemediaobject"><img src="../images/extern/googlesoc.png" alt="googlesoc"></span> + </p> +<p> + I want to thank Google for this amazing <span class="emphasis"><em>boost</em></span> to the open-source + community and to Boost mentors for trusting in my proposal in the first place. + Next on the list are my colleagues from SoC that helped me not get bored during + the long hours of coding. + </p> +<p> + Special acknowledgements to the developers of the Boost libraries that Boost.Bimap + has abused. See the dependencies section for a complete list. + </p> +<p> + I want to thank the open-source developers who wrote the tools I used during + this project. The list of names is infinitely long, so I give a general huge + thanks here. + </p> +<p> + Thanks to Paul Giaccone for proof-reading this documentation. (He has not finished + yet -- the remaining typos and spelling errors are mine and will be corrected + as soon as possible.) + </p> +<p> + Finally, thanks to my family, who had to see me at home all day during the + SoC. Special thanks to my brother Agustin, future famous novelist (at the present + time he is 19 years old), who patiently read every word of these docs and while + correcting them, barked at me for my bad written English. I have learned a + lot from his sermons. I want to thank my dog, Mafalda, too for barking all + day from my window and for being such a good company. + </p> +<p> + Thanks to Alisdair Meredith, Fernando Cacciola, Jeff Garland, John Maddock, + Thorsten Ottosen, Tony and Giovanni Piero Deretta for participating in the + formal review and give me useful advices to improve this library. And thanks + a lot to Ion Gaztañaga for managing the review. + </p> +<a name="boost_bimap.acknowledgements.boost_bimap_team"></a><h4> +<a name="id889228"></a> + <a class="link" href="acknowledgements.html#boost_bimap.acknowledgements.boost_bimap_team">Boost.Bimap Team</a> + </h4> +<p> + From Argentina... Matias and Mafalda and from Spain... Joaquin and Hector + </p> +<p> + <span class="inlinemediaobject"><img src="../images/people/matias.png" alt="matias"></span> <span class="inlinemediaobject"><img src="../images/people/mafalda.png" alt="mafalda"></span> <span class="inlinemediaobject"><img src="../images/people/joaquin.png" alt="joaquin"></span> <span class="inlinemediaobject"><img src="../images/people/hector.png" alt="hector"></span> + </p> +<p> + Luckily, the distance helps team members avoid eating each other. + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="history/multiindex_and_bimap.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/bimap_and_boost.html b/libs/bimap/doc/html/boost_bimap/bimap_and_boost.html new file mode 100644 index 0000000000..8bab2d4b7e --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/bimap_and_boost.html @@ -0,0 +1,149 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Bimap and Boost</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="prev" href="the_tutorial/complete_instantiation_scheme.html" title="Complete instantiation scheme"> +<link rel="next" href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html" title="Boost Libraries that work well with Boost.Bimap"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> +<td align="center"><a href="../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="the_tutorial/complete_instantiation_scheme.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="boost_bimap.bimap_and_boost"></a><a class="link" href="bimap_and_boost.html" title="Bimap and Boost">Bimap and Boost</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="bimap_and_boost.html#boost_bimap.bimap_and_boost.bimap_and_multiindex">Bimap + and MultiIndex</a></span></dt> +<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html">Boost + Libraries that work well with Boost.Bimap</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.introduction">Introduction</a></span></dt> +<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_serialization">Boost.Serialization</a></span></dt> +<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_assign">Boost.Assign</a></span></dt> +<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_hash">Boost.Hash</a></span></dt> +<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_lambda">Boost.Lambda</a></span></dt> +<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_range">Boost.Range</a></span></dt> +<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_foreach">Boost.Foreach</a></span></dt> +<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_typeof">Boost.Typeof</a></span></dt> +<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_xpressive">Boost.Xpressive</a></span></dt> +<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_property_map">Boost.Property_map</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="bimap_and_boost/dependencies.html">Dependencies</a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.bimap_and_boost.bimap_and_multiindex"></a><a class="link" href="bimap_and_boost.html#boost_bimap.bimap_and_boost.bimap_and_multiindex" title="Bimap and MultiIndex">Bimap + and MultiIndex</a> +</h3></div></div></div> +<p> + <span class="emphasis"><em>MISC</em></span> - <span class="bold"><strong>M</strong></span>ulti-<span class="bold"><strong>I</strong></span>ndex <span class="bold"><strong>S</strong></span>pecialized + <span class="bold"><strong>C</strong></span>ontainers + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Let's be generic, construct frameworks, describe the world in + an unified way... </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> No!, it is better to be specialized, design easy-to-use components, + offer plug-and-play objects... </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="bold"><strong> Why not take advantage of the best of both worlds? + </strong></span> + </p></blockquote></div> +<p> + <span class="inlinemediaobject"><img src="../images/bimap/miBimapFramework.png" alt="miBimapFramework"></span> + </p> +<p> + With Boost.Bimap, you can build associative containers in which both types + can be used as key. There is a library in Boost that already allows the creation + of this kind of container: Boost.MultiIndex. It offers great flexibility + and lets you construct almost any container that you could dream of. The + framework is very clean. You migh want to read this library's tutorial to + learn about the power that has been achieved. + </p> +<p> + But generality comes at a price: the interface that results might not be + the best for every specialization. People may end up wrapping a B.MI container + in its own class every time they want to use it as a bidirectional map. Boost.Bimap + takes advantage of the narrower scope to produce a better interface for bidirectional + maps <sup>[<a name="id797996" href="#ftn.id797996" class="footnote">2</a>]</sup>. There is no learning curve if you know how to use standard containers. + Great effort was put into mapping the naming scheme of the STL to Boost.Bimap. + The library is designed to match the common STL containers. + </p> +<p> + Boost.MultiIndex is, in fact, the core of the bimap container. + </p> +<p> + However, Boost.Bimap do not aim to tackle every problem with two indexed + types. There exist some problems that are better modelled with Boost.MultiIndex. + </p> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Problem I - An employee register</strong></span> + </p> +<p> + <span class="emphasis"><em>Store an ID and a name for an employee, with fast search on each + member.</em></span> + </p> +<p> + This type of problem is better modelled as a database table, and <span class="bold"><strong>Boost.MultiIndex</strong></span> is the preferred choice. It is possible + that other data will need to be indexed later. + </p> +</div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Problem II - A partners container</strong></span> + </p> +<p> + <span class="emphasis"><em>Store the names of couples and be able to get the name of a person's + partner.</em></span> + </p> +<p> + This problem is better modelled as a collection of relations, and <span class="bold"><strong>Boost.Bimap</strong></span> fits nicely here. + </p> +</div> +<p> + You can also read <a class="link" href="the_tutorial/additional_information.html" title="Additional information">Additional + Information</a> for more information about the relation of this two libraries. + </p> +</div> +<div class="footnotes"> +<br><hr width="100" align="left"> +<div class="footnote"><p><sup>[<a id="ftn.id797996" href="#id797996" class="para">2</a>] </sup> + In the same fashion, Boost.MRU will allow the creation of <span class="emphasis"><em>most + recent updated</em></span> aware containers, hiding the complexity of Boost.MultiIndex. + </p></div> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="the_tutorial/complete_instantiation_scheme.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html b/libs/bimap/doc/html/boost_bimap/bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html new file mode 100644 index 0000000000..40cb1f1357 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html @@ -0,0 +1,917 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Boost Libraries that work well with Boost.Bimap</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../bimap_and_boost.html" title="Bimap and Boost"> +<link rel="prev" href="../bimap_and_boost.html" title="Bimap and Boost"> +<link rel="next" href="dependencies.html" title="Dependencies"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../bimap_and_boost.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bimap_and_boost.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="dependencies.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap"></a><a class="link" href="boost_libraries_that_work_well_with_boost_bimap.html" title="Boost Libraries that work well with Boost.Bimap">Boost + Libraries that work well with Boost.Bimap</a> +</h3></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.introduction">Introduction</a></span></dt> +<dt><span class="section"><a href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_serialization">Boost.Serialization</a></span></dt> +<dt><span class="section"><a href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_assign">Boost.Assign</a></span></dt> +<dt><span class="section"><a href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_hash">Boost.Hash</a></span></dt> +<dt><span class="section"><a href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_lambda">Boost.Lambda</a></span></dt> +<dt><span class="section"><a href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_range">Boost.Range</a></span></dt> +<dt><span class="section"><a href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_foreach">Boost.Foreach</a></span></dt> +<dt><span class="section"><a href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_typeof">Boost.Typeof</a></span></dt> +<dt><span class="section"><a href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_xpressive">Boost.Xpressive</a></span></dt> +<dt><span class="section"><a href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_property_map">Boost.Property_map</a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.introduction"></a><a class="link" href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.introduction" title="Introduction">Introduction</a> +</h4></div></div></div> +<div class="informaltable"><table class="table"> +<colgroup> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Name + </p> + </th> +<th> + <p> + Description + </p> + </th> +<th> + <p> + author + </p> + </th> +<th> + <p> + Purpose + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <a href="http://www.boost.org/libs/serialization/doc/index.html" target="_top"><span class="bold"><strong>Boost.Serialization</strong></span></a> + </p> + </td> +<td> + <p> + Serialization for persistence and marshalling + </p> + </td> +<td> + <p> + Robert Ramey + </p> + </td> +<td> + <p> + Serialization support for bimap containers and iterators + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/libs/assign/doc/index.html" target="_top"><span class="bold"><strong>Boost.Assign</strong></span></a> + </p> + </td> +<td> + <p> + Filling containers with constant or generated data has never + been easier + </p> + </td> +<td> + <p> + Thorsten Ottosen + </p> + </td> +<td> + <p> + Help to fill a bimap or views of it + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/doc/html/hash.html" target="_top"><span class="bold"><strong>Boost.Hash</strong></span></a> + </p> + </td> +<td> + <p> + A TR1 hash function object that can be extended to hash user + defined types + </p> + </td> +<td> + <p> + Daniel James + </p> + </td> +<td> + <p> + Default hashing function + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/doc/html/lambda.html" target="_top"><span class="bold"><strong>Boost.Lambda</strong></span></a> + </p> + </td> +<td> + <p> + Define small unnamed function objects at the actual call site, + and more + </p> + </td> +<td> + <p> + from Jaakko Järvi, Gary Powell + </p> + </td> +<td> + <p> + Functors for modify, range, lower_bound and upper_bound + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/doc/html/range.html" target="_top"><span class="bold"><strong>Boost.Range</strong></span></a> + </p> + </td> +<td> + <p> + A new infrastructure for generic algorithms that builds on top + of the new iterator concepts + </p> + </td> +<td> + <p> + Thorsten Ottosen + </p> + </td> +<td> + <p> + Range based algorithms + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/doc/html/foreach.html" target="_top"><span class="bold"><strong>Boost.Foreach</strong></span></a> + </p> + </td> +<td> + <p> + BOOST_FOREACH macro for easily iterating over the elements of + a sequence + </p> + </td> +<td> + <p> + Eric Niebler + </p> + </td> +<td> + <p> + Iteration + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/libs/typeof/doc/index.html" target="_top"><span class="bold"><strong>Boost.Typeof</strong></span></a> + </p> + </td> +<td> + <p> + Typeof operator emulation + </p> + </td> +<td> + <p> + Arkadiy Vertleyb, Peder Holt + </p> + </td> +<td> + <p> + Using BOOST_AUTO while we wait for C++0x + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/libs/xpressive/doc/index.html" target="_top"><span class="bold"><strong>Boost.Xpressive</strong></span></a> + </p> + </td> +<td> + <p> + Regular expressions that can be written as strings or as expression + templates + </p> + </td> +<td> + <p> + Eric Niebler + </p> + </td> +<td> + <p> + Help to fill a bimap from a string + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/doc/html/property_map.html" target="_top"><span class="bold"><strong>Boost.PropertyMap</strong></span></a> + </p> + </td> +<td> + <p> + Concepts defining interfaces which map key objects to value objects + </p> + </td> +<td> + <p> + Jeremy Siek + </p> + </td> +<td> + <p> + Integration with BGL + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_serialization"></a><a class="link" href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_serialization" title="Boost.Serialization">Boost.Serialization</a> +</h4></div></div></div> +<p> + A bimap can be archived and retrieved by means of the Boost.Serialization + Library. Both regular and XML archives are supported. The usage is straightforward + and does not differ from that of any other serializable type. For instance: + </p> +<p> + <a href="../../../../example/bimap_and_boost/serialization.cpp" target="_top">Go to source + code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> + +<span class="comment">// Create a bimap and serialize it to a file +</span><span class="special">{</span> + <span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> + <span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"one"</span><span class="special">,</span><span class="number">1</span><span class="special">)</span> <span class="special">);</span> + <span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"two"</span><span class="special">,</span><span class="number">2</span><span class="special">)</span> <span class="special">);</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">ofstream</span> <span class="identifier">ofs</span><span class="special">(</span><span class="string">"data"</span><span class="special">);</span> + <span class="identifier">boost</span><span class="special">::</span><span class="identifier">archive</span><span class="special">::</span><span class="identifier">text_oarchive</span> <span class="identifier">oa</span><span class="special">(</span><span class="identifier">ofs</span><span class="special">);</span> + + <span class="identifier">oa</span> <span class="special"><<</span> <span class="keyword">const_cast</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">bm_type</span><span class="special">&>(</span><span class="identifier">bm</span><span class="special">);</span> <a class="co" name="boost_bimap16co" href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap16"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> + + <a class="co" name="boost_bimap17co" href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap17"><img src="../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a><span class="keyword">const</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_iterator</span> <span class="identifier">left_iter</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="string">"two"</span><span class="special">);</span> + <span class="identifier">oa</span> <span class="special"><<</span> <span class="identifier">left_iter</span><span class="special">;</span> + + <span class="keyword">const</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">right_iterator</span> <span class="identifier">right_iter</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="number">1</span><span class="special">);</span> + <span class="identifier">oa</span> <span class="special"><<</span> <span class="identifier">right_iter</span><span class="special">;</span> +<span class="special">}</span> + +<span class="comment">// Load the bimap back +</span><span class="special">{</span> + <span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">ifstream</span> <span class="identifier">ifs</span><span class="special">(</span><span class="string">"data"</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">ios</span><span class="special">::</span><span class="identifier">binary</span><span class="special">);</span> + <span class="identifier">boost</span><span class="special">::</span><span class="identifier">archive</span><span class="special">::</span><span class="identifier">text_iarchive</span> <span class="identifier">ia</span><span class="special">(</span><span class="identifier">ifs</span><span class="special">);</span> + + <span class="identifier">ia</span> <span class="special">>></span> <span class="identifier">bm</span><span class="special">;</span> + + <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special">==</span> <span class="number">2</span> <span class="special">);</span> + + <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_iterator</span> <span class="identifier">left_iter</span><span class="special">;</span> + <span class="identifier">ia</span> <span class="special">>></span> <span class="identifier">left_iter</span><span class="special">;</span> + + <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">left_iter</span><span class="special">-></span><span class="identifier">first</span> <span class="special">==</span> <span class="string">"two"</span> <span class="special">);</span> + + <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">right_iterator</span> <span class="identifier">right_iter</span><span class="special">;</span> + <span class="identifier">ia</span> <span class="special">>></span> <span class="identifier">right_iter</span><span class="special">;</span> + + <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">right_iter</span><span class="special">-></span><span class="identifier">first</span> <span class="special">==</span> <span class="number">1</span> <span class="special">);</span> +<span class="special">}</span> +</pre> +<p> + </p> +<div class="calloutlist"><table border="0" summary="Callout list"> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap16"></a><a href="#boost_bimap16co"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> +<td valign="top" align="left"><p> + We must do a const cast because Boost.Serialization archives only save + const objects. Read Boost.Serializartion docs for the rationale behind + this decision + </p></td> +</tr> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap17"></a><a href="#boost_bimap17co"><img src="../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> </p></td> +<td valign="top" align="left"><p> + We can only serialize iterators if the bimap was serialized first. + Note that the const cast is not requiered here because we create our + iterators as const. + </p></td> +</tr> +</table></div> +<p> + Serialization capabilities are automatically provided by just linking with + the appropriate Boost.Serialization library module: it is not necessary + to explicitly include any header from Boost.Serialization, apart from those + declaring the type of archive used in the process. If not used, however, + serialization support can be disabled by globally defining the macro BOOST_BIMAP_DISABLE_SERIALIZATION. + Disabling serialization for Boost.MultiIndex can yield a small improvement + in build times, and may be necessary in those defective compilers that + fail to correctly process Boost.Serialization headers. + </p> +<div class="warning"><table border="0" summary="Warning"> +<tr> +<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../../doc/src/images/warning.png"></td> +<th align="left">Warning</th> +</tr> +<tr><td align="left" valign="top"><p> + Boost.Bimap and Boost.MultiIndex share a lot of serialization code. The + macro <code class="computeroutput"><span class="identifier">BOOST_BIMAP_DISABLE_SERIALIZATION</span></code> + disables serialization in <span class="bold"><strong>both</strong></span> libraries. + The same happens when <code class="computeroutput"><span class="identifier">BOOST_MULTI_INDEX_DISABLE_SERIALIZATION</span></code> + is defined. + </p></td></tr> +</table></div> +<p> + Retrieving an archived bimap restores not only the elements, but also the + order they were arranged in the views of the container. There is an exception + to this rule, though: for unordered sets, no guarantee is made about the + order in which elements will be iterated in the restored container; in + general, it is unwise to rely on the ordering of elements of a hashed view, + since it can change in arbitrary ways during insertion or rehashing --this + is precisely the reason why hashed indices and TR1 unordered associative + containers do not define an equality operator. + </p> +<p> + Iterators of a bimap can also be serialized. Serialization of an iterator + must be done only after serializing its corresponding container. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_assign"></a><a class="link" href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_assign" title="Boost.Assign">Boost.Assign</a> +</h4></div></div></div> +<p> + The purpose of this library is to make it easy to fill containers with + data by overloading operator,() and operator()(). These two operators make + it possible to construct lists of values that are then copied into a container. + </p> +<p> + These lists are particularly useful in learning, testing, and prototyping + situations, but can also be handy otherwise. The library comes with predefined + operators for the containers of the standard library, but most functionality + will work with any standard compliant container. The library also makes + it possible to extend user defined types so for example a member function + can be called for a list of values instead of its normal arguments. + </p> +<p> + Boost.Assign can be used with bimap containers. The views of a bimap are + signature-compatible with their standard counterparts, so we can use other + Boost.Assign utilities with them. + </p> +<p> + <a href="../../../../example/bimap_and_boost/assign.cpp" target="_top">Go to source code</a> + </p> +<p> + +</p> +<pre class="programlisting"> <span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">multiset_of</span><span class="special"><</span> <span class="keyword">int</span> <span class="special">>,</span> <span class="identifier">list_of</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">></span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> + + <span class="comment">// We can use assign::list_of to initialize the container. +</span> + <span class="identifier">bm_type</span> <span class="identifier">bm</span> <span class="special">=</span> <span class="identifier">assign</span><span class="special">::</span><span class="identifier">list_of</span><span class="special"><</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">relation</span> <span class="special">></span> <a class="co" name="boost_bimap18co" href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap18"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> + <span class="special">(</span> <span class="number">1</span><span class="special">,</span> <span class="string">"one"</span> <span class="special">)</span> + <span class="special">(</span> <span class="number">2</span><span class="special">,</span> <span class="string">"two"</span> <span class="special">)</span> + <span class="special">(</span> <span class="number">3</span><span class="special">,</span> <span class="string">"three"</span> <span class="special">);</span> + + <span class="comment">// The left map view is a multiset, again we use insert +</span> + <span class="identifier">assign</span><span class="special">::</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span> <span class="special">)</span> + <span class="special">(</span> <span class="number">4</span><span class="special">,</span> <span class="string">"four"</span> <span class="special">)</span> + <span class="special">(</span> <span class="number">5</span><span class="special">,</span> <span class="string">"five"</span> <span class="special">)</span> + <span class="special">(</span> <span class="number">6</span><span class="special">,</span> <span class="string">"six"</span> <span class="special">);</span> + + <span class="comment">// The right map view is a list so we use push_back here +</span> <span class="comment">// Note the order of the elements in the list! +</span> + <span class="identifier">assign</span><span class="special">::</span><span class="identifier">push_back</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span> <span class="special">)</span> + <span class="special">(</span> <span class="string">"seven"</span> <span class="special">,</span> <span class="number">7</span> <span class="special">)</span> + <span class="special">(</span> <span class="string">"eight"</span> <span class="special">,</span> <span class="number">8</span> <span class="special">);</span> + + <span class="identifier">assign</span><span class="special">::</span><span class="identifier">push_front</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span> <span class="special">)</span> + <span class="special">(</span> <span class="string">"nine"</span> <span class="special">,</span> <span class="number">9</span> <span class="special">)</span> + <span class="special">(</span> <span class="string">"ten"</span> <span class="special">,</span> <span class="number">10</span> <span class="special">)</span> + <span class="special">(</span> <span class="string">"eleven"</span><span class="special">,</span> <span class="number">11</span> <span class="special">);</span> + +<span class="comment">// Since it is left_based the main view is a multiset, so we use insert +</span> + <span class="identifier">assign</span><span class="special">::</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm</span> <span class="special">)</span> + <span class="special">(</span> <span class="number">12</span><span class="special">,</span> <span class="string">"twelve"</span> <span class="special">)</span> + <span class="special">(</span> <span class="number">13</span><span class="special">,</span> <span class="string">"thirteen"</span> <span class="special">);</span> + </pre> +<p> + </p> +<div class="calloutlist"><table border="0" summary="Callout list"><tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap18"></a><a href="#boost_bimap18co"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> +<td valign="top" align="left"><p> + Note that <code class="computeroutput"><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">relation</span></code> has to be used instead of + <code class="computeroutput"><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span></code>. Contrary to <code class="computeroutput"><span class="identifier">value_type</span></code>, <code class="computeroutput"><span class="identifier">relation</span></code> + type stores the elements as non const, a requirement of <code class="computeroutput"><span class="identifier">assign</span><span class="special">::</span><span class="identifier">list_of</span></code> + </p></td> +</tr></table></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_hash"></a><a class="link" href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_hash" title="Boost.Hash">Boost.Hash</a> +</h4></div></div></div> +<p> + The hash function is the very core of the fast lookup capabilities of the + unordered sets: a hasher is just a Unary Function returning an std::size_t + value for any given key. In general, it is impossible that every key map + to a different hash value, for the space of keys can be greater than the + number of permissible hash codes: what makes for a good hasher is that + the probability of a collision (two different keys with the same hash value) + is as close to zero as possible. + </p> +<p> + This is a statistical property depending on the typical distribution of + keys in a given application, so it is not feasible to have a general-purpose + hash function with excellent results in every possible scenario; the default + value for this parameter uses Boost.Hash, which often provides good enough + results. + </p> +<p> + Boost.Hash can be <a href="http://www.boost.org/doc/html/hash/custom.html" target="_top">extended + for custom data types</a>, enabling to use the default parameter of + the unordered set types with any user types. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_lambda"></a><a class="link" href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_lambda" title="Boost.Lambda">Boost.Lambda</a> +</h4></div></div></div> +<p> + The Boost Lambda Library (BLL in the sequel) is a C++ template library, + which implements form of lambda abstractions for C++. The term originates + from functional programming and lambda calculus, where a lambda abstraction + defines an unnamed function. Lambda expressions are very useful to construct + the function objects required by some of the functions in a bimap view. + </p> +<p> + Boost.Bimap defines new placeholders in <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">support</span><span class="special">/</span><span class="identifier">lambda</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> + to allow a sounder solution. The placeholders are named _key and _data + and both are equivalent to boost::lambda::_1. There are two reasons to + include this placeholders: the code looks better with them and they avoid + the clash problem between lambda::_1 and boost::_1 from Boost.Bind. + </p> +<p> + <a href="../../../../example/bimap_and_boost/lambda.cpp" target="_top">Go to source code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> + +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"one"</span><span class="special">,</span><span class="number">1</span><span class="special">)</span> <span class="special">);</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"two"</span><span class="special">,</span><span class="number">2</span><span class="special">)</span> <span class="special">);</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">range</span><span class="special">(</span> <span class="number">5</span> <span class="special"><</span> <span class="identifier">_key</span><span class="special">,</span> <span class="identifier">_key</span> <span class="special"><</span> <span class="number">10</span> <span class="special">);</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">modify_key</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="string">"one"</span><span class="special">),</span> <span class="identifier">_key</span> <span class="special">=</span> <span class="string">"1"</span> <span class="special">);</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">modify_data</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">_data</span> <span class="special">*=</span> <span class="number">10</span> <span class="special">);</span> +</pre> +<p> + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_range"></a><a class="link" href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_range" title="Boost.Range">Boost.Range</a> +</h4></div></div></div> +<p> + Boost.Range is a collection of concepts and utilities that are particularly + useful for specifying and implementing generic algorithms. Generic algorithms + have so far been specified in terms of two or more iterators. Two iterators + would together form a range of values that the algorithm could work on. + This leads to a very general interface, but also to a somewhat clumsy use + of the algorithms with redundant specification of container names. Therefore + we would like to raise the abstraction level for algorithms so they specify + their interface in terms of Ranges as much as possible. + </p> +<p> + As Boost.Bimap views are signature-compatible with their standard container + counterparts, they are compatible with the concept of a range. As an additional + feature, ordered bimap views offer a function named <code class="computeroutput"><span class="identifier">range</span></code> + that allows a range of values to be obtained. + </p> +<p> + If we have some generic functions that accepts ranges: + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">ForwardReadableRange</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">UnaryFunctor</span> <span class="special">></span> +<span class="identifier">UnaryFunctor</span> <span class="identifier">for_each</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">ForwardReadableRange</span> <span class="special">&</span> <span class="identifier">r</span><span class="special">,</span> <span class="identifier">UnaryFunctor</span> <span class="identifier">func</span><span class="special">)</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="keyword">typename</span> + <span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_const_iterator</span><span class="special"><</span><span class="identifier">ForwardReadableRange</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">const_iterator</span><span class="special">;</span> + + <span class="keyword">for</span><span class="special">(</span><span class="identifier">const_iterator</span> <span class="identifier">i</span><span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">r</span><span class="special">),</span> <span class="identifier">iend</span><span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">r</span><span class="special">);</span> <span class="identifier">i</span><span class="special">!=</span><span class="identifier">iend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">func</span><span class="special">(*</span><span class="identifier">i</span><span class="special">);</span> + <span class="special">}</span> + + <span class="keyword">return</span> <span class="identifier">func</span><span class="special">;</span> +<span class="special">}</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">ForwardReadableRange</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Predicate</span> <span class="special">></span> +<span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_difference</span><span class="special"><</span><span class="identifier">ForwardReadableRange</span><span class="special">>::</span><span class="identifier">type</span> + <span class="identifier">count_if</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">ForwardReadableRange</span> <span class="special">&</span> <span class="identifier">r</span><span class="special">,</span> <span class="identifier">Predicate</span> <span class="identifier">pred</span><span class="special">)</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="keyword">typename</span> + <span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_const_iterator</span><span class="special"><</span><span class="identifier">ForwardReadableRange</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">const_iterator</span><span class="special">;</span> + + <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_difference</span><span class="special"><</span><span class="identifier">ForwardReadableRange</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">c</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> + + <span class="keyword">for</span><span class="special">(</span> <span class="identifier">const_iterator</span> <span class="identifier">i</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">r</span><span class="special">),</span> <span class="identifier">iend</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">r</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">iend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">)</span> + <span class="special">{</span> + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">pred</span><span class="special">(*</span><span class="identifier">i</span><span class="special">)</span> <span class="special">)</span> <span class="special">++</span><span class="identifier">c</span><span class="special">;</span> + <span class="special">}</span> + + <span class="keyword">return</span> <span class="identifier">c</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + We can use them with Boost.Bimap with the help of the <code class="computeroutput"><span class="identifier">range</span></code> + function. + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">pair_printer</span> +<span class="special">{</span> + <span class="identifier">pair_printer</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span> <span class="special">&</span> <span class="identifier">o</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">os</span><span class="special">(</span><span class="identifier">o</span><span class="special">)</span> <span class="special">{}</span> + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Pair</span> <span class="special">></span> + <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="identifier">Pair</span> <span class="special">&</span> <span class="identifier">p</span><span class="special">)</span> + <span class="special">{</span> + <span class="identifier">os</span> <span class="special"><<</span> <span class="string">"("</span> <span class="special"><<</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span> <span class="special"><<</span> <span class="string">","</span> <span class="special"><<</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span> <span class="special"><<</span> <span class="string">")"</span><span class="special">;</span> + <span class="special">}</span> + <span class="keyword">private</span><span class="special">:</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span> <span class="special">&</span> <span class="identifier">os</span><span class="special">;</span> +<span class="special">};</span> + +<span class="keyword">struct</span> <span class="identifier">second_extractor</span> +<span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Pair</span> <span class="special">></span> + <span class="keyword">const</span> <span class="keyword">typename</span> <span class="identifier">Pair</span><span class="special">::</span><span class="identifier">second_type</span> <span class="special">&</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="identifier">Pair</span> <span class="special">&</span> <span class="identifier">p</span><span class="special">)</span> + <span class="special">{</span> + <span class="keyword">return</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="keyword">double</span><span class="special">,</span> <span class="identifier">multiset_of</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> + + <span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> + <span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="number">2.5</span> <span class="special">,</span> <span class="number">1</span><span class="special">)</span> <span class="special">);</span> + <span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="number">3.1</span> <span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special">);</span> + <span class="comment">//... +</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="number">6.4</span> <span class="special">,</span> <span class="number">4</span><span class="special">)</span> <span class="special">);</span> + <span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="number">1.7</span> <span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special">);</span> + + <span class="comment">// Print all the elements of the left map view +</span> + <span class="identifier">for_each</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">,</span> <span class="identifier">pair_printer</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">)</span> <span class="special">);</span> + + <span class="comment">// Print a range of elements of the right map view +</span> + <span class="identifier">for_each</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">range</span><span class="special">(</span> <span class="number">2</span> <span class="special"><=</span> <span class="identifier">_key</span><span class="special">,</span> <span class="identifier">_key</span> <span class="special"><</span> <span class="number">6</span> <span class="special">),</span> <span class="identifier">pair_printer</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">)</span> <span class="special">);</span> + + <span class="comment">// Count the number of elements where the data is equal to 2 from a +</span> <span class="comment">// range of elements of the left map view +</span> + <span class="identifier">count_if</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">range</span><span class="special">(</span> <span class="number">2.3</span> <span class="special"><</span> <span class="identifier">_key</span><span class="special">,</span> <span class="identifier">_key</span> <span class="special"><</span> <span class="number">5.4</span> <span class="special">),</span> + <span class="identifier">bind</span><span class="special"><</span><span class="keyword">int</span><span class="special">>(</span> <span class="identifier">second_extractor</span><span class="special">(),</span> <span class="identifier">_1</span> <span class="special">)</span> <span class="special">==</span> <span class="number">2</span> <span class="special">);</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + <a href="../../../../example/bimap_and_boost/range.cpp" target="_top">Go to source code</a> + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_foreach"></a><a class="link" href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_foreach" title="Boost.Foreach">Boost.Foreach</a> +</h4></div></div></div> +<p> + In C++, writing a loop that iterates over a sequence is tedious. We can + either use iterators, which requires a considerable amount of boiler-plate, + or we can use the std::for_each() algorithm and move our loop body into + a predicate, which requires no less boiler-plate and forces us to move + our logic far from where it will be used. In contrast, some other languages, + like Perl, provide a dedicated "foreach" construct that automates + this process. BOOST_FOREACH is just such a construct for C++. It iterates + over sequences for us, freeing us from having to deal directly with iterators + or write predicates. + </p> +<p> + You can use BOOST_FOREACH macro with Boost.Bimap views. The generated code + will be as efficient as a std::for_each iteration. Here are some examples: + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">list_of</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> + +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"1"</span><span class="special">,</span> <span class="number">1</span><span class="special">)</span> <span class="special">);</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"2"</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special">);</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"3"</span><span class="special">,</span> <span class="number">4</span><span class="special">)</span> <span class="special">);</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"4"</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special">);</span> + +<span class="identifier">BOOST_FOREACH</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_reference</span> <span class="identifier">p</span><span class="special">,</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span> <span class="special">)</span> +<span class="special">{</span> + <span class="special">++</span><span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span><span class="special">;</span> <a class="co" name="boost_bimap19co" href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap19"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> +<span class="special">}</span> + +<span class="identifier">BOOST_FOREACH</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">right_const_reference</span> <span class="identifier">p</span><span class="special">,</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span> <span class="special">)</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span> <span class="special"><<</span> <span class="string">"-->"</span> <span class="special"><<</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<span class="special">}</span> + +</pre> +<p> + </p> +<div class="calloutlist"><table border="0" summary="Callout list"><tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap19"></a><a href="#boost_bimap19co"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> +<td valign="top" align="left"><p> + We can modify the right element because we have use a mutable collection + type in the right side. + </p></td> +</tr></table></div> +<p> + You can use it directly with ranges too: + </p> +<p> + +</p> +<pre class="programlisting"><span class="identifier">BOOST_FOREACH</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_reference</span> <span class="identifier">p</span><span class="special">,</span> + <span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">range</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">(</span><span class="string">"1"</span><span class="special">)</span> <span class="special"><=</span> <span class="identifier">_key</span><span class="special">,</span> <span class="identifier">_key</span> <span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">(</span><span class="string">"3"</span><span class="special">)</span> <span class="special">)</span> <span class="special">))</span> +<span class="special">{</span> + <span class="special">++</span><span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span><span class="special">;</span> +<span class="special">}</span> + +<span class="identifier">BOOST_FOREACH</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_const_reference</span> <span class="identifier">p</span><span class="special">,</span> + <span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">range</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">(</span><span class="string">"1"</span><span class="special">)</span> <span class="special"><=</span> <span class="identifier">_key</span><span class="special">,</span> <span class="identifier">_key</span> <span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">(</span><span class="string">"3"</span><span class="special">)</span> <span class="special">)</span> <span class="special">))</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span> <span class="special"><<</span> <span class="string">"-->"</span> <span class="special"><<</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + <a href="../../../../example/bimap_and_boost/foreach.cpp" target="_top">Go to source code</a> + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_typeof"></a><a class="link" href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_typeof" title="Boost.Typeof">Boost.Typeof</a> +</h4></div></div></div> +<p> + Once C++0x is out we are going to be able to write code like: + </p> +<pre class="programlisting"><span class="keyword">auto</span> <span class="identifier">iter</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">name</span><span class="special">>().</span><span class="identifier">find</span><span class="special">(</span><span class="string">"john"</span><span class="special">);</span> +</pre> +<p> + instead of the more verbose + </p> +<pre class="programlisting"><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">name</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">iter</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">name</span><span class="special">>().</span><span class="identifier">find</span><span class="special">(</span><span class="string">"john"</span><span class="special">);</span> +</pre> +<p> + Boost.Typeof defines a macro BOOST_AUTO that can be used as a library solution + to the auto keyword while we wait for the next standard. + </p> +<p> + If we have + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">tagged</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span><span class="identifier">name</span><span class="special">>,</span> <span class="identifier">tagged</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span><span class="identifier">number</span><span class="special">></span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"one"</span> <span class="special">,</span><span class="number">1</span><span class="special">)</span> <span class="special">);</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"two"</span> <span class="special">,</span><span class="number">2</span><span class="special">)</span> <span class="special">);</span> +</pre> +<p> + </p> +<p> + The following code snippet + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">for</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">name</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">iter</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">name</span><span class="special">>().</span><span class="identifier">begin</span><span class="special">();</span> + <span class="identifier">iter</span><span class="special">!=</span><span class="identifier">bm</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">name</span><span class="special">>().</span><span class="identifier">end</span><span class="special">();</span> <span class="special">++</span><span class="identifier">iter</span><span class="special">)</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">iter</span><span class="special">-></span><span class="identifier">first</span> <span class="special"><<</span> <span class="string">" --> "</span> <span class="special"><<</span> <span class="identifier">iter</span><span class="special">-></span><span class="identifier">second</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<span class="special">}</span> + +<span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">number</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">iter</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">number</span><span class="special">>().</span><span class="identifier">find</span><span class="special">(</span><span class="number">2</span><span class="special">);</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"2: "</span> <span class="special"><<</span> <span class="identifier">iter</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">name</span><span class="special">>();</span> +</pre> +<p> + </p> +<p> + can be rewrited as + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">for</span><span class="special">(</span> <span class="identifier">BOOST_AUTO</span><span class="special">(</span><span class="identifier">iter</span><span class="special">,</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">name</span><span class="special">>().</span><span class="identifier">begin</span><span class="special">());</span> <span class="identifier">iter</span><span class="special">!=</span><span class="identifier">bm</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">name</span><span class="special">>().</span><span class="identifier">end</span><span class="special">();</span> <span class="special">++</span><span class="identifier">iter</span><span class="special">)</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">iter</span><span class="special">-></span><span class="identifier">first</span> <span class="special"><<</span> <span class="string">" --> "</span> <span class="special"><<</span> <span class="identifier">iter</span><span class="special">-></span><span class="identifier">second</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<span class="special">}</span> + +<span class="identifier">BOOST_AUTO</span><span class="special">(</span> <span class="identifier">iter</span><span class="special">,</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">number</span><span class="special">>().</span><span class="identifier">find</span><span class="special">(</span><span class="number">2</span><span class="special">)</span> <span class="special">);</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"2: "</span> <span class="special"><<</span> <span class="identifier">iter</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">name</span><span class="special">>();</span> +</pre> +<p> + </p> +<p> + <a href="../../../../example/bimap_and_boost/typeof.cpp" target="_top">Go to source code</a> + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_xpressive"></a><a class="link" href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_xpressive" title="Boost.Xpressive">Boost.Xpressive</a> +</h4></div></div></div> +<p> + Using Boost.Xpressive we can parse a file and insert the relations in a + bimap in the same step. It is just amazing the power of four lines of code. + Here is an example (it is just beatifull) + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> + +<span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">rel_str</span><span class="special">(</span><span class="string">"one <--> 1 two <--> 2 three <--> 3"</span><span class="special">);</span> + +<span class="identifier">sregex</span> <span class="identifier">rel</span> <span class="special">=</span> <span class="special">(</span> <span class="special">(</span><span class="identifier">s1</span><span class="special">=</span> <span class="special">+</span><span class="identifier">_w</span><span class="special">)</span> <span class="special">>></span> <span class="string">" <--> "</span> <span class="special">>></span> <span class="special">(</span><span class="identifier">s2</span><span class="special">=</span> <span class="special">+</span><span class="identifier">_d</span><span class="special">)</span> <span class="special">)</span> +<span class="special">[</span> + <span class="identifier">xp</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span><span class="identifier">bm</span><span class="special">)->*</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">xp</span><span class="special">::</span><span class="identifier">construct</span><span class="special"><</span><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">>(</span><span class="identifier">s1</span><span class="special">,</span> <span class="identifier">as</span><span class="special"><</span><span class="keyword">int</span><span class="special">>(</span><span class="identifier">s2</span><span class="special">))</span> <span class="special">)</span> +<span class="special">];</span> + +<span class="identifier">sregex</span> <span class="identifier">relations</span> <span class="special">=</span> <span class="identifier">rel</span> <span class="special">>></span> <span class="special">*(+</span><span class="identifier">_s</span> <span class="special">>></span> <span class="identifier">rel</span><span class="special">);</span> + +<span class="identifier">regex_match</span><span class="special">(</span><span class="identifier">rel_str</span><span class="special">,</span> <span class="identifier">relations</span><span class="special">);</span> + +<span class="identifier">assert</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special">==</span> <span class="number">3</span> <span class="special">);</span> +</pre> +<p> + </p> +<p> + <a href="../../../../example/bimap_and_boost/xpressive.cpp" target="_top">Go to source code</a> + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_property_map"></a><a class="link" href="boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_property_map" title="Boost.Property_map">Boost.Property_map</a> +</h4></div></div></div> +<p> + The Boost Property Map Library consists mainly of interface specifications + in the form of concepts (similar to the iterator concepts in the STL). + These interface specifications are intended for use by implementers of + generic libraries in communicating requirements on template parameters + to their users. In particular, the Boost Property Map concepts define a + general purpose interface for mapping key objects to corresponding value + objects, thereby hiding the details of how the mapping is implemented from + algorithms. + </p> +<p> + The need for the property map interface came from the Boost Graph Library + (BGL), which contains many examples of algorithms that use the property + map concepts to specify their interface. For an example, note the ColorMap + template parameter of the breadth_first_search. In addition, the BGL contains + many examples of concrete types that implement the property map interface. + The adjacency_list class implements property maps for accessing objects + (properties) that are attached to vertices and edges of the graph. + </p> +<p> + The counterparts of two of the views of Boost.Bimap map, the <code class="computeroutput"><span class="identifier">set</span></code> and <code class="computeroutput"><span class="identifier">unordered_set</span></code>, + are read-write property maps. In order to use these, you need to include + one of the following headers: + </p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">property_map</span><span class="special">/</span><span class="identifier">set_support</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">property_map</span><span class="special">/</span><span class="identifier">unordered_set_support</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +</pre> +<p> + The following is adapted from the example in the Boost.PropertyMap documentation. + </p> +<p> + <a href="../../../../example/bimap_and_boost/property_map.cpp" target="_top">Go to source + code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">AddressMap</span><span class="special">></span> +<span class="keyword">void</span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">AddressMap</span> <span class="special">&</span> <span class="identifier">address_map</span><span class="special">)</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">property_traits</span><span class="special"><</span><span class="identifier">AddressMap</span><span class="special">>::</span><span class="identifier">value_type</span> <span class="identifier">value_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">property_traits</span><span class="special"><</span><span class="identifier">AddressMap</span><span class="special">>::</span><span class="identifier">key_type</span> <span class="identifier">key_type</span><span class="special">;</span> + + <span class="identifier">value_type</span> <span class="identifier">address</span><span class="special">;</span> + <span class="identifier">key_type</span> <span class="identifier">fred</span> <span class="special">=</span> <span class="string">"Fred"</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">get</span><span class="special">(</span><span class="identifier">address_map</span><span class="special">,</span> <span class="identifier">fred</span><span class="special">);</span> +<span class="special">}</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">multiset_of</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">></span> <span class="special">></span> <span class="identifier">Name2Address</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">Name2Address</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">location</span><span class="special">;</span> + + <span class="identifier">Name2Address</span> <span class="identifier">name2address</span><span class="special">;</span> + <span class="identifier">name2address</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">location</span><span class="special">(</span><span class="string">"Fred"</span><span class="special">,</span> <span class="string">"710 West 13th Street"</span><span class="special">)</span> <span class="special">);</span> + <span class="identifier">name2address</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">location</span><span class="special">(</span> <span class="string">"Joe"</span><span class="special">,</span> <span class="string">"710 West 13th Street"</span><span class="special">)</span> <span class="special">);</span> + + <span class="identifier">foo</span><span class="special">(</span> <span class="identifier">name2address</span><span class="special">.</span><span class="identifier">left</span> <span class="special">);</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../bimap_and_boost.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bimap_and_boost.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="dependencies.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/bimap_and_boost/dependencies.html b/libs/bimap/doc/html/boost_bimap/bimap_and_boost/dependencies.html new file mode 100644 index 0000000000..3d9e598c36 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/bimap_and_boost/dependencies.html @@ -0,0 +1,417 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Dependencies</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../bimap_and_boost.html" title="Bimap and Boost"> +<link rel="prev" href="boost_libraries_that_work_well_with_boost_bimap.html" title="Boost Libraries that work well with Boost.Bimap"> +<link rel="next" href="../reference.html" title="Reference"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="boost_libraries_that_work_well_with_boost_bimap.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bimap_and_boost.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.bimap_and_boost.dependencies"></a><a class="link" href="dependencies.html" title="Dependencies">Dependencies</a> +</h3></div></div></div> +<p> + Boost.Bimap is built on top of several Boost libraries. The rationale behind + this decision is keeping the Boost code base small by reusing existent code. + The libraries used are well-established and have been tested extensively, + making this library easy to port since all the hard work has already been + done. The glue that holds everything together is Boost.MPL. Clearly Boost.MultiIndex + is the heart of this library. + </p> +<div class="table"> +<a name="id806919"></a><p class="title"><b>Table 1.4. Boost Libraries needed by Boost.Bimap</b></p> +<div class="table-contents"><table class="table" summary="Boost Libraries needed by Boost.Bimap"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Name + </p> + </th> +<th> + <p> + Description + </p> + </th> +<th> + <p> + author + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <a href="http://www.boost.org/libs/multi_index/doc/index.html" target="_top"><span class="bold"><strong>Boost.MultiIndex</strong></span></a> + </p> + </td> +<td> + <p> + Containers with multiple STL-compatible access interfaces + </p> + </td> +<td> + <p> + Joaquín M López Muñoz + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/libs/mpl/doc/index.html" target="_top"><span class="bold"><strong>Boost.MPL</strong></span></a> + </p> + </td> +<td> + <p> + Template metaprogramming framework of compile-time algorithms, + sequences and metafunction classes + </p> + </td> +<td> + <p> + Aleksey Gurtovoy + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/doc/html/boost_typetraits.html" target="_top"><span class="bold"><strong>Boost.TypeTraits</strong></span></a> + </p> + </td> +<td> + <p> + Templates for fundamental properties of types. + </p> + </td> +<td> + <p> + John Maddock, Steve Cleary + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/libs/utility/enable_if.html" target="_top"><span class="bold"><strong>Boost.enable_if</strong></span></a> + </p> + </td> +<td> + <p> + Selective inclusion of function template overloads + </p> + </td> +<td> + <p> + Jaakko Järvi, Jeremiah Willcock, Andrew Lumsdaine + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/libs/iterator/doc/index.html" target="_top"><span class="bold"><strong>Boost.Iterators</strong></span></a> + </p> + </td> +<td> + <p> + Iterator construction framework, adaptors, concepts, and more. + </p> + </td> +<td> + <p> + Dave Abrahams, Jeremy Siek, Thomas Witt + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/libs/utility/call_traits.htm" target="_top"><span class="bold"><strong>Boost.call_traits</strong></span></a> + </p> + </td> +<td> + <p> + Defines types for passing parameters. + </p> + </td> +<td> + <p> + John Maddock, Howard Hinnant + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/doc/html/boost_staticassert.html" target="_top"><span class="bold"><strong>Boost.StaticAssert</strong></span></a> + </p> + </td> +<td> + <p> + Static assertions (compile time assertions). + </p> + </td> +<td> + <p> + John Maddock + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="id807212"></a><p class="title"><b>Table 1.5. Optional Boost Libraries</b></p> +<div class="table-contents"><table class="table" summary="Optional Boost Libraries"> +<colgroup> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Name + </p> + </th> +<th> + <p> + Description + </p> + </th> +<th> + <p> + author + </p> + </th> +<th> + <p> + Purpose + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <a href="http://www.boost.org/libs/serialization/doc/index.html" target="_top"><span class="bold"><strong>Boost.Serialization</strong></span></a> + </p> + </td> +<td> + <p> + Serialization for persistence and marshalling + </p> + </td> +<td> + <p> + Robert Ramey + </p> + </td> +<td> + <p> + Serialization support for bimap containers and iterators + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/libs/assign/doc/index.html" target="_top"><span class="bold"><strong>Boost.Assign</strong></span></a> + </p> + </td> +<td> + <p> + Filling containers with constant or generated data has never been + easier + </p> + </td> +<td> + <p> + Thorsten Ottosen + </p> + </td> +<td> + <p> + Help to fill a bimap or views of it + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/doc/html/hash.html" target="_top"><span class="bold"><strong>Boost.Hash</strong></span></a> + </p> + </td> +<td> + <p> + A TR1 hash function object that can be extended to hash user defined + types + </p> + </td> +<td> + <p> + Daniel James + </p> + </td> +<td> + <p> + Default hashing function + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/doc/html/lambda.html" target="_top"><span class="bold"><strong>Boost.Lambda</strong></span></a> + </p> + </td> +<td> + <p> + Define small unnamed function objects at the actual call site, + and more + </p> + </td> +<td> + <p> + from Jaakko Järvi, Gary Powell + </p> + </td> +<td> + <p> + Functors for modify, range, lower_bound and upper_bound + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/doc/html/range.html" target="_top"><span class="bold"><strong>Boost.Range</strong></span></a> + </p> + </td> +<td> + <p> + A new infrastructure for generic algorithms that builds on top + of the new iterator concepts + </p> + </td> +<td> + <p> + Thorsten Ottosen + </p> + </td> +<td> + <p> + Range based algorithms + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="http://www.boost.org/doc/html/property_map.html" target="_top"><span class="bold"><strong>Boost.PropertyMap</strong></span></a> + </p> + </td> +<td> + <p> + Concepts defining interfaces which map key objects to value objects + </p> + </td> +<td> + <p> + Jeremy Siek + </p> + </td> +<td> + <p> + Integration with BGL + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="id807521"></a><p class="title"><b>Table 1.6. Additional Boost Libraries needed to run the test-suite</b></p> +<div class="table-contents"><table class="table" summary="Additional Boost Libraries needed to run the test-suite"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Name + </p> + </th> +<th> + <p> + Description + </p> + </th> +<th> + <p> + author + </p> + </th> +</tr></thead> +<tbody><tr> +<td> + <p> + <a href="http://www.boost.org/libs/test/doc/index.html" target="_top"><span class="bold"><strong>Boost.Test</strong></span></a> + </p> + </td> +<td> + <p> + Support for simple program testing, full unit testing, and for + program execution monitoring. + </p> + </td> +<td> + <p> + Gennadiy Rozental + </p> + </td> +</tr></tbody> +</table></div> +</div> +<br class="table-break"> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="boost_libraries_that_work_well_with_boost_bimap.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bimap_and_boost.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/compiler_specifics.html b/libs/bimap/doc/html/boost_bimap/compiler_specifics.html new file mode 100644 index 0000000000..ff3de083a1 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/compiler_specifics.html @@ -0,0 +1,366 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Compiler specifics</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="prev" href="reference/unconstrained_set_of_reference.html" title="unconstrained_set_of Reference"> +<link rel="next" href="performance.html" title="Performance"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> +<td align="center"><a href="../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="reference/unconstrained_set_of_reference.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="performance.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="boost_bimap.compiler_specifics"></a><a class="link" href="compiler_specifics.html" title="Compiler specifics">Compiler specifics</a> +</h2></div></div></div> +<div class="informaltable"><table class="table"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Compiler + </p> + </th> +<th> + <p> + OS Tested + </p> + </th> +<th> + <p> + State + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + GCC 3.3 + </p> + </td> +<td> + <p> + Linux + </p> + </td> +<td> + <p> + Supported + </p> + </td> +</tr> +<tr> +<td> + <p> + GCC 3.4 + </p> + </td> +<td> + <p> + Linux + </p> + </td> +<td> + <p> + Supported + </p> + </td> +</tr> +<tr> +<td> + <p> + GCC 4.0 + </p> + </td> +<td> + <p> + Linux, Mac + </p> + </td> +<td> + <p> + Supported + </p> + </td> +</tr> +<tr> +<td> + <p> + GCC 4.1 + </p> + </td> +<td> + <p> + Linux + </p> + </td> +<td> + <p> + Supported + </p> + </td> +</tr> +<tr> +<td> + <p> + GCC 4.2 + </p> + </td> +<td> + <p> + Linux + </p> + </td> +<td> + <p> + Supported + </p> + </td> +</tr> +<tr> +<td> + <p> + ICC 8.0 + </p> + </td> +<td> + <p> + Linux + </p> + </td> +<td> + <p> + Supported + </p> + </td> +</tr> +<tr> +<td> + <p> + ICC 9.0 + </p> + </td> +<td> + <p> + Linux + </p> + </td> +<td> + <p> + Supported + </p> + </td> +</tr> +<tr> +<td> + <p> + ICC 9.1 + </p> + </td> +<td> + <p> + Linux + </p> + </td> +<td> + <p> + Supported + </p> + </td> +</tr> +<tr> +<td> + <p> + GCC 4.2 + </p> + </td> +<td> + <p> + Linux + </p> + </td> +<td> + <p> + Supported + </p> + </td> +</tr> +<tr> +<td> + <p> + GCC 4.2 + </p> + </td> +<td> + <p> + Linux + </p> + </td> +<td> + <p> + Supported + </p> + </td> +</tr> +<tr> +<td> + <p> + VS 7.1 + </p> + </td> +<td> + <p> + Windows + </p> + </td> +<td> + <p> + Supported + </p> + </td> +</tr> +<tr> +<td> + <p> + VS 8.0 + </p> + </td> +<td> + <p> + Windows + </p> + </td> +<td> + <p> + Supported + </p> + </td> +</tr> +<tr> +<td> + <p> + ICC 7.1 + </p> + </td> +<td> + <p> + Windows + </p> + </td> +<td> + <p> + Not Supported + </p> + </td> +</tr> +<tr> +<td> + <p> + ICC 8.0 + </p> + </td> +<td> + <p> + Windows + </p> + </td> +<td> + <p> + Supported + </p> + </td> +</tr> +<tr> +<td> + <p> + ICC 9.1 + </p> + </td> +<td> + <p> + Windows + </p> + </td> +<td> + <p> + Supported + </p> + </td> +</tr> +<tr> +<td> + <p> + CW 8.3 + </p> + </td> +<td> + <p> + Windows + </p> + </td> +<td> + <p> + Not Supported + </p> + </td> +</tr> +</tbody> +</table></div> +<a name="boost_bimap.compiler_specifics.vs_7_1"></a><h3> +<a name="id866952"></a> + <a class="link" href="compiler_specifics.html#boost_bimap.compiler_specifics.vs_7_1">VS 7.1</a> + </h3> +<p> + If a .cpp file uses more than four differents bimaps the compiler will run + out of symbols and issue an internal compiler error. The official solution + in msdn is to split the .cpp in several files or upgrade your compiler. + </p> +<a name="boost_bimap.compiler_specifics.vs_8_0"></a><h3> +<a name="id866980"></a> + <a class="link" href="compiler_specifics.html#boost_bimap.compiler_specifics.vs_8_0">VS 8.0</a> + </h3> +<p> + VC++ 8.0 warns on usage of certain Standard Library and API functions that + can be cause buffer overruns or other possible security issues if misused. + See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx But + the wording of the warning is misleading and unsettling, there are no portable + alternative functions, and VC++ 8.0's own libraries use the functions in question. + In order to turn off the warnings add the followings defines at the begging + of your .cpp files: + </p> +<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">_CRT_SECURE_NO_DEPRECATE</span> +<span class="preprocessor">#define</span> <span class="identifier">_SCL_SECURE_NO_DEPRECATE</span> +</pre> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="reference/unconstrained_set_of_reference.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="performance.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/examples.html b/libs/bimap/doc/html/boost_bimap/examples.html new file mode 100644 index 0000000000..b94ba3aaa0 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/examples.html @@ -0,0 +1,446 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Examples</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="prev" href="performance.html" title="Performance"> +<link rel="next" href="examples/simple_bimap.html" title="Simple Bimap"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> +<td align="center"><a href="../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="performance.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="examples/simple_bimap.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="boost_bimap.examples"></a><a class="link" href="examples.html" title="Examples">Examples</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="examples.html#boost_bimap.examples.examples_list">Examples list</a></span></dt> +<dt><span class="section"><a href="examples/simple_bimap.html">Simple Bimap</a></span></dt> +<dt><span class="section"><a href="examples/mighty_bimap.html">Mighty Bimap</a></span></dt> +<dt><span class="section"><a href="examples/multiindex_to_bimap_path___bidirectional_map.html">MultiIndex + to Bimap Path - Bidirectional Map</a></span></dt> +<dt><span class="section"><a href="examples/multiindex_to_bimap_path___hashed_indices.html">MultiIndex + to Bimap Path - Hashed indices</a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.examples.examples_list"></a><a class="link" href="examples.html#boost_bimap.examples.examples_list" title="Examples list">Examples list</a> +</h3></div></div></div> +<p> + In the folder <a href="../../../example" target="_top">libs/bimap/example</a> you can + find all the examples used in bimap documentation. Here is a list of them: + </p> +<div class="table"> +<a name="id867089"></a><p class="title"><b>Table 1.7. Tutorial examples</b></p> +<div class="table-contents"><table class="table" summary="Tutorial examples"> +<colgroup> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Program + </p> + </th> +<th> + <p> + Description + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <a href="../../../example/simple_bimap.cpp" target="_top">simple_bimap.cpp </a> + </p> + </td> +<td> + <p> + Soccer world cup example + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/tagged_simple_bimap.cpp" target="_top">tagged_simple_bimap.cpp + </a> + </p> + </td> +<td> + <p> + Soccer world cup example using user defined names + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/step_by_step.cpp" target="_top">step_by_step.cpp </a> + </p> + </td> +<td> + <p> + Basic example of the three views of bimap + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/population_bimap.cpp" target="_top">population_bimap.cpp + </a> + </p> + </td> +<td> + <p> + Countries populations, using <code class="computeroutput"><span class="identifier">unordered_set_of</span></code> + and <code class="computeroutput"><span class="identifier">multiset_of</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/repetitions_counter.cpp" target="_top">repetitions_counter.cpp + </a> + </p> + </td> +<td> + <p> + Word repetitions counter, using <code class="computeroutput"><span class="identifier">unordered_set_of</span></code> + and <code class="computeroutput"><span class="identifier">list_of</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/mighty_bimap.cpp" target="_top">mighty_bimap.cpp </a> + </p> + </td> +<td> + <p> + Dictionary using <code class="computeroutput"><span class="identifier">list_of_relation</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/user_defined_names.cpp" target="_top">user_defined_names.cpp + </a> + </p> + </td> +<td> + <p> + Equivalence between code with tagged and untagged code + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/standard_map_comparison.cpp" target="_top">standard_map_comparison.cpp + </a> + </p> + </td> +<td> + <p> + Comparison between standard maps and bimap map views + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/at_function_examples.cpp" target="_top">at_function_examples.cpp + </a> + </p> + </td> +<td> + <p> + Functions <code class="computeroutput"><span class="identifier">at</span><span class="special">(</span><span class="identifier">key</span><span class="special">)</span></code> + and <code class="computeroutput"><span class="keyword">operator</span><span class="special">[](</span><span class="identifier">key</span><span class="special">)</span></code> + examples + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/tutorial_modify_and_replace.cpp" target="_top">tutorial_modify_and_replace.cpp + </a> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">modify</span></code> and <code class="computeroutput"><span class="identifier">replace</span></code> examples + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/tutorial_range.cpp" target="_top">tutorial_range.cpp + </a> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">range</span><span class="special">()</span></code> + tutorial + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/tutorial_info_hook.cpp" target="_top">tutorial_info_hook.cpp + </a> + </p> + </td> +<td> + <p> + Additional information hooking + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/unconstrained_collection.cpp" target="_top">unconstrained_collection.cpp + </a> + </p> + </td> +<td> + <p> + Using <code class="computeroutput"><span class="identifier">unconstrained_set_of</span></code> + collection type + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="id867580"></a><p class="title"><b>Table 1.8. Bimap and Boost examples</b></p> +<div class="table-contents"><table class="table" summary="Bimap and Boost examples"> +<colgroup> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Program + </p> + </th> +<th> + <p> + Description + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <a href="../../../example/bimap_and_boost/assign.cpp" target="_top">assign.cpp + </a> + </p> + </td> +<td> + <p> + Bimap and Boost.Assign: Methods to insert elements + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/bimap_and_boost/lambda.cpp" target="_top">lambda.cpp + </a> + </p> + </td> +<td> + <p> + Bimap and Boost.Lambda: new lambda placeholders + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/bimap_and_boost/property_map.cpp" target="_top">property_map.cpp + </a> + </p> + </td> +<td> + <p> + Bimap and Boost.PropertyMap: PropertyMap support + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/bimap_and_boost/range.cpp" target="_top">range.cpp + </a> + </p> + </td> +<td> + <p> + Bimap and Boost.Range: Using bimaps in the new range framework + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/bimap_and_boost/foreach.cpp" target="_top">foreach.cpp + </a> + </p> + </td> +<td> + <p> + Bimap and Boost.Foreach: Iterating over bimaps + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/bimap_and_boost/typeof.cpp" target="_top">typeof.cpp + </a> + </p> + </td> +<td> + <p> + Bimap and Boost.Typeof: using BOOST_AUTO while we wait for C++0x + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/bimap_and_boost/xpressive.cpp" target="_top">xpressive.cpp + </a> + </p> + </td> +<td> + <p> + Bimap and Boost.Xpressive: Inserting elements in a bimap + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/bimap_and_boost/serialization.cpp" target="_top">serialization.cpp: + </a> + </p> + </td> +<td> + <p> + Bimap and Boost.Serialization: Load and save bimaps and iterators + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="id867811"></a><p class="title"><b>Table 1.9. Boost.MultiIndex to Boost.Bimap path examples</b></p> +<div class="table-contents"><table class="table" summary="Boost.MultiIndex to Boost.Bimap path examples"> +<colgroup> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Program + </p> + </th> +<th> + <p> + Description + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <a href="../../../example/mi_to_b_path/bidirectional_map.cpp" target="_top">bidirectional_map.cpp + </a> + </p> + </td> +<td> + <p> + Boost.MultiIndex to Boost.Bimap path example + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/mi_to_b_path/hashed_indices.cpp" target="_top">hashed_indices.cpp + </a> + </p> + </td> +<td> + <p> + Boost.MultiIndex to Boost.Bimap path example + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../example/mi_to_b_path/tagged_bidirectional_map.cpp" target="_top">tagged_bidirectional_map.cpp + </a> + </p> + </td> +<td> + <p> + Boost.MultiIndex to Boost.Bimap path example + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="performance.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="examples/simple_bimap.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/examples/mighty_bimap.html b/libs/bimap/doc/html/boost_bimap/examples/mighty_bimap.html new file mode 100644 index 0000000000..9ec83ce80c --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/examples/mighty_bimap.html @@ -0,0 +1,137 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Mighty Bimap</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../examples.html" title="Examples"> +<link rel="prev" href="simple_bimap.html" title="Simple Bimap"> +<link rel="next" href="multiindex_to_bimap_path___bidirectional_map.html" title="MultiIndex to Bimap Path - Bidirectional Map"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="simple_bimap.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="multiindex_to_bimap_path___bidirectional_map.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.examples.mighty_bimap"></a><a class="link" href="mighty_bimap.html" title="Mighty Bimap">Mighty Bimap</a> +</h3></div></div></div> +<p> + This is the translator example from the tutorial. In this example the collection + type of relation is changed to allow the iteration of the container. + </p> +<p> + <a href="../../../../example/mighty_bimap.cpp" target="_top">Go to source code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">string</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">list_of</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">unordered_set_of</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">struct</span> <span class="identifier">english</span> <span class="special">{};</span> +<span class="keyword">struct</span> <span class="identifier">spanish</span> <span class="special">{};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bimaps</span><span class="special">;</span> + + <span class="keyword">typedef</span> <span class="identifier">bimap</span> + <span class="special"><</span> + <span class="identifier">unordered_set_of</span><span class="special"><</span> <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">spanish</span> <span class="special">></span> <span class="special">>,</span> + <span class="identifier">unordered_set_of</span><span class="special"><</span> <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">english</span> <span class="special">></span> <span class="special">>,</span> + <span class="identifier">list_of_relation</span> + + <span class="special">></span> <span class="identifier">translator</span><span class="special">;</span> + + <span class="identifier">translator</span> <span class="identifier">trans</span><span class="special">;</span> + + <span class="comment">// We have to use `push_back` because the collection of relations is +</span> <span class="comment">// a `list_of_relation` +</span> + <span class="identifier">trans</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span> <span class="identifier">translator</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"hola"</span> <span class="special">,</span><span class="string">"hello"</span> <span class="special">)</span> <span class="special">);</span> + <span class="identifier">trans</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span> <span class="identifier">translator</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"adios"</span> <span class="special">,</span><span class="string">"goodbye"</span> <span class="special">)</span> <span class="special">);</span> + <span class="identifier">trans</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span> <span class="identifier">translator</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"rosa"</span> <span class="special">,</span><span class="string">"rose"</span> <span class="special">)</span> <span class="special">);</span> + <span class="identifier">trans</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span> <span class="identifier">translator</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"mesa"</span> <span class="special">,</span><span class="string">"table"</span> <span class="special">)</span> <span class="special">);</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"enter a word"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">word</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">getline</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cin</span><span class="special">,</span><span class="identifier">word</span><span class="special">);</span> + + <span class="comment">// Search the queried word on the from index (Spanish) +</span> + <span class="identifier">translator</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">spanish</span><span class="special">>::</span><span class="identifier">const_iterator</span> <span class="identifier">is</span> + <span class="special">=</span> <span class="identifier">trans</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">spanish</span><span class="special">>().</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">word</span><span class="special">);</span> + + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">is</span> <span class="special">!=</span> <span class="identifier">trans</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">spanish</span><span class="special">>().</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">word</span> <span class="special"><<</span> <span class="string">" is said "</span> + <span class="special"><<</span> <span class="identifier">is</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">english</span><span class="special">>()</span> + <span class="special"><<</span> <span class="string">" in English"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + <span class="keyword">else</span> + <span class="special">{</span> + <span class="comment">// Word not found in Spanish, try our luck in English +</span> + <span class="identifier">translator</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">english</span><span class="special">>::</span><span class="identifier">const_iterator</span> <span class="identifier">ie</span> + <span class="special">=</span> <span class="identifier">trans</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">english</span><span class="special">>().</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">word</span><span class="special">);</span> + + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">ie</span> <span class="special">!=</span> <span class="identifier">trans</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">english</span><span class="special">>().</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">word</span> <span class="special"><<</span> <span class="string">" is said "</span> + <span class="special"><<</span> <span class="identifier">ie</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">spanish</span><span class="special">>()</span> + <span class="special"><<</span> <span class="string">" in Spanish"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + <span class="keyword">else</span> + <span class="special">{</span> + <span class="comment">// Word not found, show the possible translations +</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"No such word in the dictionary"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"These are the possible translations"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + + <span class="keyword">for</span><span class="special">(</span> <span class="identifier">translator</span><span class="special">::</span><span class="identifier">const_iterator</span> + <span class="identifier">i</span> <span class="special">=</span> <span class="identifier">trans</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> + <span class="identifier">i_end</span> <span class="special">=</span> <span class="identifier">trans</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> + + <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">i_end</span> <span class="special">;</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">spanish</span><span class="special">>()</span> + <span class="special"><<</span> <span class="string">" <---> "</span> + <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">english</span><span class="special">>()</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + <span class="special">}</span> + <span class="special">}</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="simple_bimap.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="multiindex_to_bimap_path___bidirectional_map.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/examples/multiindex_to_bimap_path___bidirectional_map.html b/libs/bimap/doc/html/boost_bimap/examples/multiindex_to_bimap_path___bidirectional_map.html new file mode 100644 index 0000000000..e5623d6c3d --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/examples/multiindex_to_bimap_path___bidirectional_map.html @@ -0,0 +1,332 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>MultiIndex to Bimap Path - Bidirectional Map</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../examples.html" title="Examples"> +<link rel="prev" href="mighty_bimap.html" title="Mighty Bimap"> +<link rel="next" href="multiindex_to_bimap_path___hashed_indices.html" title="MultiIndex to Bimap Path - Hashed indices"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="mighty_bimap.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="multiindex_to_bimap_path___hashed_indices.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.examples.multiindex_to_bimap_path___bidirectional_map"></a><a class="link" href="multiindex_to_bimap_path___bidirectional_map.html" title="MultiIndex to Bimap Path - Bidirectional Map">MultiIndex + to Bimap Path - Bidirectional Map</a> +</h3></div></div></div> +<p> + This is example 4 in Boost.MultiIndex documentation. + </p> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + This example shows how to construct a bidirectional map with multi_index_container. + By a bidirectional map we mean a container of elements of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">FromType</span><span class="special">,</span><span class="keyword">const</span> <span class="identifier">ToType</span><span class="special">></span></code> such that no two elements exists with + the same first or second value (<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span></code> only + guarantees uniqueness of the first member). Fast look-up is provided for + both keys. The program features a tiny Spanish-English dictionary with on-line + query of words in both languages. + </p> +</div> +<a name="boost_bimap.examples.multiindex_to_bimap_path___bidirectional_map.boost_multiindex"></a><h5> +<a name="id872643"></a> + <a class="link" href="multiindex_to_bimap_path___bidirectional_map.html#boost_bimap.examples.multiindex_to_bimap_path___bidirectional_map.boost_multiindex">Boost.MultiIndex</a> + </h5> +<p> + <a href="../../../../example/mi_to_b_path/mi_bidirectional_map.cpp" target="_top">Go to source + code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">tokenizer</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multi_index_container</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multi_index</span><span class="special">/</span><span class="identifier">key_extractors</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multi_index</span><span class="special">/</span><span class="identifier">ordered_index</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">;</span> +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">multi_index</span><span class="special">;</span> + +<span class="comment">// tags for accessing both sides of a bidirectional map +</span> +<span class="keyword">struct</span> <span class="identifier">from</span> <span class="special">{};</span> +<span class="keyword">struct</span> <span class="identifier">to</span> <span class="special">{};</span> + +<span class="comment">// The class template bidirectional_map wraps the specification +</span><span class="comment">// of a bidirectional map based on multi_index_container. +</span> +<span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">FromType</span><span class="special">,</span><span class="keyword">typename</span> <span class="identifier">ToType</span><span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">bidirectional_map</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">FromType</span><span class="special">,</span><span class="identifier">ToType</span><span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> + + <span class="keyword">typedef</span> <span class="identifier">multi_index_container</span><span class="special"><</span> + <span class="identifier">value_type</span><span class="special">,</span> + <span class="identifier">indexed_by</span> + <span class="special"><</span> + <span class="identifier">ordered_unique</span> + <span class="special"><</span> + <span class="identifier">tag</span><span class="special"><</span><span class="identifier">from</span><span class="special">>,</span> <span class="identifier">member</span><span class="special"><</span><span class="identifier">value_type</span><span class="special">,</span><span class="identifier">FromType</span><span class="special">,&</span><span class="identifier">value_type</span><span class="special">::</span><span class="identifier">first</span><span class="special">></span> + <span class="special">>,</span> + <span class="identifier">ordered_unique</span> + <span class="special"><</span> + <span class="identifier">tag</span><span class="special"><</span><span class="identifier">to</span><span class="special">>,</span> <span class="identifier">member</span><span class="special"><</span><span class="identifier">value_type</span><span class="special">,</span><span class="identifier">ToType</span><span class="special">,&</span><span class="identifier">value_type</span><span class="special">::</span><span class="identifier">second</span><span class="special">></span> + <span class="special">></span> + <span class="special">></span> + + <span class="special">></span> <span class="identifier">type</span><span class="special">;</span> + +<span class="special">};</span> + +<span class="comment">// A dictionary is a bidirectional map from strings to strings +</span> +<span class="keyword">typedef</span> <span class="identifier">bidirectional_map</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">dictionary</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="identifier">dictionary</span> <span class="identifier">d</span><span class="special">;</span> + + <span class="comment">// Fill up our microdictionary. +</span> <span class="comment">// first members Spanish, second members English. +</span> + <span class="identifier">d</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">dictionary</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"hola"</span><span class="special">,</span><span class="string">"hello"</span><span class="special">));</span> + <span class="identifier">d</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">dictionary</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"adios"</span><span class="special">,</span><span class="string">"goodbye"</span><span class="special">));</span> + <span class="identifier">d</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">dictionary</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"rosa"</span><span class="special">,</span><span class="string">"rose"</span><span class="special">));</span> + <span class="identifier">d</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">dictionary</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"mesa"</span><span class="special">,</span><span class="string">"table"</span><span class="special">));</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"enter a word"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">word</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">getline</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cin</span><span class="special">,</span><span class="identifier">word</span><span class="special">);</span> + + <span class="comment">// search the queried word on the from index (Spanish) +</span> + <span class="identifier">dictionary</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">d</span><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="identifier">from</span><span class="special">>().</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">word</span><span class="special">);</span> + + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">d</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> + <span class="special">{</span> + <span class="comment">// the second part of the element is the equivalent in English +</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">word</span> <span class="special"><<</span> <span class="string">" is said "</span> + <span class="special"><<</span> <span class="identifier">it</span><span class="special">-></span><span class="identifier">second</span> <span class="special"><<</span> <span class="string">" in English"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + <span class="keyword">else</span> + <span class="special">{</span> + <span class="comment">// word not found in Spanish, try our luck in English +</span> + <span class="identifier">dictionary</span><span class="special">::</span><span class="identifier">index_iterator</span><span class="special"><</span><span class="identifier">to</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">it2</span> <span class="special">=</span> <span class="identifier">d</span><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="identifier">to</span><span class="special">>().</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">word</span><span class="special">);</span> + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">it2</span> <span class="special">!=</span> <span class="identifier">d</span><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="identifier">to</span><span class="special">>().</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">word</span> <span class="special"><<</span> <span class="string">" is said "</span> + <span class="special"><<</span> <span class="identifier">it2</span><span class="special">-></span><span class="identifier">first</span> <span class="special"><<</span> <span class="string">" in Spanish"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + <span class="keyword">else</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"No such word in the dictionary"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + <span class="special">}</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<a name="boost_bimap.examples.multiindex_to_bimap_path___bidirectional_map.boost_bimap"></a><h5> +<a name="id874624"></a> + <a class="link" href="multiindex_to_bimap_path___bidirectional_map.html#boost_bimap.examples.multiindex_to_bimap_path___bidirectional_map.boost_bimap">Boost.Bimap</a> + </h5> +<p> + <a href="../../../../example/mi_to_b_path/bidirectional_map.cpp" target="_top">Go to source + code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">tokenizer</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bimaps</span><span class="special">;</span> + +<span class="comment">// A dictionary is a bidirectional map from strings to strings +</span> +<span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">></span> <span class="identifier">dictionary</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">dictionary</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">translation</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="identifier">dictionary</span> <span class="identifier">d</span><span class="special">;</span> + + <span class="comment">// Fill up our microdictionary. +</span> <span class="comment">// first members Spanish, second members English. +</span> + <span class="identifier">d</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">translation</span><span class="special">(</span><span class="string">"hola"</span> <span class="special">,</span><span class="string">"hello"</span> <span class="special">));</span> + <span class="identifier">d</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">translation</span><span class="special">(</span><span class="string">"adios"</span><span class="special">,</span><span class="string">"goodbye"</span><span class="special">));</span> + <span class="identifier">d</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">translation</span><span class="special">(</span><span class="string">"rosa"</span> <span class="special">,</span><span class="string">"rose"</span> <span class="special">));</span> + <span class="identifier">d</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">translation</span><span class="special">(</span><span class="string">"mesa"</span> <span class="special">,</span><span class="string">"table"</span> <span class="special">));</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"enter a word"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">word</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">getline</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cin</span><span class="special">,</span><span class="identifier">word</span><span class="special">);</span> + + <span class="comment">// search the queried word on the from index (Spanish) +</span> + <span class="identifier">dictionary</span><span class="special">::</span><span class="identifier">left_const_iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">d</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">word</span><span class="special">);</span> + + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">d</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> + <span class="special">{</span> + <span class="comment">// the second part of the element is the equivalent in English +</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">word</span> <span class="special"><<</span> <span class="string">" is said "</span> + <span class="special"><<</span> <span class="identifier">it</span><span class="special">-></span><span class="identifier">second</span> <a class="co" name="boost_bimap23co" href="multiindex_to_bimap_path___bidirectional_map.html#boost_bimap23"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> + <span class="special"><<</span> <span class="string">" in English"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + <span class="keyword">else</span> + <span class="special">{</span> + <span class="comment">// word not found in Spanish, try our luck in English +</span> + <span class="identifier">dictionary</span><span class="special">::</span><span class="identifier">right_const_iterator</span> <span class="identifier">it2</span> <span class="special">=</span> <span class="identifier">d</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">word</span><span class="special">);</span> + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">it2</span> <span class="special">!=</span> <span class="identifier">d</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">word</span> <span class="special"><<</span> <span class="string">" is said "</span> + <span class="special"><<</span> <span class="identifier">it2</span><span class="special">-></span><span class="identifier">second</span> <a class="co" name="boost_bimap24co" href="multiindex_to_bimap_path___bidirectional_map.html#boost_bimap24"><img src="../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> + <span class="special"><<</span> <span class="string">" in Spanish"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + <span class="keyword">else</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"No such word in the dictionary"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + <span class="special">}</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<div class="calloutlist"><table border="0" summary="Callout list"> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap23"></a><a href="#boost_bimap23co"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> +<td valign="top" align="left"><p> + <code class="computeroutput"><span class="identifier">it</span></code> is an iterator of + the left view, so <code class="computeroutput"><span class="identifier">it</span><span class="special">-></span><span class="identifier">second</span></code> + refers to the right element of the relation, the word in english + </p></td> +</tr> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap24"></a><a href="#boost_bimap24co"><img src="../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> </p></td> +<td valign="top" align="left"><p> + <code class="computeroutput"><span class="identifier">it2</span></code> is an iterator of + the right view, so <code class="computeroutput"><span class="identifier">it2</span><span class="special">-></span><span class="identifier">second</span></code> + refers to the left element of the relation, the word in spanish + </p></td> +</tr> +</table></div> +<p> + Or better, using tags... + </p> +<p> + <a href="../../../../example/mi_to_b_path/tagged_bidirectional_map.cpp" target="_top">Go to + source code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> + +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bimaps</span><span class="special">;</span> + +<span class="comment">// tags +</span> +<span class="keyword">struct</span> <span class="identifier">spanish</span> <span class="special">{};</span> +<span class="keyword">struct</span> <span class="identifier">english</span> <span class="special">{};</span> + +<span class="comment">// A dictionary is a bidirectional map from strings to strings +</span> +<span class="keyword">typedef</span> <span class="identifier">bimap</span> +<span class="special"><</span> + <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span><span class="identifier">spanish</span> <span class="special">>,</span> <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span><span class="identifier">english</span> <span class="special">></span> + +<span class="special">></span> <span class="identifier">dictionary</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">dictionary</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">translation</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="identifier">dictionary</span> <span class="identifier">d</span><span class="special">;</span> + + <span class="comment">// Fill up our microdictionary. +</span> <span class="comment">// first members Spanish, second members English. +</span> + <span class="identifier">d</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">translation</span><span class="special">(</span><span class="string">"hola"</span> <span class="special">,</span><span class="string">"hello"</span> <span class="special">));</span> + <span class="identifier">d</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">translation</span><span class="special">(</span><span class="string">"adios"</span><span class="special">,</span><span class="string">"goodbye"</span><span class="special">));</span> + <span class="identifier">d</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">translation</span><span class="special">(</span><span class="string">"rosa"</span> <span class="special">,</span><span class="string">"rose"</span> <span class="special">));</span> + <span class="identifier">d</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">translation</span><span class="special">(</span><span class="string">"mesa"</span> <span class="special">,</span><span class="string">"table"</span> <span class="special">));</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"enter a word"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">word</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">getline</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cin</span><span class="special">,</span><span class="identifier">word</span><span class="special">);</span> + + <span class="comment">// search the queried word on the from index (Spanish) */ +</span> + <span class="identifier">dictionary</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">spanish</span><span class="special">>::</span><span class="identifier">const_iterator</span> <span class="identifier">it</span> <span class="special">=</span> + <span class="identifier">d</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">spanish</span><span class="special">>().</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">word</span><span class="special">);</span> + + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">d</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">spanish</span><span class="special">>().</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">word</span> <span class="special"><<</span> <span class="string">" is said "</span> + <span class="special"><<</span> <span class="identifier">it</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">english</span><span class="special">>()</span> <span class="special"><<</span> <span class="string">" in English"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + <span class="keyword">else</span> + <span class="special">{</span> + <span class="comment">// word not found in Spanish, try our luck in English +</span> + <span class="identifier">dictionary</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">english</span><span class="special">>::</span><span class="identifier">const_iterator</span> <span class="identifier">it2</span> <span class="special">=</span> + <span class="identifier">d</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">english</span><span class="special">>().</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">word</span><span class="special">);</span> + + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">it2</span> <span class="special">!=</span> <span class="identifier">d</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">english</span><span class="special">>().</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">word</span> <span class="special"><<</span> <span class="string">" is said "</span> + <span class="special"><<</span> <span class="identifier">it2</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">spanish</span><span class="special">>()</span> <span class="special"><<</span> <span class="string">" in Spanish"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + <span class="keyword">else</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"No such word in the dictionary"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + <span class="special">}</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="mighty_bimap.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="multiindex_to_bimap_path___hashed_indices.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/examples/multiindex_to_bimap_path___hashed_indices.html b/libs/bimap/doc/html/boost_bimap/examples/multiindex_to_bimap_path___hashed_indices.html new file mode 100644 index 0000000000..98cefab211 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/examples/multiindex_to_bimap_path___hashed_indices.html @@ -0,0 +1,238 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>MultiIndex to Bimap Path - Hashed indices</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../examples.html" title="Examples"> +<link rel="prev" href="multiindex_to_bimap_path___bidirectional_map.html" title="MultiIndex to Bimap Path - Bidirectional Map"> +<link rel="next" href="../test_suite.html" title="Test suite"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="multiindex_to_bimap_path___bidirectional_map.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../test_suite.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.examples.multiindex_to_bimap_path___hashed_indices"></a><a class="link" href="multiindex_to_bimap_path___hashed_indices.html" title="MultiIndex to Bimap Path - Hashed indices">MultiIndex + to Bimap Path - Hashed indices</a> +</h3></div></div></div> +<p> + This is example 8 of Boost.MultiIndex. + </p> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + Hashed indices can be used as an alternative to ordered indices when fast + look-up is needed and sorting information is of no interest. The example + features a word counter where duplicate entries are checked by means of a + hashed index. + </p> +</div> +<a name="boost_bimap.examples.multiindex_to_bimap_path___hashed_indices.boost_multiindex"></a><h5> +<a name="id877266"></a> + <a class="link" href="multiindex_to_bimap_path___hashed_indices.html#boost_bimap.examples.multiindex_to_bimap_path___hashed_indices.boost_multiindex">Boost.MultiIndex</a> + </h5> +<p> + <a href="../../../../example/mi_to_b_path/mi_hashed_indices.cpp" target="_top">Go to source + code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iomanip</span><span class="special">></span> + +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">tokenizer</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multi_index_container</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multi_index</span><span class="special">/</span><span class="identifier">key_extractors</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multi_index</span><span class="special">/</span><span class="identifier">ordered_index</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multi_index</span><span class="special">/</span><span class="identifier">hashed_index</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">lambda</span><span class="special">/</span><span class="identifier">lambda</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">multi_index</span><span class="special">;</span> +<span class="keyword">namespace</span> <span class="identifier">bl</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">lambda</span><span class="special">;</span> + +<span class="comment">// word_counter keeps the ocurrences of words inserted. A hashed +</span><span class="comment">// index allows for fast checking of preexisting entries. +</span> +<span class="keyword">struct</span> <span class="identifier">word_counter_entry</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">word</span><span class="special">;</span> + <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">occurrences</span><span class="special">;</span> + + <span class="identifier">word_counter_entry</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">word_</span> <span class="special">)</span> <span class="special">:</span> <span class="identifier">word</span><span class="special">(</span><span class="identifier">word_</span><span class="special">),</span> <span class="identifier">occurrences</span><span class="special">(</span><span class="number">0</span><span class="special">)</span> <span class="special">{}</span> +<span class="special">};</span> + +<span class="keyword">typedef</span> <span class="identifier">multi_index_container</span> +<span class="special"><</span> + <span class="identifier">word_counter_entry</span><span class="special">,</span> + <span class="identifier">indexed_by</span> + <span class="special"><</span> + <span class="identifier">ordered_non_unique</span> + <span class="special"><</span> + <span class="identifier">BOOST_MULTI_INDEX_MEMBER</span><span class="special">(</span> + <span class="identifier">word_counter_entry</span><span class="special">,</span><span class="keyword">unsigned</span> <span class="keyword">int</span><span class="special">,</span><span class="identifier">occurrences</span><span class="special">),</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special"><</span><span class="keyword">unsigned</span> <span class="keyword">int</span><span class="special">></span> + <span class="special">>,</span> + <span class="identifier">hashed_unique</span> + <span class="special"><</span> + <span class="identifier">BOOST_MULTI_INDEX_MEMBER</span><span class="special">(</span><span class="identifier">word_counter_entry</span><span class="special">,</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span><span class="identifier">word</span><span class="special">)</span> + <span class="special">></span> + <span class="special">></span> + +<span class="special">></span> <span class="identifier">word_counter</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">tokenizer</span><span class="special"><</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">char_separator</span><span class="special"><</span><span class="keyword">char</span><span class="special">></span> <span class="special">></span> <span class="identifier">text_tokenizer</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">text</span><span class="special">=</span> + <span class="string">"En un lugar de la Mancha, de cuyo nombre no quiero acordarme... "</span> + <span class="string">"...snip..."</span> + <span class="string">"...no se salga un punto de la verdad."</span><span class="special">;</span> + + <span class="comment">// feed the text into the container +</span> + <span class="identifier">word_counter</span> <span class="identifier">wc</span><span class="special">;</span> + <span class="identifier">text_tokenizer</span> <span class="identifier">tok</span><span class="special">(</span><span class="identifier">text</span><span class="special">,</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">char_separator</span><span class="special"><</span><span class="keyword">char</span><span class="special">>(</span><span class="string">" \t\n.,;:!?'\"-"</span><span class="special">));</span> + <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">total_occurrences</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> + + <span class="keyword">for</span><span class="special">(</span> <span class="identifier">text_tokenizer</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">tok</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">it_end</span> <span class="special">=</span> <span class="identifier">tok</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> + <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">it_end</span> <span class="special">;</span> <span class="special">++</span><span class="identifier">it</span> <span class="special">)</span> + <span class="special">{</span> + <span class="special">++</span><span class="identifier">total_occurrences</span><span class="special">;</span> + <span class="identifier">word_counter</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">wit</span> <span class="special">=</span> <span class="identifier">wc</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it</span><span class="special">).</span><span class="identifier">first</span><span class="special">;</span> + <span class="identifier">wc</span><span class="special">.</span><span class="identifier">modify_key</span><span class="special">(</span> <span class="identifier">wit</span><span class="special">,</span> <span class="special">++</span> <span class="identifier">bl</span><span class="special">::</span><span class="identifier">_1</span> <span class="special">);</span> + <span class="special">}</span> + + <span class="comment">// list words by frequency of appearance +</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">fixed</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">setprecision</span><span class="special">(</span><span class="number">2</span><span class="special">);</span> + + <span class="keyword">for</span><span class="special">(</span> <span class="identifier">word_counter</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">wit</span> <span class="special">=</span> <span class="identifier">wc</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">wit_end</span><span class="special">=</span><span class="identifier">wc</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> + <span class="identifier">wit</span> <span class="special">!=</span> <span class="identifier">wit_end</span><span class="special">;</span> <span class="special">++</span><span class="identifier">wit</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">setw</span><span class="special">(</span><span class="number">11</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">wit</span><span class="special">-></span><span class="identifier">word</span> <span class="special"><<</span> <span class="string">": "</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">setw</span><span class="special">(</span><span class="number">5</span><span class="special">)</span> + <span class="special"><<</span> <span class="number">100.0</span> <span class="special">*</span> <span class="identifier">wit</span><span class="special">-></span><span class="identifier">occurrences</span> <span class="special">/</span> <span class="identifier">total_occurrences</span> <span class="special"><<</span> <span class="string">"%"</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<a name="boost_bimap.examples.multiindex_to_bimap_path___hashed_indices.boost_bimap"></a><h5> +<a name="id878963"></a> + <a class="link" href="multiindex_to_bimap_path___hashed_indices.html#boost_bimap.examples.multiindex_to_bimap_path___hashed_indices.boost_bimap">Boost.Bimap</a> + </h5> +<p> + <a href="../../../../example/mi_to_b_path/hashed_indices.cpp" target="_top">Go to source code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iomanip</span><span class="special">></span> + +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">tokenizer</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">unordered_set_of</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">multiset_of</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">support</span><span class="special">/</span><span class="identifier">lambda</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bimaps</span><span class="special">;</span> + +<span class="keyword">struct</span> <span class="identifier">word</span> <span class="special">{};</span> +<span class="keyword">struct</span> <span class="identifier">occurrences</span> <span class="special">{};</span> + +<span class="keyword">typedef</span> <span class="identifier">bimap</span> +<span class="special"><</span> + + <span class="identifier">multiset_of</span><span class="special"><</span> <span class="identifier">tagged</span><span class="special"><</span><span class="keyword">unsigned</span> <span class="keyword">int</span><span class="special">,</span><span class="identifier">occurrences</span><span class="special">>,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special"><</span><span class="keyword">unsigned</span> <span class="keyword">int</span><span class="special">></span> <span class="special">>,</span> +<span class="identifier">unordered_set_of</span><span class="special"><</span> <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">word</span><span class="special">></span> <span class="special">></span> + +<span class="special">></span> <span class="identifier">word_counter</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">tokenizer</span><span class="special"><</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">char_separator</span><span class="special"><</span><span class="keyword">char</span><span class="special">></span> <span class="special">></span> <span class="identifier">text_tokenizer</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">text</span><span class="special">=</span> + <span class="string">"Relations between data in the STL are represented with maps."</span> + <span class="string">"A map is a directed relation, by using it you are representing "</span> + <span class="string">"a mapping. In this directed relation, the first type is related to "</span> + <span class="string">"the second type but it is not true that the inverse relationship "</span> + <span class="string">"holds. This is useful in a lot of situations, but there are some "</span> + <span class="string">"relationships that are bidirectional by nature."</span><span class="special">;</span> + + <span class="comment">// feed the text into the container +</span> + <span class="identifier">word_counter</span> <span class="identifier">wc</span><span class="special">;</span> + <span class="identifier">text_tokenizer</span> <span class="identifier">tok</span><span class="special">(</span><span class="identifier">text</span><span class="special">,</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">char_separator</span><span class="special"><</span><span class="keyword">char</span><span class="special">>(</span><span class="string">" \t\n.,;:!?'\"-"</span><span class="special">));</span> + <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">total_occurrences</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> + + <span class="keyword">for</span><span class="special">(</span> <span class="identifier">text_tokenizer</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">tok</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">it_end</span> <span class="special">=</span> <span class="identifier">tok</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> + <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">it_end</span> <span class="special">;</span> <span class="special">++</span><span class="identifier">it</span> <span class="special">)</span> + <span class="special">{</span> + <span class="special">++</span><span class="identifier">total_occurrences</span><span class="special">;</span> + + <span class="identifier">word_counter</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">occurrences</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">wit</span> <span class="special">=</span> + <span class="identifier">wc</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">occurrences</span><span class="special">>().</span><span class="identifier">insert</span><span class="special">(</span> + <span class="identifier">word_counter</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">occurrences</span><span class="special">>::</span><span class="identifier">value_type</span><span class="special">(</span><span class="number">0</span><span class="special">,*</span><span class="identifier">it</span><span class="special">)</span> + <span class="special">).</span><span class="identifier">first</span><span class="special">;</span> + + <span class="identifier">wc</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">occurrences</span><span class="special">>().</span><span class="identifier">modify_key</span><span class="special">(</span> <span class="identifier">wit</span><span class="special">,</span> <span class="special">++</span><span class="identifier">_key</span><span class="special">);</span> + <span class="special">}</span> + + <span class="comment">// list words by frequency of appearance +</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">fixed</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">setprecision</span><span class="special">(</span><span class="number">2</span><span class="special">);</span> + + <span class="keyword">for</span><span class="special">(</span> <span class="identifier">word_counter</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">occurrences</span><span class="special">>::</span><span class="identifier">const_iterator</span> + <span class="identifier">wit</span> <span class="special">=</span> <span class="identifier">wc</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">occurrences</span><span class="special">>().</span><span class="identifier">begin</span><span class="special">(),</span> + <span class="identifier">wit_end</span> <span class="special">=</span> <span class="identifier">wc</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">occurrences</span><span class="special">>().</span><span class="identifier">end</span><span class="special">();</span> + + <span class="identifier">wit</span> <span class="special">!=</span> <span class="identifier">wit_end</span><span class="special">;</span> <span class="special">++</span><span class="identifier">wit</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">setw</span><span class="special">(</span><span class="number">15</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">wit</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">word</span><span class="special">>()</span> <span class="special"><<</span> <span class="string">": "</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">setw</span><span class="special">(</span><span class="number">5</span><span class="special">)</span> + <span class="special"><<</span> <span class="number">100.0</span> <span class="special">*</span> <span class="identifier">wit</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">occurrences</span><span class="special">>()</span> <span class="special">/</span> <span class="identifier">total_occurrences</span> <span class="special"><<</span> <span class="string">"%"</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="multiindex_to_bimap_path___bidirectional_map.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../test_suite.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/examples/simple_bimap.html b/libs/bimap/doc/html/boost_bimap/examples/simple_bimap.html new file mode 100644 index 0000000000..a350874029 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/examples/simple_bimap.html @@ -0,0 +1,203 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Simple Bimap</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../examples.html" title="Examples"> +<link rel="prev" href="../examples.html" title="Examples"> +<link rel="next" href="mighty_bimap.html" title="Mighty Bimap"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../examples.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="mighty_bimap.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.examples.simple_bimap"></a><a class="link" href="simple_bimap.html" title="Simple Bimap">Simple Bimap</a> +</h3></div></div></div> +<p> + This is the example from the one minute tutorial section. + </p> +<p> + <a href="../../../../example/simple_bimap.cpp" target="_top">Go to source code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">string</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> + +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">MapType</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">print_map</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">MapType</span> <span class="special">&</span> <span class="identifier">map</span><span class="special">,</span> + <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&</span> <span class="identifier">separator</span><span class="special">,</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span> <span class="special">&</span> <span class="identifier">os</span> <span class="special">)</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">MapType</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">const_iterator</span><span class="special">;</span> + + <span class="keyword">for</span><span class="special">(</span> <span class="identifier">const_iterator</span> <span class="identifier">i</span> <span class="special">=</span> <span class="identifier">map</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">iend</span> <span class="special">=</span> <span class="identifier">map</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">iend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">os</span> <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">first</span> <span class="special"><<</span> <span class="identifier">separator</span> <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">second</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="comment">// Soccer World cup +</span> + <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">></span> <span class="identifier">results_bimap</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">results_bimap</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">position</span><span class="special">;</span> + + <span class="identifier">results_bimap</span> <span class="identifier">results</span><span class="special">;</span> + <span class="identifier">results</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">position</span><span class="special">(</span><span class="string">"Argentina"</span> <span class="special">,</span><span class="number">1</span><span class="special">)</span> <span class="special">);</span> + <span class="identifier">results</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">position</span><span class="special">(</span><span class="string">"Spain"</span> <span class="special">,</span><span class="number">2</span><span class="special">)</span> <span class="special">);</span> + <span class="identifier">results</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">position</span><span class="special">(</span><span class="string">"Germany"</span> <span class="special">,</span><span class="number">3</span><span class="special">)</span> <span class="special">);</span> + <span class="identifier">results</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">position</span><span class="special">(</span><span class="string">"France"</span> <span class="special">,</span><span class="number">4</span><span class="special">)</span> <span class="special">);</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"The number of countries is "</span> <span class="special"><<</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"The winner is "</span> <span class="special"><<</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">at</span><span class="special">(</span><span class="number">1</span><span class="special">)</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Countries names ordered by their final position:"</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + + <span class="comment">// results.right works like a std::map< int, std::string > +</span> + <span class="identifier">print_map</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">right</span><span class="special">,</span> <span class="string">") "</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">);</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span> + <span class="special"><<</span> <span class="string">"Countries names ordered alphabetically along with"</span> + <span class="string">"their final position:"</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + + <span class="comment">// results.left works like a std::map< std::string, int > +</span> + <span class="identifier">print_map</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">left</span><span class="special">,</span> <span class="string">" ends in position "</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">);</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + You can rewrite it using tags to gain readability. + </p> +<p> + <a href="../../../../example/tagged_simple_bimap.cpp" target="_top">Go to source code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> + +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">struct</span> <span class="identifier">country</span> <span class="special">{};</span> +<span class="keyword">struct</span> <span class="identifier">place</span> <span class="special">{};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bimaps</span><span class="special">;</span> + + <span class="comment">// Soccer World cup. +</span> + <span class="keyword">typedef</span> <span class="identifier">bimap</span> + <span class="special"><</span> + <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">country</span> <span class="special">>,</span> + <span class="identifier">tagged</span><span class="special"><</span> <span class="keyword">int</span> <span class="special">,</span> <span class="identifier">place</span> <span class="special">></span> + + <span class="special">></span> <span class="identifier">results_bimap</span><span class="special">;</span> + + <span class="keyword">typedef</span> <span class="identifier">results_bimap</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">position</span><span class="special">;</span> + + <span class="identifier">results_bimap</span> <span class="identifier">results</span><span class="special">;</span> + <span class="identifier">results</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">position</span><span class="special">(</span><span class="string">"Argentina"</span> <span class="special">,</span><span class="number">1</span><span class="special">)</span> <span class="special">);</span> + <span class="identifier">results</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">position</span><span class="special">(</span><span class="string">"Spain"</span> <span class="special">,</span><span class="number">2</span><span class="special">)</span> <span class="special">);</span> + <span class="identifier">results</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">position</span><span class="special">(</span><span class="string">"Germany"</span> <span class="special">,</span><span class="number">3</span><span class="special">)</span> <span class="special">);</span> + <span class="identifier">results</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">position</span><span class="special">(</span><span class="string">"France"</span> <span class="special">,</span><span class="number">4</span><span class="special">)</span> <span class="special">);</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Countries names ordered by their final position:"</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + + <a class="co" name="boost_bimap20co" href="simple_bimap.html#boost_bimap20"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a><span class="keyword">for</span><span class="special">(</span> <span class="identifier">results_bimap</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">place</span><span class="special">>::</span><span class="identifier">const_iterator</span> + <span class="identifier">i</span> <span class="special">=</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">place</span><span class="special">>().</span><span class="identifier">begin</span><span class="special">(),</span> + <span class="identifier">iend</span> <span class="special">=</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">place</span><span class="special">>().</span><span class="identifier">end</span><span class="special">()</span> <span class="special">;</span> + <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">iend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">)</span> + <span class="special">{</span> + <a class="co" name="boost_bimap21co" href="simple_bimap.html#boost_bimap21"><img src="../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">place</span> <span class="special">>()</span> <span class="special"><<</span> <span class="string">") "</span> + <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">country</span><span class="special">>()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span> + <span class="special"><<</span> <span class="string">"Countries names ordered alfabetically along with"</span> + <span class="string">"their final position:"</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + + <a class="co" name="boost_bimap22co" href="simple_bimap.html#boost_bimap22"><img src="../../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a><span class="keyword">for</span><span class="special">(</span> <span class="identifier">results_bimap</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">country</span><span class="special">>::</span><span class="identifier">const_iterator</span> + <span class="identifier">i</span> <span class="special">=</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">country</span><span class="special">>().</span><span class="identifier">begin</span><span class="special">(),</span> + <span class="identifier">iend</span> <span class="special">=</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">country</span><span class="special">>().</span><span class="identifier">end</span><span class="special">()</span> <span class="special">;</span> + <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">iend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">country</span><span class="special">>()</span> <span class="special"><<</span> <span class="string">" ends "</span> + <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">place</span> <span class="special">>()</span> <span class="special"><<</span> <span class="string">"º"</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<div class="calloutlist"><table border="0" summary="Callout list"> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap20"></a><a href="#boost_bimap20co"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> +<td valign="top" align="left"><p> + <code class="computeroutput"><span class="identifier">results</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">place</span><span class="special">>()</span></code> + is equivalent to <code class="computeroutput"><span class="identifier">results</span><span class="special">.</span><span class="identifier">right</span></code> + </p></td> +</tr> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap21"></a><a href="#boost_bimap21co"><img src="../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> </p></td> +<td valign="top" align="left"><p> + <code class="computeroutput"><span class="identifier">get</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">></span></code> + works for each view of the bimap + </p></td> +</tr> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap22"></a><a href="#boost_bimap22co"><img src="../../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a> </p></td> +<td valign="top" align="left"><p> + <code class="computeroutput"><span class="identifier">results</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">country</span><span class="special">>()</span></code> + is equivalent to <code class="computeroutput"><span class="identifier">results</span><span class="special">.</span><span class="identifier">left</span></code> + </p></td> +</tr> +</table></div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../examples.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="mighty_bimap.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/future_work.html b/libs/bimap/doc/html/boost_bimap/future_work.html new file mode 100644 index 0000000000..28ee3e31c0 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/future_work.html @@ -0,0 +1,51 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Future work</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="prev" href="test_suite.html" title="Test suite"> +<link rel="next" href="release_notes.html" title="Release notes"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> +<td align="center"><a href="../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="test_suite.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="release_notes.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="boost_bimap.future_work"></a><a class="link" href="future_work.html" title="Future work">Future work</a> +</h2></div></div></div> +<a name="boost_bimap.future_work.rearrange_function"></a><h4> +<a name="id881474"></a> + <a class="link" href="future_work.html#boost_bimap.future_work.rearrange_function">Rearrange Function</a> + </h4> +<p> + Boost.MultiIndex includes some others functions that can be included in the + views. + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="test_suite.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="release_notes.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/history.html b/libs/bimap/doc/html/boost_bimap/history.html new file mode 100644 index 0000000000..7f60ed9b20 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/history.html @@ -0,0 +1,111 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>History</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="prev" href="rationale/the_student_and_the_mentor.html" title="The student and the mentor"> +<link rel="next" href="history/multiindex_and_bimap.html" title="MultiIndex and Bimap"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> +<td align="center"><a href="../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="rationale/the_student_and_the_mentor.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="history/multiindex_and_bimap.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="boost_bimap.history"></a><a class="link" href="history.html" title="History">History</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="history.html#boost_bimap.history.the_long_path_from_code_project_to_boost">The + long path from Code Project to Boost</a></span></dt> +<dt><span class="section"><a href="history/multiindex_and_bimap.html">MultiIndex + and Bimap</a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.history.the_long_path_from_code_project_to_boost"></a><a class="link" href="history.html#boost_bimap.history.the_long_path_from_code_project_to_boost" title="The long path from Code Project to Boost">The + long path from Code Project to Boost</a> +</h3></div></div></div> +<div class="variablelist"> +<p class="title"><b></b></p> +<dl> +<dt><span class="term">2002 - bimap at Code Project</span></dt> +<dd><p> + Joaquin Lopez Muñoz posted his first <a href="http://www.codeproject.com/vcpp/stl/bimap.asp#test_suite" target="_top">bimap + library</a> in 2002. Tons of users have been using it. He then + <a href="http://aspn.activestate.com/ASPN/Mail/Message/boost/1404881" target="_top">asked + the list for interest</a> in his library in 2003. Luckily, there + was a lot of interest and Joaquin started to boostify the code. At + some point all the developers seemed to agree that, rather than a bidirectional + map, it would be better to work on an N-indexed set that contained + Joaquin's library as a particular case. + </p></dd> +<dt><span class="term">2003 - multiindex_set</span></dt> +<dd><p> + The library grew enormously and was ready for a formal review in 2003. + At this point, the container was a lot more powerful, but everything + comes with a price and this new beast lacked the simplicity of the + original bimap. + </p></dd> +<dt><span class="term">2004 - indexed_set</span></dt> +<dd><p> + In 2004, the formal review ended well for the new multi-indexed container. + This Swiss army knife introduced several new features, such as non-unique + indexes, hashed indices and sequenced indices. In the list of improvements + to the library, it was mentioned that a bidirectional map should be + coded in top of this container. + </p></dd> +<dt><span class="term">2005 - multi_index_container</span></dt> +<dd><p> + Once in Boost, the library switched to the now familiar name "Boost.MultiIndex". + Late in 2004, it formally became a member of Boost. Joaquin continued + to enchance the library and added new features such as composite keys + and random-access indices. + </p></dd> +<dt><span class="term">2006 - Multi Index Specialized Containers SoC project</span></dt> +<dd><p> + In 2006, during the formal review of Boost.Property_tree, the need + for a bidirectional map container built on top of Boost.MultiIndex + arose again. Boost entered the Google SoC 2006 as a mentor organization + at the same time. Joaquin put himself forward as a mentor. He proposed + to build not only a bidirectional map, but a myriad multi-indexed specialized + containers. Matias Capeletto presented an application to code Boost.Misc + for the SoC and was elected, along with nine other students. Matias's + and Joaquin's SoC project ends with a working implementation of the + bimap library that was presented in an informal review. By the end + of the year the library was queued for a formal review. + </p></dd> +<dt><span class="term">2007 - Boost.Bimap</span></dt> +<dd><p> + The formal review took place at the beggining of the year and Boost.Bimap + was accepted in Boost. + </p></dd> +</dl> +</div> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="rationale/the_student_and_the_mentor.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="history/multiindex_and_bimap.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/history/multiindex_and_bimap.html b/libs/bimap/doc/html/boost_bimap/history/multiindex_and_bimap.html new file mode 100644 index 0000000000..31423e0bba --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/history/multiindex_and_bimap.html @@ -0,0 +1,477 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>MultiIndex and Bimap</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../history.html" title="History"> +<link rel="prev" href="../history.html" title="History"> +<link rel="next" href="../acknowledgements.html" title="Acknowledgements"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../history.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../history.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../acknowledgements.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.history.multiindex_and_bimap"></a><a class="link" href="multiindex_and_bimap.html" title="MultiIndex and Bimap">MultiIndex + and Bimap</a> +</h3></div></div></div> +<p> + This is the conversation thread that began during Boost.PropertyTree formal + review process. The review was very interesting and very deep topics were + addressed. It is quite interesting and it is now part of this library history. + Enjoy! + </p> +<p> + <span class="bold"><strong>Marcin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> The biggest virtue of property_tree is easy to use interface. + If we try to make generic tree of it, it will be compromised. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Gennadiy</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> IMO the same result (as library presents) could be achieved + just by using multi_index. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Marcin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Could you elaborate more on that? I considered use of multi_index + to implement indexing for properties, but it only affected the implementation + part of library, not interface, and because I already had a working, exception + safe solution, I didn't see the reason to dump it and add another dependency + on another library. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Gennadiy</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I mean why do I need this half baked property_tree as another + data structure? Property tree supports nothing in itself. It's just a data + structure. You have parsers that produce property tree out of different + sources. But you mat as well produce maps or something else. Here for example + All that I need to do to "implement" similar functionality as + your property tree: </em></span> + </p></blockquote></div> +<p> + +</p> +<pre class="programlisting"><span class="comment">// Data structure itself +</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">ValueType</span><span class="special">,</span><span class="keyword">typename</span> <span class="identifier">KeyType</span><span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">Node</span><span class="special">;</span> +<span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">ValueType</span><span class="special">,</span><span class="keyword">typename</span> <span class="identifier">KeyType</span><span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">ptree_gen</span> <span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">KeyType</span><span class="special">,</span><span class="identifier">Node</span><span class="special"><</span><span class="identifier">ValueType</span><span class="special">,</span><span class="identifier">KeyType</span><span class="special">></span> <span class="special">></span> <span class="identifier">mi_value</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">multi_index_container</span><span class="special"><</span><span class="identifier">mi_value</span><span class="special">,</span> <span class="identifier">indexed_by</span><span class="special"><...></span> <span class="special">></span> <span class="identifier">type</span><span class="special">;</span> +<span class="special">};</span> +<span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">ValueType</span><span class="special">,</span><span class="keyword">typename</span> <span class="identifier">KeyType</span><span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">Node</span> <span class="special">{</span> + <span class="identifier">ValueType</span> <span class="identifier">v</span><span class="special">;</span> + <span class="identifier">ptree_gen</span><span class="special"><</span><span class="identifier">ValueType</span><span class="special">,</span><span class="identifier">KeyType</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">children</span><span class="special">;</span> +<span class="special">};</span> +<span class="comment">// serialization support +</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Archive</span><span class="special">,</span><span class="keyword">typename</span> <span class="identifier">ValueType</span><span class="special">,</span><span class="keyword">typename</span> <span class="identifier">KeyType</span><span class="special">></span> +<span class="keyword">void</span> <span class="identifier">serialize</span><span class="special">(</span><span class="identifier">Archive</span> <span class="special">&</span> <span class="identifier">ar</span><span class="special">,</span> <span class="identifier">Node</span><span class="special"><</span><span class="identifier">ValueType</span><span class="special">,</span><span class="identifier">KeyType</span><span class="special">>&</span> <span class="identifier">n</span><span class="special">,</span> + <span class="keyword">const</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">version</span><span class="special">)</span> +<span class="special">{</span> + <span class="identifier">ar</span> <span class="special">&</span> <span class="identifier">n</span><span class="special">.</span><span class="identifier">v</span><span class="special">;</span> + <span class="identifier">ar</span> <span class="special">&</span> <span class="identifier">n</span><span class="special">.</span><span class="identifier">children</span><span class="special">;</span> +<span class="special">}</span> +<span class="comment">// some access methods +</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">ValueType</span><span class="special">,</span><span class="keyword">typename</span> <span class="identifier">KeyType</span><span class="special">></span> +<span class="identifier">ValueType</span> <span class="keyword">const</span><span class="special">&</span> +<span class="identifier">get</span><span class="special">(</span> <span class="identifier">string</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">keys</span><span class="special">,</span> <span class="identifier">ptree_gen</span><span class="special"><</span><span class="identifier">ValueType</span><span class="special">,</span><span class="identifier">KeyType</span><span class="special">>::</span><span class="identifier">type</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">src</span> <span class="special">)</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">pait</span><span class="special"><</span><span class="identifier">string</span><span class="special">,</span><span class="identifier">string</span><span class="special">></span> <span class="identifier">sk</span> <span class="special">=</span> <span class="identifier">split</span><span class="special">(</span> <span class="identifier">keys</span><span class="special">,</span> <span class="string">"."</span> <span class="special">);</span> + <span class="identifier">Node</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">N</span> <span class="special">=</span> <span class="identifier">src</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span> <span class="identifier">sk</span><span class="special">.</span><span class="identifier">first</span> <span class="special">);</span> + <span class="keyword">return</span> <span class="identifier">sk</span><span class="special">.</span><span class="identifier">second</span><span class="special">.</span><span class="identifier">empty</span><span class="special">()</span> <span class="special">?</span> <span class="identifier">N</span><span class="special">.</span><span class="identifier">v</span> <span class="special">:</span> <span class="identifier">get</span><span class="special">(</span> <span class="identifier">sk</span><span class="special">.</span><span class="identifier">second</span><span class="special">,</span> <span class="identifier">N</span><span class="special">.</span><span class="identifier">children</span> <span class="special">);</span> +<span class="special">}</span> +</pre> +<p> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Use it like this: </em></span> + </p></blockquote></div> +<p> + +</p> +<pre class="programlisting"><span class="identifier">ptree_gen</span><span class="special"><</span><span class="identifier">string</span><span class="special">,</span><span class="identifier">string</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">PT</span><span class="special">;</span> +<span class="identifier">boost</span><span class="special">::</span><span class="identifier">archive</span><span class="special">::</span><span class="identifier">text_iarchive</span> <span class="identifier">ia</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">ifstream</span> <span class="identifier">ifs</span><span class="special">(</span><span class="string">"filename"</span><span class="special">)</span> <span class="special">);</span> +<span class="identifier">ia</span> <span class="special">>></span> <span class="identifier">PT</span><span class="special">;</span> +<span class="identifier">string</span> <span class="identifier">value</span> <span class="special">=</span> <span class="identifier">get</span><span class="special">(</span> <span class="string">"a.b.c.d"</span><span class="special">,</span> <span class="identifier">PT</span> <span class="special">);</span> +</pre> +<p> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Now tell me how property_tree interface is easier? And what + is the value in 50k of Code you need to implement this data structure. + </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Thorsten</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Seriously Gennadiy, do you really see newbies writing the code + you just did? </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Marcin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> What you just implemented is stripped down, bare bones version + of property_tree that, among other things, does not allow you to produce + human editable XML files. Now add more interface (aka get functions), add + more archives to serialization lib, add customization, add transparent + translation from strings to arbitrary types and vice versa. Spend some + weeks trying to get all the corner cases right, and then some more weeks + trying to smooth rough edges in the interface. Then write tests. Write + docs. At the end, I believe you will not get much less code than there + is in the library already. Maybe you get some savings by using multi_index + instead of manual indexing. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> The reason why ptree does not use multi index is because implementation + existed long before I considered submitting to boost, probably before even + I knew of multi index existence. It was working well. Later, when I was + improving it during pre-review process, I seriously considered using multi-index. + But I decided it is not worth throwing everything out. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Although ptree has large interface with many functions modifying + state of the tree, it uses "single point of change" approach. + Every insert eventually goes through one function, which takes care of + exception safety and keeping index in sync with data. The same applies + to erase. This function has 9 lines of code in case of insert, and (by + coincidence) also 9 in case of erase. By using multi index these functions + would obviously be simplified, maybe to 4 lines each. Net gain: 10 lines + of code (out of several hundred in ptree_implementation.hpp). </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I'm aware that there are performance gains to be reaped as well, + but at that time I was rather focusing on getting the interface right. + </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Dave</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> That's perfectly reasonable, but (through no fault of yours) + it misses the point I was trying to make. I guess I should have said, "...that + demonstrates it to be the best implementation." </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> All I'm saying is that the extent to which a Boost library implementation + should leverage other Boost libraries is not a question that can always + be decided based on following simple guidelines, and that if this library + is accepted, it's worth revisiting your decision. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Thorsten</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I think it is important to focus on the interface in the review, + but I also see several benefits of an implementation that builds on Boost.MultiIndex:' + </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- fewer bugs like the one Joaquin found</em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- better space efficiency</em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- exception-safety guarantees are immediately full-filled (I + haven't looked, but I suspect that there are several bugs in this area)</em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Daniel</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Multi_index supports everything a bimap would, but its interface + is more cumbersome. I for one won't use a W3DOM-like library if we get + one, but I would happily use property_tree. I've also only used multi_index + once, and that was to use it as a bidirectional map. Property_tree covers + other areas as well as being a potential subset of an XML library, but + I still hold there is value in such a subset. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Boris</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I haven't used program_options yet. But if I understand correctly + both libraries seem to support storing and accessing data with strings + that might describe some kind of hierarchy. This seems to be the core idea + of both libraries - is this correct? </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Then it wouldn't matter much what container is used. However + a generic tree which can store data hierarchically probably makes most + sense. If I understand correctly both libraries could make use of such + a class? </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Marcin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I think generic tree container is material for another library. + Whether property_tree should be based on it or not is a matter of internal + implementation, and generally of little interest to users. The biggest + value of property_tree is in its easy to use interface, that should not + be compromised, if at all possible. I have been already reassured in this + view by quite many people who took their time to review the library. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Boris</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I was trying to see the big picture: I rather prefer a C++ standard + based on a few well-known concepts like containers, iterators, algorithms + etc. instead of having a C++ standard with hundreds of components which + are tailored for specific needs, collaborate with only a handful of other + components and think they provide an easy-to-use interface while all the + easy-to-use interfaces make the whole standard less easy-to-use. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> That said I have used your property tree library myself to read + and write a configuration file. It was indeed very easy to use. However + it would have been even easier if it was something I had known before like + eg. an iterator. For now I will definitely use your property tree library + but would appreciate if existing concepts were reused many C++ developers + are familiar with. My opinion is that your library should be a part of + Boost but should be more generalized in the future. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Thorsten</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Well, I think we need both. Boost.MultiIndex is a great library + and can do all kinds of wonderful things. But I would still like to see + a bidirectional map (boost::bimap) written as a wrapper around it to get + an easy and specialized interface. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Pavel</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Bimap is available in libs/multi-index/examples/bimap.cpp. + </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Thorsten</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Right, but the real value comes when somebody designs a nice + STL-like interface and write docs etc, at least that was my point. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Dave</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> IMO Thorsten is exactly right. This is precisely the sort of + thing that could be added to the library as part of its ongoing maintenance + and development (without review, of course). </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Thorsten, we have talked about this privately in the past, but + I feel like bringing it to the list in the hope of getting the attention + of potential contributors: </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> There are some data structures buildable with B.MI which are + regarded as particularly useful or common, like for instance the bidirectional + map or bimap. A lean and mean implementation is provided in the aforementioned + example, but certainly a much carefully crafted interface can be provided + keeping B.MI as the implementation core: operator[], selection of 1-1/1-N/N-1/N-N + variants, hashing/ordering, etc. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I'm afraid I don't have the time to pursue this, as the current + roadmap for core features of B.MI is taking all the spare time I can dedicate + to the library. For this reason, I would love to see some volunteer jumping + in who can develop this and other singular containers using B.MI (a cache + container comes to mind) and then propose the results here either as a + stand alone library of as part of B.MI --I'd prefer the former so as to + keep the size of B.MI bounded. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> If there's such a volunteer I can provide her with some help/mentoring. + I also wonder whether this is a task suitable to be proposed for Google + Summer of Code. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Thorsten</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I think it would be good for SOC. All the really hard things + are taken care of by B.MI, and so it seems reasonable for a student to + be able to fill in the details. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Dave</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Great! </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Jeff</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Please write a proposal! </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I've just done so: </em></span> + </p></blockquote></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Specialized containers with Boost.MultiIndex</strong></span> + </p> +<p> + <span class="bold"><strong>Introduction</strong></span> + </p> +<p> + Boost.MultiIndex allows the construction of complex data structures involving + two or more indexing mechanisms on the same set of elements. Out of the unlimited + range of possible data structures specifiable within Boost.MultiIndex, some + particular configurations arise recurrently: + </p> +<p> + <span class="bold"><strong>a.</strong></span> A bidirectional map or bimap is a container + of elements of type pair<T,Q> where fast look up is provided both for + the T and the Q field, in contrast with a regular STL map which only allows + for fast look up on T. + </p> +<p> + <span class="bold"><strong>b.</strong></span> An MRU (most recently used) list keeps + the n last referenced elements: when a new item is inserted and the list + has reached its maximum length, the oldest element is erased, whereas if + an insertion is tried of a preexistence element, this gets promoted to the + first position. MRU lists can be used to implement dynamic caches and the + kind of behavior exhibited by programs featuring a "Recent files" + menu command, for instance. + </p> +<p> + Although Boost.MultiIndex provides the mechanisms to build these common structures, + the resulting interface can be cumbersome and too general in comparison with + specialized containers focusing on such particular structures. + </p> +<p> + <span class="bold"><strong>Goal</strong></span> + </p> +<p> + To write a library of specialized containers like the ones described above, + using Boost.MultiIndex as the implementation core. Besides bimap and MRU + list, the student can also propose other specialized containers of interest + in the community. It is expected that the library meets the standards of + quality required by Boost for an eventual inclusion in this project, which + implies a strong emphasis on interface design, documentation and unit testing; + the mentor will be guiding the student through the complete cycle from specification + and requirements gathering to documentation and actual coding. The final + result of the project must then contain: + </p> +<p> + <span class="bold"><strong>a.</strong></span> Source code following <a href="http://boost.org/more/lib_guide.htm#Guidelines" target="_top">Boost + programming guidelines</a>. + </p> +<p> + <span class="bold"><strong>b.</strong></span> User documentation. Requirements on the + format are loose, though the <a href="http://www.boost.org/tools/quickbook/" target="_top">QuickBook</a> + format is gaining acceptance within Boost. + </p> +<p> + <span class="bold"><strong>c.</strong></span> Complete set of unit tests powered by + <a href="http://www.boost.org/boost-build2/" target="_top">Boost Build System V2</a>. + </p> +<p> + <span class="bold"><strong>Requirements</strong></span> + </p> +<p> + <span class="bold"><strong>a.</strong></span> Intermediate-to-high level in C++, with + emphasis in generic programming (templates). + </p> +<p> + <span class="bold"><strong>b.</strong></span> Knowledge of the STL framework and design + principles. Of course, knowledge of Boost in general and Boost.MultiIndex + in particular is a big plus. + </p> +<p> + <span class="bold"><strong>c.</strong></span> Acquaintance with at least two different + C++ programming environments. + </p> +<p> + <span class="bold"><strong>d.</strong></span> Some fluency in the English language; + subsequent reviews of the documentation can help smooth rough edges here, + though. + </p> +<p> + <span class="bold"><strong>e.</strong></span> A mathematical inclination and previous + exposure to a formal Algorithms course would help very much. + </p> +<p> + <span class="bold"><strong>f.</strong></span> A craving for extreme quality work. + </p> +<p> + <span class="bold"><strong>Benefits for the student</strong></span> + </p> +<p> + The student taking on this project will have the opportunity to learn the + complete process of software production inside a highly regarded C++ open + source institution, and even see her work included in Boost eventually. The + completion of the project involves non-trivial problems in C++ interface + design and so-called modern C++ programming, high quality user documentation + and unit testing. The student will also learn, perhaps to her surprise, that + most of the time will be spent gathering and trying ideas and, in general, + thinking, rather than writing actual code. + </p> +</div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I am planning to submit an application to SoC. I will love to + make real the specialized containers you mention and try to include some + useful others. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <code class="literal"> And then... after long hours of coding (and fun) this library + saw the light. </code> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="inlinemediaobject"><img src="../../images/bimap/boost.bimap.logo.png" alt="boost.bimap.logo"></span> + </p></blockquote></div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../history.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../history.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../acknowledgements.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/introduction.html b/libs/bimap/doc/html/boost_bimap/introduction.html new file mode 100644 index 0000000000..0c839a4e4f --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/introduction.html @@ -0,0 +1,194 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Introduction</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="prev" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="next" href="one_minute_tutorial.html" title="One minute tutorial"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> +<td align="center"><a href="../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="one_minute_tutorial.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="boost_bimap.introduction"></a><a class="link" href="introduction.html" title="Introduction">Introduction</a> +</h2></div></div></div> +<a name="boost_bimap.introduction.how_to_use_this_document"></a><h4> +<a name="id769112"></a> + <a class="link" href="introduction.html#boost_bimap.introduction.how_to_use_this_document">How to use + this document</a> + </h4> +<p> + This documentation contains a large amount of information. Whereas it may be + worth reading it all, this documentation is intended for programmers with various + motives: + </p> +<div class="variablelist"> +<p class="title"><b></b></p> +<dl> +<dt><span class="term">I have to finished this today, I just want a bidirectional map!</span></dt> +<dd><p> + If your boss will kill you if the project is not finished by the end + of the day, just read the <a class="link" href="one_minute_tutorial.html" title="One minute tutorial">One-minute + tutorial</a>. If you have a background in STL, you can be testing + a bimap within ten minutes. + </p></dd> +<dt><span class="term">I am a serious programmer and want to learn Boost.Bimap</span></dt> +<dd><p> + Boost.Bimap has a lot to offer if you are prepared to spend some time + reading this documentation. You will need to read <a class="link" href="the_tutorial.html" title="The tutorial">The + tutorial</a> and skim through some of the <a class="link" href="examples.html" title="Examples">Examples</a>. + The best way to read this documentation is in the order given here. Just + click on the arrow at the right bottom corner as you finish each page. + You may skip the reference section, and return to it later to look up + a function signature or to find a specific metafunction. + </p></dd> +<dt><span class="term">I just love C++, I want to see the inner workings of Boost.Bimap.</span></dt> +<dd><p> + If you are a library developer, this documentation is the best place + to learn how Boost.Bimap is implemented. It is strongly recommended that + you first learn to use the library as if you were the second type of + programmer above. This library was developed in the Google SoC 2006, + and the mentor and student generated a great deal of documentation in + the building process. The rationale section is very large and contains + a lot of information. There is a history section for those who might + find it useful. Finally, in the reference section, each entity of the + library is documented and its source code is presented. + </p></dd> +</dl> +</div> +<div class="note"><table border="0" summary="Note"> +<tr> +<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td> +<th align="left">Note</th> +</tr> +<tr><td align="left" valign="top"><p> + If anything in the documentation is unclear, please email me at <span class="emphasis"><em>matias + {dot} capeletto {at} gmail {dot} com</em></span>, telling me which of the + three types of programmer above you are and which section needs improvement. + Please use the following notation for the subject: <span class="emphasis"><em>[boost][bimap] + Your problem</em></span> as this will help me to identify it more easily. + If appropriate, I will act on your advice to improve the documentation. Thanks + and enjoy! + </p></td></tr> +</table></div> +<div class="important"><table border="0" summary="Important"> +<tr> +<td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../doc/src/images/important.png"></td> +<th align="left">Important</th> +</tr> +<tr><td align="left" valign="top"><p> + If you should find a bug or would like to see an additional feature in the + library, please use the standard Boost methods of dealing with this kind + of issue rather than emailing me directly. Boost has a very good system to + <a href="http://www.boost.org/more/bugs.htm" target="_top">track bugs</a> and <a href="http://www.boost.org/more/requesting_new_features.htm" target="_top">features requests</a>, + and using it is the best way of dealing with them as soon as possible. + </p></td></tr> +</table></div> +<a name="boost_bimap.introduction.navigation"></a><h4> +<a name="id769258"></a> + <a class="link" href="introduction.html#boost_bimap.introduction.navigation">Navigation</a> + </h4> +<p> + Used in combination with the configured browser key (usually Alt), the following + keys act as handy shortcuts for common navigation tasks. + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>General</strong></span> + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>p</strong></span></code> - Previous page + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>n</strong></span></code> - Next page + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>h</strong></span></code> - home + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>u</strong></span></code> - Up + </li> +</ul></div> +</li> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>Main TOC</strong></span> + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>i</strong></span></code> - Introduction + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>o</strong></span></code> - One minute + tutorial + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>t</strong></span></code> - The tutorial + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>b</strong></span></code> - Bimap and Boost + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>r</strong></span></code> - Reference + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>c</strong></span></code> - Compiler specifics + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>v</strong></span></code> - Performance + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>e</strong></span></code> - Examples + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>s</strong></span></code> - Test Suite + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>f</strong></span></code> - Future work + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>m</strong></span></code> - Release notes + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>w</strong></span></code> - Rationale + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>y</strong></span></code> - History + </li> +<li class="listitem"> + <code class="literal"><span class="bold"><strong>a</strong></span></code> - Acknowledgements + </li> +</ul></div> +</li> +</ul></div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="one_minute_tutorial.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/one_minute_tutorial.html b/libs/bimap/doc/html/boost_bimap/one_minute_tutorial.html new file mode 100644 index 0000000000..4925850a3e --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/one_minute_tutorial.html @@ -0,0 +1,431 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>One minute tutorial</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="prev" href="introduction.html" title="Introduction"> +<link rel="next" href="the_tutorial.html" title="The tutorial"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> +<td align="center"><a href="../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="introduction.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="the_tutorial.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="boost_bimap.one_minute_tutorial"></a><a class="link" href="one_minute_tutorial.html" title="One minute tutorial">One minute tutorial</a> +</h2></div></div></div> +<a name="boost_bimap.one_minute_tutorial.what_is_a_bimap_"></a><h4> +<a name="id769586"></a> + <a class="link" href="one_minute_tutorial.html#boost_bimap.one_minute_tutorial.what_is_a_bimap_">What is a + bimap?</a> + </h4> +<p> + A Bimap is a data structure that represents bidirectional relations between + elements of two collections. The container is designed to work as two opposed + STL maps. A bimap between a collection <code class="computeroutput"><span class="identifier">X</span></code> + and a collection <code class="computeroutput"><span class="identifier">Y</span></code> can be viewed + as a map from <code class="computeroutput"><span class="identifier">X</span></code> to <code class="computeroutput"><span class="identifier">Y</span></code> (this view will be called the <span class="emphasis"><em>left + map view</em></span>) or as a map from <code class="computeroutput"><span class="identifier">Y</span></code> + to <code class="computeroutput"><span class="identifier">X</span></code> (known as the <span class="emphasis"><em>right + map view</em></span>). Additionally, the bimap can also be viewed as a set of + relations between <code class="computeroutput"><span class="identifier">X</span></code> and <code class="computeroutput"><span class="identifier">Y</span></code> (named the <span class="emphasis"><em>collection of relations + view</em></span>). + </p> +<p> + The following code creates an empty bimap container: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span><span class="identifier">X</span><span class="special">,</span><span class="identifier">Y</span><span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> +</pre> +<p> + Given this code, the following is the complete description of the resulting + bimap. <sup>[<a name="id769748" href="#ftn.id769748" class="footnote">1</a>]</sup> + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span></code> is signature-compatible with <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="identifier">X</span><span class="special">,</span><span class="identifier">Y</span><span class="special">></span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span></code> is signature-compatible with <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="identifier">Y</span><span class="special">,</span><span class="identifier">X</span><span class="special">></span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">bm</span></code> is signature-compatible + with <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span><span class="special"><</span> <span class="identifier">relation</span><span class="special"><</span><span class="identifier">X</span><span class="special">,</span><span class="identifier">Y</span><span class="special">></span> <span class="special">></span></code> + </li> +</ul></div> +<p> + <span class="inlinemediaobject"><img src="../images/bimap/simple.bimap.png" alt="simple.bimap"></span> + </p> +<p> + You can see how a bimap container offers three views over the same collection + of bidirectional relations. + </p> +<p> + If we have any generic function that work with maps + </p> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">MapType</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">print_map</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">MapType</span> <span class="special">&</span> <span class="identifier">m</span><span class="special">)</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">MapType</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">const_iterator</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span> <span class="identifier">const_iterator</span> <span class="identifier">iter</span> <span class="special">=</span> <span class="identifier">m</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">iend</span> <span class="special">=</span> <span class="identifier">m</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> <span class="identifier">iter</span> <span class="special">!=</span> <span class="identifier">iend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">iter</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">iter</span><span class="special">-></span><span class="identifier">first</span> <span class="special"><<</span> <span class="string">"-->"</span> <span class="special"><<</span> <span class="identifier">iter</span><span class="special">-></span><span class="identifier">second</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span> +</pre> +<p> + We can use the <span class="emphasis"><em>left map view</em></span> and the <span class="emphasis"><em>right map + view</em></span> with it + </p> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">></span> <span class="identifier">bm</span><span class="special">;</span> +<span class="special">...</span> +<span class="identifier">print_map</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span> <span class="special">);</span> +<span class="identifier">print_map</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span> <span class="special">);</span> +</pre> +<p> + And the output will be + </p> +<pre class="programlisting"><code class="literal">1 --> one</code> +<code class="literal">2 --> two</code> +... +<code class="literal">one --> 1</code> +<code class="literal">two --> 2</code> +... +</pre> +<a name="boost_bimap.one_minute_tutorial.layout_of_the_relation_and_the_pairs_of_a_bimap"></a><h4> +<a name="id770430"></a> + <a class="link" href="one_minute_tutorial.html#boost_bimap.one_minute_tutorial.layout_of_the_relation_and_the_pairs_of_a_bimap">Layout + of the relation and the pairs of a bimap</a> + </h4> +<p> + The <code class="computeroutput"><span class="identifier">relation</span></code> class represents + two related elements. The two values are named left and right to express the + symmetry of this type. The bimap pair classes are signature-compatible with + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pairs</span></code>. + </p> +<p> + <span class="inlinemediaobject"><img src="../images/bimap/relation.and.pair.png" alt="relation.and.pair"></span> + </p> +<a name="boost_bimap.one_minute_tutorial.step_by_step"></a><h4> +<a name="id770497"></a> + <a class="link" href="one_minute_tutorial.html#boost_bimap.one_minute_tutorial.step_by_step">Step by step</a> + </h4> +<p> + A convinience header is avaiable in the boost directory: + </p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +</pre> +<p> + Lets define a bidirectional map between integers and strings: + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bimap</span><span class="special"><</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> +</pre> +<p> + </p> +<a name="boost_bimap.one_minute_tutorial.the_collection_of_relations_view"></a><h4> +<a name="id770643"></a> + <a class="link" href="one_minute_tutorial.html#boost_bimap.one_minute_tutorial.the_collection_of_relations_view">The + collection of relations view</a> + </h4> +<p> + Remember that <code class="computeroutput"><span class="identifier">bm</span></code> alone can + be used as a set of relations. We can insert elements or iterate over them + using this view. + </p> +<p> + +</p> +<pre class="programlisting"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="string">"one"</span> <span class="special">)</span> <span class="special">);</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="string">"two"</span> <span class="special">)</span> <span class="special">);</span> + +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"There are "</span> <span class="special"><<</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special"><<</span> <span class="string">"relations"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + +<span class="keyword">for</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">iter</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">iend</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> + <span class="identifier">iter</span> <span class="special">!=</span> <span class="identifier">iend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">iter</span> <span class="special">)</span> +<span class="special">{</span> + <span class="comment">// iter->left : data : int +</span> <span class="comment">// iter->right : data : std::string +</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">iter</span><span class="special">-></span><span class="identifier">left</span> <span class="special"><<</span> <span class="string">" <--> "</span> <span class="special"><<</span> <span class="identifier">iter</span><span class="special">-></span><span class="identifier">right</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<a name="boost_bimap.one_minute_tutorial.the_left_map_view"></a><h4> +<a name="id771089"></a> + <a class="link" href="one_minute_tutorial.html#boost_bimap.one_minute_tutorial.the_left_map_view">The left + map view</a> + </h4> +<p> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span></code> works like a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span> + <span class="keyword">int</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> + <span class="special">></span></code>. We use it in the same way we will + use a standard map. + </p> +<p> + +</p> +<pre class="programlisting"><a class="co" name="boost_bimap0co" href="one_minute_tutorial.html#boost_bimap0"><img src="../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a><span class="keyword">typedef</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_map</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">left_const_iterator</span><span class="special">;</span> + +<span class="keyword">for</span><span class="special">(</span> <span class="identifier">left_const_iterator</span> <span class="identifier">left_iter</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">iend</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> + <span class="identifier">left_iter</span> <span class="special">!=</span> <span class="identifier">iend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">left_iter</span> <span class="special">)</span> +<span class="special">{</span> + <span class="comment">// left_iter->first : key : int +</span> <span class="comment">// left_iter->second : data : std::string +</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">left_iter</span><span class="special">-></span><span class="identifier">first</span> <span class="special"><<</span> <span class="string">" --> "</span> <span class="special"><<</span> <span class="identifier">left_iter</span><span class="special">-></span><span class="identifier">second</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<span class="special">}</span> + +<a class="co" name="boost_bimap1co" href="one_minute_tutorial.html#boost_bimap1"><img src="../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_const_iterator</span> <span class="identifier">left_iter</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="number">2</span><span class="special">);</span> +<span class="identifier">assert</span><span class="special">(</span> <span class="identifier">left_iter</span><span class="special">-></span><span class="identifier">second</span> <span class="special">==</span> <span class="string">"two"</span> <span class="special">);</span> + +<a class="co" name="boost_bimap2co" href="one_minute_tutorial.html#boost_bimap2"><img src="../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a><span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_value_type</span><span class="special">(</span> <span class="number">3</span><span class="special">,</span> <span class="string">"three"</span> <span class="special">)</span> <span class="special">);</span> +</pre> +<p> + </p> +<div class="calloutlist"><table border="0" summary="Callout list"> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap0"></a><a href="#boost_bimap0co"><img src="../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> +<td valign="top" align="left"><p> + The type of <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span></code> is <code class="computeroutput"><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_map</span></code> + and the type of <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span></code> is <code class="computeroutput"><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">right_map</span></code> + </p></td> +</tr> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap1"></a><a href="#boost_bimap1co"><img src="../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> </p></td> +<td valign="top" align="left"><p> + <code class="computeroutput"><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_</span></code>-type- can be used as a shortcut + for the more verbose <code class="computeroutput"><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_map</span><span class="special">::</span></code>-type- + </p></td> +</tr> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap2"></a><a href="#boost_bimap2co"><img src="../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a> </p></td> +<td valign="top" align="left"><p> + This line produces the same effect of <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="number">3</span><span class="special">,</span><span class="string">"three"</span><span class="special">)</span> + <span class="special">);</span></code> + </p></td> +</tr> +</table></div> +<a name="boost_bimap.one_minute_tutorial.the_right_map_view"></a><h4> +<a name="id771810"></a> + <a class="link" href="one_minute_tutorial.html#boost_bimap.one_minute_tutorial.the_right_map_view">The right + map view</a> + </h4> +<p> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span></code> works like a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">></span></code>. It + is important to note that the key is the first type and the data is the second + one, exactly as with standard maps. + </p> +<p> + +</p> +<pre class="programlisting"><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">right_const_iterator</span> <span class="identifier">right_iter</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="string">"two"</span><span class="special">);</span> + +<span class="comment">// right_iter->first : key : std::string +</span><span class="comment">// right_iter->second : data : int +</span> +<span class="identifier">assert</span><span class="special">(</span> <span class="identifier">right_iter</span><span class="special">-></span><span class="identifier">second</span> <span class="special">==</span> <span class="number">2</span> <span class="special">);</span> + +<span class="identifier">assert</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">at</span><span class="special">(</span><span class="string">"one"</span><span class="special">)</span> <span class="special">==</span> <span class="number">1</span> <span class="special">);</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">erase</span><span class="special">(</span><span class="string">"two"</span><span class="special">);</span> + +<a class="co" name="boost_bimap3co" href="one_minute_tutorial.html#boost_bimap3"><img src="../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a><span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">right_value_type</span><span class="special">(</span> <span class="string">"four"</span><span class="special">,</span> <span class="number">4</span> <span class="special">)</span> <span class="special">);</span> +</pre> +<p> + </p> +<div class="calloutlist"><table border="0" summary="Callout list"><tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap3"></a><a href="#boost_bimap3co"><img src="../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> +<td valign="top" align="left"><p> + This line produces the same effect of <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="number">4</span><span class="special">,</span><span class="string">"four"</span><span class="special">)</span> + <span class="special">);</span></code> + </p></td> +</tr></table></div> +<a name="boost_bimap.one_minute_tutorial.differences_with_std__map"></a><h4> +<a name="id772245"></a> + <a class="link" href="one_minute_tutorial.html#boost_bimap.one_minute_tutorial.differences_with_std__map">Differences + with std::map</a> + </h4> +<p> + The main difference between bimap views and their standard containers counterparts + is that, because of the bidirectional nature of a bimap, the values stored + in it can not be modified directly using iterators. For example, when a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="identifier">X</span><span class="special">,</span><span class="identifier">Y</span><span class="special">></span></code> iterator + is dereferenced the return type is <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">X</span><span class="special">,</span> + <span class="identifier">Y</span><span class="special">></span></code>, + so the following code is valid: <code class="computeroutput"><span class="identifier">m</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()-></span><span class="identifier">second</span> <span class="special">=</span> <span class="identifier">new_value</span><span class="special">;</span></code>. + However dereferencing a <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span><span class="identifier">X</span><span class="special">,</span><span class="identifier">Y</span><span class="special">>::</span><span class="identifier">left_iterator</span></code> + returns a type that is <span class="emphasis"><em>signature-compatible</em></span> with a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">X</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Y</span><span class="special">></span></code> + </p> +<pre class="programlisting"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="number">1</span><span class="special">)-></span><span class="identifier">second</span> <span class="special">=</span> <span class="string">"1"</span><span class="special">;</span> <span class="comment">// Compilation error +</span></pre> +<p> + If you insert <code class="computeroutput"><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="string">"one"</span><span class="special">)</span></code> and <code class="computeroutput"><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="string">"1"</span><span class="special">)</span></code> in a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">></span></code> the second insertion will have no effect. + In a <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span><span class="identifier">X</span><span class="special">,</span><span class="identifier">Y</span><span class="special">></span></code> both keys have to remain unique. The insertion + may fail in other situtions too. Lets see an example + </p> +<pre class="programlisting"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">clear</span><span class="special">();</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span> <span class="number">1</span><span class="special">,</span> <span class="string">"one"</span> <span class="special">)</span> <span class="special">);</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span> <span class="number">1</span><span class="special">,</span> <span class="string">"1"</span> <span class="special">)</span> <span class="special">);</span> <span class="comment">// No effect! +</span><span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span> <span class="number">2</span><span class="special">,</span> <span class="string">"one"</span> <span class="special">)</span> <span class="special">);</span> <span class="comment">// No effect! +</span> +<span class="identifier">assert</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special">==</span> <span class="number">1</span> <span class="special">);</span> +</pre> +<a name="boost_bimap.one_minute_tutorial.a_simple_example"></a><h4> +<a name="id772905"></a> + <a class="link" href="one_minute_tutorial.html#boost_bimap.one_minute_tutorial.a_simple_example">A simple example</a> + </h4> +<p> + Look how you can reuse code that is intend to be used with std::maps, like + the print_map function in this example. + </p> +<p> + <a href="../../../example/simple_bimap.cpp" target="_top">Go to source code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">string</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> + +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">MapType</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">print_map</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">MapType</span> <span class="special">&</span> <span class="identifier">map</span><span class="special">,</span> + <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&</span> <span class="identifier">separator</span><span class="special">,</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span> <span class="special">&</span> <span class="identifier">os</span> <span class="special">)</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">MapType</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">const_iterator</span><span class="special">;</span> + + <span class="keyword">for</span><span class="special">(</span> <span class="identifier">const_iterator</span> <span class="identifier">i</span> <span class="special">=</span> <span class="identifier">map</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">iend</span> <span class="special">=</span> <span class="identifier">map</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">iend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">os</span> <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">first</span> <span class="special"><<</span> <span class="identifier">separator</span> <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">second</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="comment">// Soccer World cup +</span> + <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">></span> <span class="identifier">results_bimap</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">results_bimap</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">position</span><span class="special">;</span> + + <span class="identifier">results_bimap</span> <span class="identifier">results</span><span class="special">;</span> + <span class="identifier">results</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">position</span><span class="special">(</span><span class="string">"Argentina"</span> <span class="special">,</span><span class="number">1</span><span class="special">)</span> <span class="special">);</span> + <span class="identifier">results</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">position</span><span class="special">(</span><span class="string">"Spain"</span> <span class="special">,</span><span class="number">2</span><span class="special">)</span> <span class="special">);</span> + <span class="identifier">results</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">position</span><span class="special">(</span><span class="string">"Germany"</span> <span class="special">,</span><span class="number">3</span><span class="special">)</span> <span class="special">);</span> + <span class="identifier">results</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">position</span><span class="special">(</span><span class="string">"France"</span> <span class="special">,</span><span class="number">4</span><span class="special">)</span> <span class="special">);</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"The number of countries is "</span> <span class="special"><<</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"The winner is "</span> <span class="special"><<</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">at</span><span class="special">(</span><span class="number">1</span><span class="special">)</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Countries names ordered by their final position:"</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + + <span class="comment">// results.right works like a std::map< int, std::string > +</span> + <span class="identifier">print_map</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">right</span><span class="special">,</span> <span class="string">") "</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">);</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span> + <span class="special"><<</span> <span class="string">"Countries names ordered alphabetically along with"</span> + <span class="string">"their final position:"</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + + <span class="comment">// results.left works like a std::map< std::string, int > +</span> + <span class="identifier">print_map</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">left</span><span class="special">,</span> <span class="string">" ends in position "</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">);</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + The output of this program will be the following: + </p> +<pre class="programlisting"><code class="literal">The number of countries is 4</code> + +<code class="literal">The winner is Argentina</code> + +<code class="literal">Countries names ordered by their final position:</code> +<code class="literal">1) Argentina</code> +<code class="literal">2) Spain</code> +<code class="literal">3) Germany</code> +<code class="literal">4) France</code> + +<code class="literal">Countries names ordered alphabetically along with their final position:</code> +<code class="literal">Argentina ends in position 1</code> +<code class="literal">France ends in position 4</code> +<code class="literal">Germany ends in position 3</code> +<code class="literal">Spain ends in position 2</code> +</pre> +<a name="boost_bimap.one_minute_tutorial.continuing_the_journey"></a><h4> +<a name="id774177"></a> + <a class="link" href="one_minute_tutorial.html#boost_bimap.one_minute_tutorial.continuing_the_journey">Continuing + the journey</a> + </h4> +<p> + For information on function signatures, see any standard library documentation + or read the <a class="link" href="reference.html" title="Reference">reference</a> section + of this documentation. + </p> +<div class="caution"><table border="0" summary="Caution"> +<tr> +<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../doc/src/images/caution.png"></td> +<th align="left">Caution</th> +</tr> +<tr><td align="left" valign="top"><p> + Be aware that a bidirectional map is only signature-compatible with standard + containers. Some functions may give different results, such as in the case + of inserting a pair into the left map where the second value conflicts with + a stored relation in the container. The functions may be slower in a bimap + because of the duplicated constraints. It is strongly recommended that you + read <a class="link" href="the_tutorial.html" title="The tutorial">The full tutorial</a> if + you intend to use a bimap in a serious project. + </p></td></tr> +</table></div> +<div class="footnotes"> +<br><hr width="100" align="left"> +<div class="footnote"><p><sup>[<a id="ftn.id769748" href="#id769748" class="para">1</a>] </sup> + A type is <span class="emphasis"><em>signature-compatible</em></span> with other type if it + has the same signature for functions and metadata. Preconditions, postconditions + and the order of operations need not be the same. + </p></div> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="introduction.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="the_tutorial.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/performance.html b/libs/bimap/doc/html/boost_bimap/performance.html new file mode 100644 index 0000000000..2163b0ba46 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/performance.html @@ -0,0 +1,46 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Performance</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="prev" href="compiler_specifics.html" title="Compiler specifics"> +<link rel="next" href="examples.html" title="Examples"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> +<td align="center"><a href="../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="compiler_specifics.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="examples.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="boost_bimap.performance"></a><a class="link" href="performance.html" title="Performance">Performance</a> +</h2></div></div></div> +<p> + Section under construction. + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="compiler_specifics.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="examples.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/rationale.html b/libs/bimap/doc/html/boost_bimap/rationale.html new file mode 100644 index 0000000000..7527943eec --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/rationale.html @@ -0,0 +1,298 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Rationale</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="prev" href="release_notes.html" title="Release notes"> +<link rel="next" href="rationale/additional_features.html" title="Additional Features"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> +<td align="center"><a href="../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="release_notes.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="rationale/additional_features.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="boost_bimap.rationale"></a><a class="link" href="rationale.html" title="Rationale">Rationale</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="rationale.html#boost_bimap.rationale.general_design">General Design</a></span></dt> +<dt><span class="section"><a href="rationale/additional_features.html">Additional + Features</a></span></dt> +<dt><span class="section"><a href="rationale/code.html">Code</a></span></dt> +<dt><span class="section"><a href="rationale/the_student_and_the_mentor.html">The + student and the mentor</a></span></dt> +</dl></div> +<p> + This section assumes that you have read all other sections, the most of important + of which being <span class="emphasis"><em>tutorial</em></span>, <span class="emphasis"><em>std::set theory</em></span> + and the <span class="emphasis"><em>reference</em></span>, and that you have tested the library. + A lot of effort was invested in making the interface as intuitive and clean + as possible. If you understand, and hopefully like, the interface of this library, + it will be a lot easier to read this rationale. The following section is little + more than a rationale. This library was coded in the context of the Google + SoC 2006 and the student and mentor were in different continents. A great deal + of email flowed between Joaquin and Matias. The juiciest parts of the conversations + where extracted and rearranged here. + </p> +<div class="note"><table border="0" summary="Note"> +<tr> +<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td> +<th align="left">Note</th> +</tr> +<tr><td align="left" valign="top"><p> + To browse the code, you can use the <a href="../doxydoc/index.html" target="_top"><span class="emphasis"><em>Bimap + Complete Reference</em></span></a>, a doxygen-powered document targeted + at developers. + </p></td></tr> +</table></div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.rationale.general_design"></a><a class="link" href="rationale.html#boost_bimap.rationale.general_design" title="General Design">General Design</a> +</h3></div></div></div> +<p> + The initial explanation includes few features. This section aims to describe + the general design of the library and excludes details of those features + that are of lesser importance; these features will be introduced later. + </p> +<p> + The design of the library is divided into two parts. The first is the construction + of a <code class="literal">relation</code> class. This will be the object stored and + managed by the <code class="literal">multi_index_container</code> core. The idea is + to make this class as easy as possible to use, while making it efficient + in terms of memory and access time. This is a cornerstone in the design of + <span class="bold"><strong>Boost.Bimap</strong></span> and, as you will see in this + rationale, the rest of the design follows easily. + </p> +<p> + The following interface is necessary for the <code class="literal">relation</code> + class: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="special">-</span><span class="identifier">unspecified</span><span class="special">-</span> <span class="identifier">TA</span><span class="special">;</span> <span class="keyword">typedef</span> <span class="special">-</span><span class="identifier">unspecified</span><span class="special">-</span> <span class="identifier">TB</span><span class="special">;</span> + +<span class="identifier">TA</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">ai</span><span class="special">;</span> <span class="identifier">TB</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">bi</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">relation</span><span class="special"><</span> <span class="identifier">TA</span><span class="special">,</span> <span class="identifier">TB</span> <span class="special">></span> <span class="identifier">rel</span><span class="special">;</span> +<span class="identifier">STATIC_ASSERT</span><span class="special">(</span> <span class="identifier">is_same</span><span class="special"><</span> <span class="identifier">rel</span><span class="special">::</span><span class="identifier">left_type</span> <span class="special">,</span> <span class="identifier">TA</span> <span class="special">>::</span><span class="identifier">value</span> <span class="special">);</span> +<span class="identifier">STATIC_ASSERT</span><span class="special">(</span> <span class="identifier">is_same</span><span class="special"><</span> <span class="identifier">rel</span><span class="special">::</span><span class="identifier">right_type</span><span class="special">,</span> <span class="identifier">TB</span> <span class="special">>::</span><span class="identifier">value</span> <span class="special">);</span> + +<span class="identifier">rel</span> <span class="identifier">r</span><span class="special">(</span><span class="identifier">ai</span><span class="special">,</span><span class="identifier">bi</span><span class="special">);</span> +<span class="identifier">assert</span><span class="special">(</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">left</span> <span class="special">==</span> <span class="identifier">ai</span> <span class="special">&&</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">right</span> <span class="special">==</span> <span class="identifier">bi</span> <span class="special">);</span> + +<span class="identifier">r</span><span class="special">.</span><span class="identifier">left</span> <span class="special">=</span> <span class="identifier">a</span><span class="special">;</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">right</span> <span class="special">=</span> <span class="identifier">b</span><span class="special">;</span> +<span class="identifier">assert</span><span class="special">(</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">left</span> <span class="special">==</span> <span class="identifier">a</span> <span class="special">&&</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">right</span> <span class="special">==</span> <span class="identifier">b</span> <span class="special">);</span> + +<span class="keyword">typedef</span> <span class="identifier">pair_type_by</span><span class="special"><</span> <span class="identifier">member_at</span><span class="special">::</span><span class="identifier">left</span> <span class="special">,</span> <span class="identifier">rel</span> <span class="special">>::</span><span class="identifier">type</span> <span class="identifier">pba_type</span><span class="special">;</span> +<span class="identifier">STATIC_ASSERT</span><span class="special">(</span> <span class="identifier">is_same</span><span class="special"><</span> <span class="identifier">pba_type</span><span class="special">::</span><span class="identifier">first_type</span> <span class="special">,</span> <span class="identifier">TA</span> <span class="special">>::</span><span class="identifier">value</span> <span class="special">);</span> +<span class="identifier">STATIC_ASSERT</span><span class="special">(</span> <span class="identifier">is_same</span><span class="special"><</span> <span class="identifier">pba_type</span><span class="special">::</span><span class="identifier">second_type</span><span class="special">,</span> <span class="identifier">TB</span> <span class="special">>::</span><span class="identifier">value</span> <span class="special">);</span> + +<span class="keyword">typedef</span> <span class="identifier">pair_type_by</span><span class="special"><</span> <span class="identifier">member_at</span><span class="special">::</span><span class="identifier">right</span><span class="special">,</span> <span class="identifier">rel</span> <span class="special">>::</span><span class="identifier">type</span> <span class="identifier">pbb_type</span><span class="special">;</span> +<span class="identifier">STATIC_ASSERT</span><span class="special">(</span> <span class="identifier">is_same</span><span class="special"><</span> <span class="identifier">pbb_type</span><span class="special">::</span><span class="identifier">first_type</span> <span class="special">,</span> <span class="identifier">TB</span> <span class="special">>::</span><span class="identifier">value</span> <span class="special">);</span> +<span class="identifier">STATIC_ASSERT</span><span class="special">(</span> <span class="identifier">is_same</span><span class="special"><</span> <span class="identifier">pbb_type</span><span class="special">::</span><span class="identifier">second_type</span><span class="special">,</span> <span class="identifier">TA</span> <span class="special">>::</span><span class="identifier">value</span> <span class="special">);</span> + +<span class="identifier">pba_type</span> <span class="identifier">pba</span> <span class="special">=</span> <span class="identifier">pair_by</span><span class="special"><</span> <span class="identifier">member_at</span><span class="special">::</span><span class="identifier">left</span> <span class="special">>(</span><span class="identifier">r</span><span class="special">);</span> +<span class="identifier">assert</span><span class="special">(</span> <span class="identifier">pba</span><span class="special">.</span><span class="identifier">first</span> <span class="special">==</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">left</span> <span class="special">&&</span> <span class="identifier">pba</span><span class="special">.</span><span class="identifier">second</span> <span class="special">==</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">right</span> <span class="special">);</span> + +<span class="identifier">pbb_type</span> <span class="identifier">pbb</span> <span class="special">=</span> <span class="identifier">pair_by</span><span class="special"><</span> <span class="identifier">member_at</span><span class="special">::</span><span class="identifier">right</span> <span class="special">>(</span><span class="identifier">r</span><span class="special">);</span> +<span class="identifier">assert</span><span class="special">(</span> <span class="identifier">pbb</span><span class="special">.</span><span class="identifier">first</span> <span class="special">==</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">right</span> <span class="special">&&</span> <span class="identifier">pbb</span><span class="special">.</span><span class="identifier">second</span> <span class="special">==</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">left</span> <span class="special">);</span> +</pre> +<p> + <span class="inlinemediaobject"><img src="../images/bimap/relation.png" alt="relation"></span> + </p> +<p> + Although this seems straightforward, as will be seen later, it is the most + difficult code hack of the library. It is indeed very easy if we relax some + of the efficiency constraints. For example, it is trivial if we allow a relation + to have greater size than the the sum of those of its components. It is equally + simple if access speed is not important. One of the first decisions made + about <span class="bold"><strong>Boost.Bimap</strong></span> was, however, that, in + order to be useful, it had to achieve zero overhead over the wrapped <span class="bold"><strong>Boost.MultiIndex</strong></span> container. Finally, there is another + constraint that can be relaxed: conformance to C++ standards, but this is + quite unacceptable. Let us now suppose that we have coded this class, and + it conforms to what was required. + </p> +<p> + The second part is based on this <code class="literal">relation</code> class. We can + now view the data in any of three ways: <code class="computeroutput"><span class="identifier">pair</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span></code>, + <code class="computeroutput"><span class="identifier">relation</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span></code> and <code class="computeroutput"><span class="identifier">pair</span><span class="special"><</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">A</span><span class="special">></span></code>. + Suppose that our bimap supports only one-to-one relations. (Other relation + types are considered additional features in this design.) The proposed interface + is very simple, and it is based heavily on the concepts of the STL. Given + a <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span> <span class="identifier">bm</span></code>: + </p> +<div class="orderedlist"><ol class="orderedlist" type="1"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span></code> is signature-compatible with a + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span></code> is signature-compatible with + a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">A</span><span class="special">></span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">bm</span></code> is signature-compatible + with a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span><span class="special"><</span><span class="identifier">relation</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span> <span class="special">></span></code> + </li> +</ol></div> +<p> + <span class="inlinemediaobject"><img src="../images/bimap/simple.bimap.png" alt="simple.bimap"></span> + </p> +<p> + This interface is easily learned by users who have a STL background, as well + as being simple and powerful. This is the general design. + </p> +<a name="boost_bimap.rationale.general_design.relation_implementation"></a><h5> +<a name="id883219"></a> + <a class="link" href="rationale.html#boost_bimap.rationale.general_design.relation_implementation">Relation + Implementation</a> + </h5> +<p> + This section explains the details of the actual <code class="literal">relation</code> + class implementation. + </p> +<p> + The first thing that we can imagine is the use of an <code class="literal">union</code>. + Regrettably, the current C++ standard only allows unions of POD types. For + the views, we can try a wrapper around a <code class="computeroutput"><span class="identifier">relation</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span></code> that + has two references named first and second that bind to <code class="computeroutput"><span class="identifier">A</span></code> + and <code class="computeroutput"><span class="identifier">B</span></code>, or to <code class="computeroutput"><span class="identifier">B</span></code> and <code class="computeroutput"><span class="identifier">A</span></code>. + </p> +<pre class="programlisting"><span class="identifier">relation</span><span class="special"><</span><span class="identifier">TA</span><span class="special">,</span><span class="identifier">TB</span><span class="special">></span> <span class="identifier">r</span><span class="special">;</span> + +<span class="identifier">const_reference_pair</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span> <span class="identifier">pba</span><span class="special">(</span><span class="identifier">r</span><span class="special">);</span> +<span class="identifier">const_reference_pair</span><span class="special"><</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">A</span><span class="special">></span> <span class="identifier">pbb</span><span class="special">(</span><span class="identifier">r</span><span class="special">);</span> +</pre> +<p> + It is not difficult to code the relation class using this, but two references + are initialized at every access and using of <code class="computeroutput"><span class="identifier">pba</span><span class="special">.</span><span class="identifier">first</span></code> + will be slower in most compilers than using <code class="computeroutput"><span class="identifier">r</span><span class="special">.</span><span class="identifier">left</span></code> directly + . There is another hidden drawback of using this scheme: it is not iterator-friendly, + since the map views iterators must be degraded to <span class="emphasis"><em>Read Write</em></span> + instead of <span class="emphasis"><em>LValue</em></span>. This will be explained later. + </p> +<p> + At first, this seems to be the best we can do with the current C++ standard. + However there is a solution to this problem that does not conform very well + to C++ standards but does achieve zero overhead in terms of access time and + memory, and additionally allows the view iterators to be upgraded to <span class="emphasis"><em>LValue</em></span> + again. + </p> +<p> + In order to use this, the compiler must conform to a layout-compatibility + clause that is not currently in the standard but is very natural. The additional + clause imposes that if we have two classes: + </p> +<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">class_a_b</span> +<span class="special">{</span> + <span class="identifier">Type1</span> <span class="identifier">name_a</span><span class="special">;</span> + <span class="identifier">Type2</span> <span class="identifier">name_b</span><span class="special">;</span> +<span class="special">};</span> + +<span class="keyword">struct</span> <span class="identifier">class_b_a</span> +<span class="special">{</span> + <span class="identifier">Type1</span> <span class="identifier">name_b</span><span class="special">;</span> + <span class="identifier">Type2</span> <span class="identifier">name_a</span><span class="special">;</span> +<span class="special">};</span> +</pre> +<p> + then the storage layout of <code class="literal">class_a_b</code> is equal to the storage + layout of <code class="literal">class_b_a</code>. If you are surprised to learn that + this does not hold in a standards-compliant C++ compiler, welcome to the + club. It is the natural way to implement it from the point of view of the + compiler's vendor and is very useful for the developer. Maybe it will be + included in the standard some day. Every current compiler conforms to this. + </p> +<p> + If we are able to count on this, then we can implement an idiom called <code class="literal">mutant</code>. + The idea is to provide a secure wrapper around <code class="literal">reinterpret_cast</code>. + A class can declare that it can be viewed using different view classes that + are storage-compatible with it. Then we use the free function <code class="literal">mutate<view>(mutant)</code> + to get the view. The <code class="computeroutput"><span class="identifier">mutate</span></code> + function checks at compile time that the requested view is declared in the + mutant views list. We implement a class name <code class="computeroutput"><span class="identifier">structured_pair</span></code> + that is signature-compatible with a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span></code>, + while the storage layout is configured with a third template parameter. Two + instances of this template class will provide the views of the relation. + </p> +<p> + The thing is that if we want to be standards-compliant, we cannot use this + approach. It is very annoying not to be able to use something that we know + will work with every compiler and that is far better than alternatives. So + -- and this is an important decision -- we have to find a way to use it and + still make the library standards-compliant. + </p> +<p> + The idea is very simple. We code both approaches: the const_reference_pair-based + and the mutant-based, and use the mutant approach if the compiler is compliant + with our new layout-compatible clause. If the compiler really messes things + up, we degrade the performance of the bimap a little. The only drawback here + is that, while the mutant approach allows to make <span class="emphasis"><em>LValue</em></span> + iterators, we have to degrade them to <span class="emphasis"><em>Read Write</em></span> in + both cases, because we require that the same code be compilable by any standards-compliant + compiler. + </p> +<div class="note"><table border="0" summary="Note"> +<tr> +<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td> +<th align="left">Note</th> +</tr> +<tr><td align="left" valign="top"><p> + Testing this approach in all the supported compilers indicated that the + mutant idiom was always supported. The strictly compliant version was removed + from the code because it was never used. + </p></td></tr> +</table></div> +<a name="boost_bimap.rationale.general_design.bimap_implementation"></a><h5> +<a name="id883786"></a> + <a class="link" href="rationale.html#boost_bimap.rationale.general_design.bimap_implementation">Bimap + Implementation</a> + </h5> +<p> + The core of bimap will be obviously a <code class="computeroutput"><span class="identifier">multi_index_container</span></code>. + The basic idea to tackle the implementation of the bimap class is to use + <code class="literal">iterator_adaptor</code> to convert the iterators from Boost.MultiIndex + to the <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span></code> and <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span></code> behaviour. + The <code class="computeroutput"><span class="identifier">map_view</span></code> and the <code class="computeroutput"><span class="identifier">set_view</span></code> can be implemented directly using + this new transformed iterators and a wrapper around each index of the core + container. However, there is a hidden idiom here, that, once coded, will + be very useful for other parts of this library and for Boost.MRU library. + Following the ideas from <code class="computeroutput"><span class="identifier">iterator_adaptor</span></code>, + Boost.Bimap views are implemented using a <code class="literal">container_adaptor</code>. + There are several template classes (for example <code class="computeroutput"><span class="identifier">map_adaptor</span></code> + and <code class="computeroutput"><span class="identifier">set_adaptor</span></code>) that take + a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span></code> signature-conformant class and new + iterators, and adapt the container so it now uses this iterators instead + of the originals. For example, if you have a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span><span class="special"><</span><span class="keyword">int</span><span class="special">*></span></code>, + you can build other container that behaves exactly as a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span></code> using + <code class="computeroutput"><span class="identifier">set_adaptor</span></code> and <code class="literal">iterator_adaptor</code>. + The combined use of this two tools is very powerful. A <code class="literal">container_adaptor</code> + can take classes that do not fulfil all the requirements of the adapted container. + The new container must define these missing functions. + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="release_notes.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="rationale/additional_features.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/rationale/additional_features.html b/libs/bimap/doc/html/boost_bimap/rationale/additional_features.html new file mode 100644 index 0000000000..930791182f --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/rationale/additional_features.html @@ -0,0 +1,139 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Additional Features</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../rationale.html" title="Rationale"> +<link rel="prev" href="../rationale.html" title="Rationale"> +<link rel="next" href="code.html" title="Code"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../rationale.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../rationale.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="code.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.rationale.additional_features"></a><a class="link" href="additional_features.html" title="Additional Features">Additional + Features</a> +</h3></div></div></div> +<a name="boost_bimap.rationale.additional_features.n_1__n_n__hashed_maps"></a><h5> +<a name="id884065"></a> + <a class="link" href="additional_features.html#boost_bimap.rationale.additional_features.n_1__n_n__hashed_maps">N-1, + N-N, hashed maps</a> + </h5> +<p> + This is a very interesting point of the design. The framework introduced + in <span class="emphasis"><em>std::set theory</em></span> permits the management of the different + constraints with a very simple and conceptual approach. It is easy both to + remember and to learn. The idea here is to allow the user to specify the + collection type of each key directly. In order to implement this feature, + we have to solve two problems: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + The index types of the <code class="computeroutput"><span class="identifier">multi_index_container</span></code> + core now depends on the collection type used for each key. + </li> +<li class="listitem"> + The map views now change their semantics according to the collection + type chosen. + </li> +</ul></div> +<p> + Boost.Bimap relies heavily on Boost.MPL to implement all of the metaprogramming + necessary to make this framework work. By default, if the user does not specify + the kind of the set, a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span></code> type + is used. + </p> +<p> + <span class="inlinemediaobject"><img src="../../images/bimap/bimap.structures.png" alt="bimap.structures"></span> + </p> +<a name="boost_bimap.rationale.additional_features.collection_type_of_relation_constraints"></a><h5> +<a name="id884180"></a> + <a class="link" href="additional_features.html#boost_bimap.rationale.additional_features.collection_type_of_relation_constraints">Collection + type of relation constraints</a> + </h5> +<p> + The constraints of the bimap set view are another very important feature. + In general, Boost.Bimap users will base the set view type on one of the two + collection types of their keys. It may be useful however to give this set + other constraints or simply to order it differently. By default, Boost.Bimap + bases the collection type of relations on the left collection type, but the + user may choose between: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + left_based + </li> +<li class="listitem"> + right_based + </li> +<li class="listitem"> + set_of_relation<> + </li> +<li class="listitem"> + multiset_of_relation<> + </li> +<li class="listitem"> + unordered_set_of_relation<> + </li> +<li class="listitem"> + unordered_multiset_of_relation<> + </li> +<li class="listitem"> + list_of + </li> +<li class="listitem"> + vector_of + </li> +</ul></div> +<p> + In the first two cases, there are only two indices in the <code class="computeroutput"><span class="identifier">multi_index_core</span></code>, + and for this reason, these are the preferred options. The implementation + uses further metaprogramming to define a new index if necessary. + </p> +<a name="boost_bimap.rationale.additional_features.tagged"></a><h5> +<a name="id884293"></a> + <a class="link" href="additional_features.html#boost_bimap.rationale.additional_features.tagged">Tagged</a> + </h5> +<p> + The idea of using tags instead of the <code class="literal">member_at::side</code> + idiom is very appealing since code that uses it is more readable. The only + cost is compile time. <span class="emphasis"><em>boost/bimap/tagged</em></span> is the implementation + of a non-invasive tagged idiom. The <code class="literal">relation</code> class is + built in such a way that even when the user uses tags, the <code class="literal">member_at::side</code> + idiom continues to work. This is good since an user can start tagging even + before completing the coding of the algorithm, and the untagged code continues + to work. The development becomes a little more complicated when user-defined + tags are included, but there are many handy metafunctions defined in the + <code class="literal">tagged</code> idiom that help to keep things simple enough. + </p> +<p> + <span class="inlinemediaobject"><img src="../../images/bimap/tagged.png" alt="tagged"></span> + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../rationale.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../rationale.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="code.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/rationale/code.html b/libs/bimap/doc/html/boost_bimap/rationale/code.html new file mode 100644 index 0000000000..28115bd809 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/rationale/code.html @@ -0,0 +1,198 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Code</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../rationale.html" title="Rationale"> +<link rel="prev" href="additional_features.html" title="Additional Features"> +<link rel="next" href="the_student_and_the_mentor.html" title="The student and the mentor"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="additional_features.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../rationale.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="the_student_and_the_mentor.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.rationale.code"></a><a class="link" href="code.html" title="Code">Code</a> +</h3></div></div></div> +<p> + You can browse the code using the <a href="../../doxydoc/index.html" target="_top"><span class="bold"><strong>Boost.Bimap doxygen docs</strong></span></a>. + </p> +<p> + The code follows the <a href="http://www.boost.org/more/lib_guide.htm" target="_top">Boost + Library Requirement and Guidelines</a> as closely as possible. + </p> +<div class="table"> +<a name="id884408"></a><p class="title"><b>Table 1.10. folders in boost/bimap</b></p> +<div class="table-contents"><table class="table" summary="folders in boost/bimap"> +<colgroup> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + name + </p> + </th> +<th> + <p> + what is inside? + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + user level header files + </p> + </td> +<td class="auto-generated"> </td> +</tr> +<tr> +<td> + <p> + tagged/ + </p> + </td> +<td> + <p> + tagged idiom + </p> + </td> +</tr> +<tr> +<td> + <p> + relation/ + </p> + </td> +<td> + <p> + the bimap data + </p> + </td> +</tr> +<tr> +<td> + <p> + container_adaptor/ + </p> + </td> +<td> + <p> + easy way of adapting containers + </p> + </td> +</tr> +<tr> +<td> + <p> + views/ + </p> + </td> +<td> + <p> + bimap views + </p> + </td> +</tr> +<tr> +<td> + <p> + property_map/ + </p> + </td> +<td> + <p> + support for property map concept + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="id884547"></a><p class="title"><b>Table 1.11. folders in each folder</b></p> +<div class="table-contents"><table class="table" summary="folders in each folder"> +<colgroup> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + name + </p> + </th> +<th> + <p> + what is inside? + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + </td> +<td> + <p> + class definitions + </p> + </td> +</tr> +<tr> +<td> + <p> + support/ + </p> + </td> +<td> + <p> + optional metafunctions and free functions + </p> + </td> +</tr> +<tr> +<td> + <p> + detail/ + </p> + </td> +<td> + <p> + things not intended for the user's eyes + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="additional_features.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../rationale.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="the_student_and_the_mentor.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/rationale/the_student_and_the_mentor.html b/libs/bimap/doc/html/boost_bimap/rationale/the_student_and_the_mentor.html new file mode 100644 index 0000000000..d2bd8d0a3a --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/rationale/the_student_and_the_mentor.html @@ -0,0 +1,763 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>The student and the mentor</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../rationale.html" title="Rationale"> +<link rel="prev" href="code.html" title="Code"> +<link rel="next" href="../history.html" title="History"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="code.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../rationale.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../history.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.rationale.the_student_and_the_mentor"></a><a class="link" href="the_student_and_the_mentor.html" title="The student and the mentor">The + student and the mentor</a> +</h3></div></div></div> +<div class="tip"><table border="0" summary="Tip"> +<tr> +<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../../doc/src/images/tip.png"></td> +<th align="left">Tip</th> +</tr> +<tr><td align="left" valign="top"><p> + It is a good idea to read the original <a href="http://h1.ripway.com/mcape/boost/libs/misc/" target="_top">Boost.Misc + SoC proposal</a> first. + </p></td></tr> +</table></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <code class="literal">- The discussion starts with Joaquin trying to strip out the "misc" + name out of the library -</code> + </p></blockquote></div> +<p> + <span class="inlinemediaobject"><img src="../../images/people/joaquin.png" alt="joaquin"></span> + </p> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Thinking about it, the unifying principle of MISC containers + is perhaps misleading: certainly all miscs use multi-indexing internally, + but this does not reflect much in the external interface (as it should + be, OTOH). So, from the user's point of view, miscs are entirely heterogeneous + beasts. Moreover, there isn't in your proposal any kind of global facility + common to all miscs. What about dropping the misc principle and working + on each container as a separate library, then? You'd have boost::bimap, + boost::mru, etc, and no common intro to them. This also opens up the possibility + to add other containers to the suite which aren't based on B.MI. What's + your stance on this? Do you see a value in keeping miscs conceptually together? + </em></span> + </p></blockquote></div> +<p> + <span class="inlinemediaobject"><img src="../../images/people/matias.png" alt="matias"></span> + </p> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> As the original proposal states only two containers (bimap and + mru set) both based in B.MI, it was straight forward to group them together. + When I was writing the SoC proposal I experienced a similar feeling when + the two families begin to grow. As you say, the only common denominator + is their internal implementation. I thought a bit about a more general + framework to join this two families (and other internally related ones) + and finally came up with an idea: Boost.MultiIndex! So I think that it + is not a good idea to try to unify the two families and I voted in favor + of get rid of the misc part of boost::misc::bimap and boost::misc::mru. + Anyway, for my SoC application it seems OK to put the two families in the + same project because although from the outside they are completely unrelated, + the work I will have to do in order to build the libraries will be consistent + and what I will learn coding the bimap family will be used when I start + to code the mru family. When the mru family is in place, I will surely + have learnt other things to improve the bimap group. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> On the other hand, I think it will be useful for the general + user to have at least some document linked in the B.MI documentation that + enumerates the most common cases of uses (a bimap and an mru set for example) + and points where to find clean implementation for this useful containers. + For now, a link to boost::bimap and other one to boost::mru will suffice. + If you think about the title of such a document, you will probably come + up with something like: Common Multi Index Specialized Containers, and + we are back to our misc proposal. So, to order some ideas: </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- A new family of containers that can be accessed by both key + will be created. (boost::bimap)</em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- A new family of time aware containers will see the light. (boost::mru)</em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- A page can be added to B.MI documentation, titled misc that + links this new libraries.</em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> This is a clearer framework for the user. They can use a mru + container without hearing about Boost.MultiIndex at all. And B.MI users + will get some of their common containers already implemented with an STL + friendly interface in other libraries. And as you stated this is more extensible + because opens the door to use other libraries in bimap and mru families + than just Boost.MultiIndex without compromising the more general boost + framework. The word "misc" it is going to disappear from the + code and the documentation of bimap and mru. From now on the only use for + it will be to identify our SoC project. I am thinking in a name for the + bimap library. What about Boost.BidirectionalMap? Ideas? </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Yes, Boost.Bimap. In my opinion, bimap is a well known name + in the Boost and even in the C++ community. It sounds and is short. Why + not to vindicate yourself as the owner of this name? </em></span> + </p></blockquote></div> +<p> + <code class="literal">- Then after a week of work -</code> + </p> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Now that Boost.Bimap is getting some shape, I see that as you + have told me, we must offer a "one_to_many_map" and a "multi_bimap" + as part of the library. The framework I am actually working allowed to + construct this kind of bidirectional maps and it is easy to understand + from the user side. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> OK, I am glad we agree on this point. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> With respect to the symmetry of the key access names, I have + to agree that there is not much a difference between the following ones: + </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- to - from</em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- to - b</em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- 0 - 1</em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- left - right</em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> In my opinion it is a matter of taste, but left/right sounds + more symmetrical than the others. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I like very much the left/right notation, it is very simple + to remember and it is a lot more symmetrical than to/from. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> At first my idea was to obtain ease of use hiding the B.MI core, + making it more STL-intuitive. Nevertheless I have realized that B.MI is + a lot more coherent and easy to use that I had imagined. This makes me + think again in the problem. In the design that I am coding now, bimap + <span class="bold"><strong>is-a</strong></span> multi_index_container specializes + with a data type very comfortable called bipair, that can be seen like + any of the two maps that integrates it using map views. This scheme has + great benefits for users: </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> - If the user already knows B.MI, he can take advantage of the + tools that it provides and that are not present in the STL containers. + In addition, in some cases the use to indices to see the data can be very + useful. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> - If the user does not know anything about B.MI but have an + STL framework, the learning curve is reduced to understand the bimap instantiation + and how a is obtained the desired map view. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Another very important benefit holds: All the algorithms done + for B.MI continues to work with Boost.Bimap and if B.MI continues growing, + bimap grow automatically. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Umm... This is an interesting design decision, but controversial + in my opinion. Basically you decide to expose the implementation of bimap; + that has advantages, as you stated, but also a nonsmall disadvantage: once + <span class="bold"><strong>you have documented</strong></span> the implementation, + it is not possible to change it anymore. It is a marriage with B.MI without + the chance of divorce. The other possibility, to hide the implementation + and to duplicate and document the provided functionality, explicitly or + implicitly due to the same characteristics of the implementation, is of + course heavier to maintain, but it gives a degree of freedom to change + the guts of your software if you need to. Do not take this like a frontal + objection, but I think that it is quite important design decision, not + only in the context of bimap but in general. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> You are quite right here. I think we have to choose the hardest + path and hide the B.MI core from the user. I am sending you the first draft + of bimap along with some documentation. </em></span> + </p></blockquote></div> +<p> + <code class="literal">- This completes the second week, the documentation was basically + the first section of this rationale -</code> + </p> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I must confess that I am beginning to like what I see. I am + mathematical by vocation, and when I see symmetry in a formulation I believe + that it is in the right track. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> We are two mathematicians by vocation then. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I think that the part of std::set theory is very clear. To me, + it turns out to me somewhat strange to consider the rank of a map (values + X) like a std::set, but of course the formulation is consistent. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I like it very much, it can be a little odd at first, but now + that I have get used to it, it is very easy to express in the code my contrains + on the data, and I believe that if somebody reads the code and sees the + bimap instantiation he is not going to have problems understanding it. + Perhaps it is easier to understand it if we use your notation: ordered_nonunique, + unordered_unique, but this goes against our STL facade. In my opinion the + user that comes from STL must have to learn as less as possible. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Considering a relation like a <code class="computeroutput"><span class="keyword">struct</span> + <span class="special">{</span><span class="identifier">left</span><span class="special">,</span> <span class="identifier">right</span><span class="special">}</span></code> is clean and clear. If I understand it + well, one relation has views of type <code class="computeroutput"><span class="identifier">pair</span><span class="special">{</span><span class="identifier">first</span><span class="special">,</span> <span class="identifier">second</span><span class="special">}</span></code>, is this correct? </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Yes, I believe that the left/right notation to express symmetry + is great. I believe that to people is going to love it. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> OK, perfect. I likes this very much: </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- bm.left is compatible with std::map<A,B></em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- bm.right is compatible with std::map<B,A></em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- bm is compatible with std::set<relation<A,B>></em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> It is elegant and symmetric. I feel good vibrations here. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Great! </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Moving on, the support for N-1, N-N, and hashed index is very + easy to grasp, and it fits well in framework. However I do not finish to + understand very well the "set<relation> constraints" section. + Will you came up with some examples of which is the meaning of the different + cases that you enumerate? </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias - </strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Yes, I mean: </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- based on the left</em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- based on the right</em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> The bimap core must be based on some index of multi index. If + the index of the left is of the type hash, then in fact the main view is + going to be an unordered_set< relation<A,B> >. Perhaps this + is not what the user prefers and he wants to base its main view on the + right index. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- set_of_relation </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- multiset_of_relation </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- unordered_set_of_relation </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em>- unordered_multiset_of_relation </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> However, if both of them are hash indexes, the user may want + the main view to be ordered. As we have a B.MI core this is very easy to + support, we just have to add another index to it. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I understand it now. OK, I do not know if we have to include + this in the first version, is going to be a functionality avalanche! </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> The user is not affected by the addition of this functionality, + because by default it will be based on the left index that is a very natural + behaviour. I do not think that this is functionality bloat, but I agree + with you that it is a functionality avalanche. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> There are restrictions between the left and right set types + and the possible main view set types. For example if some of the index + is of unique type, then the main view cannot be of type multiset_of_relation. + To the inverse one, if the main view is of type set_of_relation the left + and the right index cannot be of type multi_set. All this subject of the + unicity constrictions and the resulting interactions between indexes is + one of the subtle subjects of B.MI. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> This can be checked at compile time and informed as an error + in compile time. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> It can be interesting. </em></span> + </p></blockquote></div> +<p> + <code class="literal">- And right when everything seems to be perfect... - </code> + </p> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I have some worse news with respect to mutant, it is very a + well designed and manageable class, unfortunately, C++ does not guarantee + layout-compatibility almost in any case. For example, the C++ standard + does not guarantee that the classes <code class="computeroutput"><span class="keyword">struct</span><span class="special">{</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">;</span> <span class="identifier">T2</span> + <span class="identifier">b</span><span class="special">;}</span></code> + and <code class="computeroutput"><span class="keyword">struct</span><span class="special">{</span><span class="identifier">T1</span> <span class="identifier">b</span><span class="special">;</span> <span class="identifier">T2</span> <span class="identifier">a</span><span class="special">;}</span></code> are + layout-compatible, and therefore the trick of reinterpret_cast is an undefined + behavior. I am with you in which that in the 100% of the cases this scheme + will really work, but the standard is the standard. If you can look the + layout-compatibility subject in it (http://www.kuzbass.ru/docs<span class="emphasis"><em>isocpp</em></span>). + As you see, sometimes the standard is cruel. Although mutant seems a lost + case, please do not hurry to eliminate it. We will see what can be done + for it. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I read the standard, and you were right about it. Mutant was + an implementation detail. It is a pity because I am sure that it will work + perfect in any compiler. Perhaps the standard becomes more strict some + day and mutant returns to life... We can then try a wrapper around a relation<A,B> + that have two references named first and second that bind to A and B, or + B and A. </em></span> + </p></blockquote></div> +<p> + +</p> +<pre class="programlisting"><span class="identifier">relation</span><span class="special"><</span><span class="identifier">TA</span><span class="special">,</span><span class="identifier">TB</span><span class="special">></span> <span class="identifier">r</span><span class="special">;</span> +<span class="identifier">const_reference_pair</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span> <span class="identifier">pba</span><span class="special">(</span><span class="identifier">r</span><span class="special">);</span> +<span class="identifier">const_reference_pair</span><span class="special"><</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">A</span><span class="special">></span> <span class="identifier">pbb</span><span class="special">(</span><span class="identifier">r</span><span class="special">);</span> +</pre> +<p> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> It is not difficult to code the relation class in this way but + two references are initialized with every access and the use of <code class="computeroutput"><span class="identifier">pba</span><span class="special">.</span><span class="identifier">first</span></code> will be slower than <code class="computeroutput"><span class="identifier">r</span><span class="special">.</span><span class="identifier">left</span></code> + in most compilers. It is very difficult to optimize this kind of references. + </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> This workaround is not possible, due to technical problems with + the expected behavior of the iterators. If the iterators of bm.left are + of bidirectional type, then standard stated that it have to return an object + of type const value_type& when dereferenced. You will have to return + a const_reference_pair created in the flight, making it impossible to return + a reference. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I understand... I have workaround for that also but surely the + standard will attack me again! We must manage to create the class relation + that responds as we want, the rest of the code will flow from this point. + This clear separation between the relation class and the rest of the library, + is going to help to us to separate the problems and to attack them better. + </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> What workaround? It already pricks my curiosity,I have dedicated + a long time to the subject and I do not find any solution except that we + allow the relation class to occupy more memory. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> We must achieve that the relation<A,B> size equals the + pair<A,B> size if we want this library to be really useful. I was + going to write my workaround and I realized that It does not work. Look + at this: http://www.boost.org/libs/iterator/doc/new-iter-concepts.html + Basically the problem that we are dealing is solved if we based our iterators + on this proposal. The present standard forces that the bidirectional iterators + also are of the type input and output. Using the new concepts there is + no inconvenient in making our iterators "Readable Writable Swappable + Bidirectional Traversal". Therefore the const_reference_pair returns + to be valid. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> It is correct in the sense that you simply say that your iterators + are less powerful than those of the std::map. It is not that it is wrong, + simply that instead of fixing the problem, you confess it. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> OK, but in our particular case; What are the benefits of offering + a LValue iterator against a Read Write iterator? It does not seem to me + that it is less powerful in this case. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> The main problem with a ReadWrite is that the following thing: + <code class="computeroutput"><span class="identifier">value_type</span> <span class="special">*</span> + <span class="identifier">p</span><span class="special">=&(*</span><span class="identifier">it</span><span class="special">);</span></code> + fails or stores a transitory direction in p. Is this important in the real + life? I do not know. How frequently you store the direction of the elements + of a map? Perhaps it is not very frequent, since the logical thing is to + store the iterators instead of the directions of the elements. Let us review + our options: </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 1. We used mutant knowing that is not standard, but of course + it is supported in the 100% of the cases. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 2. We used const_reference_pair and we declared the iterators + not LValue. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 3. We found some trick that still we do not know. I have thus + been playing with unions and things, without much luck. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 4. We leverage the restriction that views have to support the + first, second notation. If we made this decision, there are several possibilities: + </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> a. The left map has standard semantics first/second while the + right map has the inverse semantics. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> b. Instead of first and second we provide first() and second(), + with which the problem is trivial. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> c. The map view do not support first/second but left/right as + the father relation </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 5. We solve the problem using more memory than sizeof(pair<A,B>). + </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> In any case, I would say that the only really unacceptable option + is the last one. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Lets see. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 1. I want the "standard compliant" label in the library. + </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 2. This is the natural choice, but knowing that there is another + option that always works and it is more efficient is awful. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 3. I have also tried to play with unions, the problem is that + the union members must be POD types. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 4. This option implies a big lost to the library. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 5. Totally agree. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I want to add another option to this list. Using metaprogramming, + the relation class checks if the compiler supports the mutant idiom. If + it supports it then it uses it and obtains zero overhead plus LValue iterators, + but if it do not supports it then uses const_reference_pair and obtains + minimum overhead with ReadWrite iterators. This might be controversial + but the advantages that mutant offers are very big and the truth is that + I do not believe that in any actual compiler this idiom is not supported. + This scheme would adjust perfectly to the present standard since we are + not supposing anything. The only drawback here is that although the mutant + approach allows to make LValue iterators we have to degrade they to Read + Write in both cases, because we want that the same code can be compiled + in any standard compliant compiler. </em></span> + </p></blockquote></div> +<p> + <code class="literal">- Hopefully we find our way out of the problem -</code> + </p> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Changing the subject, I believe that the general concept of + hooking data is good, but I do not like the way you implement it. It has + to be easy to migrate to B.MI to anticipate the case in that Boost.Bimap + becomes insufficient. It is more natural for a B.MI user that the data + is accessed without the indirection of <code class="computeroutput"><span class="special">.</span><span class="identifier">data</span></code>. I do not know how this can be articulated + in your framework. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> I have a technical problem to implement the data_hook in this + way. If the standard would let us use the mutant idiom directly, I can + implement it using multiple inheritance. But as we must use const_reference_pair + too, It becomes impossible for me to support it. We have three options + here: </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 1) relation { left, right, data } and pair_view { first, second, + data } </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> - This is more intuitive within the bimap framework, since it + does not mix the data with the index, as a table in a data base does, but + gives more importance to the index. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> - It is not necessary that the user puts the mutable keyword + in each member of the data class. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> - This moves away just a little bit from B.MI because the model + of it is similar to a table, but it continues to exist a clear path of + migration. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 2) relation { left,right, d1,d2... dn } and pair_view { first, + second, data } </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> - The path to B.MI is the one you have proposed. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> - It is very asymmetric. It is necessary to explain that the + views are handled different that the relation. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> - The user must place the mutable keyboards in the data class. + </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 3) Only relation { left,right, d1,d2... dn } </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> - Simple migration path to B.MI. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> - You are not able to access the hooked data from the views. + </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> My vote goes to the first proposal. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Yes, the first option is the one that less surprises hold to + the user. I also vote for 1. </em></span> + </p></blockquote></div> +<p> + <code class="literal">- The third week was over -</code> + </p> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> There is still one problem that I have to solve. I need to know + if it is necessary to create a map_view associated to nothing. If it is + necessary there are two options: that it behaves as an empty container + or that it throws an exception or assert when trying to use it. If it is + not necessary, the map_view is going to keep a reference instead of a pointer. + To me, the map_view always must be viewing something. In the case of the + iterators being able to create them empty, makes them easy to use in contexts + that require constructors by default, like being the value_type of a container, + but I do not believe that this is the case of map_view. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> How would an empty map_view be useful? My intuition is like + yours, map_view would have to be always associate to something. If we wished + to obtain the semantics "is associated or not" we can use a pointer + to a map_view. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> OK, then you agree to that map_views stores a reference instead + of a pointer? </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Joaquin</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> It depends on the semantics you want to give to map_views, and + in concrete to the copy of map_views. </em></span> + </p></blockquote></div> +<p> + +</p> +<pre class="programlisting"><span class="identifier">map_view</span> <span class="identifier">x</span><span class="special">=...;</span> +<span class="identifier">map_view</span> <span class="identifier">y</span><span class="special">=...;</span> +<span class="identifier">x</span><span class="special">=</span><span class="identifier">y</span><span class="special">;</span> +</pre> +<p> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> What is supposed to do this last line? </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 1. Rebinding of x, that is to say, x points at the same container + that y. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 2. Copy of the underlying container. </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> If you want to implement 1, you cannot use references internally. + If you want to implement 2, it is almost the same to use a reference or + a pointer. </em></span> + </p></blockquote></div> +<p> + <span class="bold"><strong>Matias</strong></span> + </p> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> If I want that they behave exactly as std::maps then I must + go for 2. But if I think they as "views" of something, I like + 1. The question is complicated. I add another option: </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> 3. Error: operator= is declare as private in boost::bimap::map_view + std_container </em></span> + </p></blockquote></div> +<div class="blockquote"><blockquote class="blockquote"><p> + <span class="emphasis"><em> Also What happens with <code class="computeroutput"><span class="identifier">std_container</span> + <span class="special">=</span> <span class="identifier">view</span><span class="special">;</span></code>? and with <code class="computeroutput"><span class="identifier">view</span> + <span class="special">=</span> <span class="identifier">std_container</span><span class="special">;</span></code>? </em></span> + </p></blockquote></div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="code.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../rationale.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../history.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/reference.html b/libs/bimap/doc/html/boost_bimap/reference.html new file mode 100644 index 0000000000..5fe8db5444 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/reference.html @@ -0,0 +1,181 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Reference</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="prev" href="bimap_and_boost/dependencies.html" title="Dependencies"> +<link rel="next" href="reference/bimap_reference.html" title="Bimap Reference"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> +<td align="center"><a href="../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="bimap_and_boost/dependencies.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="reference/bimap_reference.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="boost_bimap.reference"></a><a class="link" href="reference.html" title="Reference">Reference</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="reference.html#boost_bimap.reference.headers">Headers</a></span></dt> +<dt><span class="section"><a href="reference/bimap_reference.html">Bimap Reference</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="reference/bimap_reference.html#boost_bimap.reference.bimap_reference.view_concepts">View + concepts</a></span></dt> +<dt><span class="section"><a href="reference/bimap_reference.html#boost_bimap.reference.bimap_reference.complexity_signature"> Complexity + signature</a></span></dt> +<dt><span class="section"><a href="reference/bimap_reference.html#boost_bimap.reference.bimap_reference.set_type_specification">Set + type specification</a></span></dt> +<dt><span class="section"><a href="reference/bimap_reference.html#boost_bimap.reference.bimap_reference.tags">Tags</a></span></dt> +<dt><span class="section"><a href="reference/bimap_reference.html#boost_bimap.reference.bimap_reference.header__boost_bimap_bimap_hpp__synopsis">Header + "boost/bimap/bimap.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="reference/bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap">Class + template bimap</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="reference/set_of_reference.html">set_of Reference</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="reference/set_of_reference.html#boost_bimap.reference.set_of_reference.header__boost_bimap_set_of_hpp__synopsis">Header + "boost/bimap/set_of.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="reference/set_of_reference.html#boost_bimap.reference.set_of_reference.header__boost_bimap_multiset_of_hpp__synopsis">Header + "boost/bimap/multiset_of.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="reference/set_of_reference.html#boost_bimap.reference.set_of_reference.collection_type_specifiers_set_of_and_multiset_of">Collection + type specifiers set_of and multiset_of</a></span></dt> +<dt><span class="section"><a href="reference/set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views">[multi]set_of + Views</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="reference/unordered_set_of_reference.html">unordered_set_of + Reference</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="reference/unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.header__boost_bimap_unordered_set_of_hpp__synopsis">Header + "boost/bimap/unordered_set_of.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="reference/unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.header__boost_bimap_unordered_multiset_of_hpp__synopsis">Header + "boost/bimap/unordered_multiset_of.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="reference/unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.collection_type_specifiers_unordered_set_of_and_unordered_multiset_of">Collection + type specifiers unordered_set_of and unordered_multiset_of</a></span></dt> +<dt><span class="section"><a href="reference/unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views">unordered_[multi]set_of + Views</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="reference/list_of_reference.html">list_of Reference</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="reference/list_of_reference.html#boost_bimap.reference.list_of_reference.header__boost_bimap_list_of_hpp__synopsis">Header + "boost/bimap/list_of.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="reference/list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views">list_of + Views</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="reference/vector_of_reference.html">vector_of + Reference</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="reference/vector_of_reference.html#boost_bimap.reference.vector_of_reference.header__boost_bimap_vector_of_hpp__synopsis">Header + "boost/bimap/vector_of.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="reference/vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views">vector_of + views</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="reference/unconstrained_set_of_reference.html">unconstrained_set_of + Reference</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="reference/unconstrained_set_of_reference.html#boost_bimap.reference.unconstrained_set_of_reference.header__boost_bimap_unconstrained_set_of_hpp__synopsis">Header + "boost/bimap/unconstrained_set_of.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="reference/unconstrained_set_of_reference.html#boost_bimap.reference.unconstrained_set_of_reference.unconstrained_set_of_views">unconstrained_set_of + Views</a></span></dt> +</dl></dd> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.reference.headers"></a><a class="link" href="reference.html#boost_bimap.reference.headers" title="Headers">Headers</a> +</h3></div></div></div> +<p> + The following are the interface headers of Boost.Bimap: + </p> +<p> + <span class="bold"><strong>Convenience</strong></span> + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + "boost/bimap.hpp" <span class="emphasis"><em>(includes "boost/bimap/bimap.hpp" + and imports the bimap class to boost namespace)</em></span> + </li></ul></div> +<p> + <span class="bold"><strong>Container</strong></span> + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + "boost/bimap/bimap.hpp" <span class="emphasis"><em>(includes "boost/bimap/set_of.hpp" + and "boost/bimap/unconstrained_set_of.hpp")</em></span> + </li></ul></div> +<p> + <span class="bold"><strong>Set Types</strong></span> + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + "boost/bimap/set_of.hpp" + </li> +<li class="listitem"> + "boost/bimap/multiset_of.hpp" + </li> +<li class="listitem"> + "boost/bimap/unordered_set_of.hpp" + </li> +<li class="listitem"> + "boost/bimap/unordered_multiset_of.hpp" + </li> +<li class="listitem"> + "boost/bimap/list_of.hpp" + </li> +<li class="listitem"> + "boost/bimap/vector_of.hpp" + </li> +<li class="listitem"> + "boost/bimap/unconstrained_set_of.hpp" + </li> +</ul></div> +<p> + <span class="bold"><strong>Boost Integration</strong></span> + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + "boost/bimap/support/lambda.hpp" + </li> +<li class="listitem"> + "boost/bimap/property_map/set_support.hpp" + </li> +<li class="listitem"> + "boost/bimap/property_map/unordered_set_support.hpp" + </li> +</ul></div> +<p> + A program using Boost.Bimap must therefore include "boost/bimap/bimap.hpp" + and the headers defining the collection types to be used. + </p> +<p> + Additional headers allow the integration of Boost.Bimap with other boost + libraries, like Boost.Lambda and Boost.Property_map. + </p> +<p> + In order to use the serialization capabilities of Boost.Bimap, the appropriate + Boost.Serialization library module must be linked. Other than that, Boost.Bimap + is a header-only library, requiring no additional object modules. + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="bimap_and_boost/dependencies.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="reference/bimap_reference.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/reference/bimap_reference.html b/libs/bimap/doc/html/boost_bimap/reference/bimap_reference.html new file mode 100644 index 0000000000..c2d1f01cf2 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/reference/bimap_reference.html @@ -0,0 +1,935 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Bimap Reference</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../reference.html" title="Reference"> +<link rel="prev" href="../reference.html" title="Reference"> +<link rel="next" href="set_of_reference.html" title="set_of Reference"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="set_of_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.reference.bimap_reference"></a><a class="link" href="bimap_reference.html" title="Bimap Reference">Bimap Reference</a> +</h3></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.view_concepts">View + concepts</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.complexity_signature"> Complexity + signature</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.set_type_specification">Set + type specification</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.tags">Tags</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.header__boost_bimap_bimap_hpp__synopsis">Header + "boost/bimap/bimap.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap">Class + template bimap</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.complexity">Complexity</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.instantiation_types">Instantiation + types</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.nested_types">Nested + types</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.constructors__copy_and_assignment">Constructors, + copy and assignment</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.projection_operations"> Projection + operations</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.support_for_user_defined_names"> Support + for user defined names</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.serialization">Serialization</a></span></dt> +</dl></dd> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.bimap_reference.view_concepts"></a><a class="link" href="bimap_reference.html#boost_bimap.reference.bimap_reference.view_concepts" title="View concepts">View + concepts</a> +</h4></div></div></div> +<p> + <code class="computeroutput"><span class="identifier">bimap</span></code> instantiations comprise + two side views and an view of the relation specified at compile time. Each + view allows read-write access to the elements contained in a definite manner, + mathing an STL container signature. + </p> +<p> + Views are not isolated objects and so cannot be constructed on their own; + rather they are an integral part of a <code class="computeroutput"><span class="identifier">bimap</span></code>. + The name of the view class implementation proper is never directly exposed + to the user, who has access only to the associated view type specifier. + </p> +<p> + Insertion and deletion of elements are always performed through the appropriate + interface of any of the three views of the <code class="computeroutput"><span class="identifier">bimap</span></code>; + these operations do, however, have an impact on all other views as well: + for instance, insertion through a given view may fail because there exists + another view that forbids the operation in order to preserve its invariant + (such as uniqueness of elements). The global operations performed jointly + in the any view can be reduced to six primitives: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + copying + </li> +<li class="listitem"> + insertion of an element + </li> +<li class="listitem"> + hinted insertion, where a pre-existing element is suggested in order + to improve the efficiency of the operation + </li> +<li class="listitem"> + deletion of an element + </li> +<li class="listitem"> + replacement of the value of an element, which may trigger the rearrangement + of this element in one or more views, or may forbid the replacement + </li> +<li class="listitem"> + modification of an element, and its subsequent rearrangement/banning + by the various views + </li> +</ul></div> +<p> + The last two primitives deserve some further explanation: in order to guarantee + the invariants associated to each view (e.g. some definite ordering) elements + of a <code class="computeroutput"><span class="identifier">bimap</span></code> are not mutable. + To overcome this restriction, the views expose member functions for updating + and modifying, which allows for the mutation of elements in a controlled + fashion. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.bimap_reference.complexity_signature"></a><a name="complexity_signature_explanation"></a> <a class="link" href="bimap_reference.html#boost_bimap.reference.bimap_reference.complexity_signature" title="Complexity signature">Complexity + signature</a> +</h4></div></div></div> +<p> + Some member functions of a view interface are implemented by global primitives + from the above list. The complexity of these operations thus depends on + all views of a given <code class="computeroutput"><span class="identifier">bimap</span></code>, + not just the currently used view. + </p> +<p> + In order to establish complexity estimates, a view is characterised by + its complexity signature, consisting of the following associated functions + on the number of elements: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">c</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>: + copying + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">i</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>: + insertion + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">h</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>: + hinted insertion + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">d</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>: + deletion + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>: + replacement + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">m</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>: + modifying + </li> +</ul></div> +<p> + If the collection type of the relation is <code class="computeroutput"><span class="identifier">left_based</span></code> + or <code class="computeroutput"><span class="identifier">right_based</span></code>, and we + use an <code class="computeroutput"><span class="identifier">l</span></code> subscript to denote + the left view and an <code class="computeroutput"><span class="identifier">r</span></code> + for the right view, then the insertion of an element in such a container + is of complexity <code class="computeroutput"><span class="identifier">O</span><span class="special">(</span><span class="identifier">i_l</span><span class="special">(</span><span class="identifier">n</span><span class="special">)+</span><span class="identifier">i_r</span><span class="special">(</span><span class="identifier">n</span><span class="special">))</span></code>, + where n is the number of elements. If the collection type of relation is + not side-based, then there is an additional term to add that is contributed + by the collection type of relation view. Using <code class="computeroutput"><span class="identifier">a</span></code> + to denote the above view, the complexity of insertion will now be <code class="computeroutput"><span class="identifier">O</span><span class="special">(</span><span class="identifier">i_l</span><span class="special">(</span><span class="identifier">n</span><span class="special">)+</span><span class="identifier">i_r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)+</span><span class="identifier">i_a</span><span class="special">(</span><span class="identifier">n</span><span class="special">))</span></code>. + To abbreviate the notation, we adopt the following definitions: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">C</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">c_l</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">c_r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">[</span> <span class="special">+</span> <span class="identifier">c_a</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">]</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">I</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">i_l</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">i_r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">[</span> <span class="special">+</span> <span class="identifier">i_a</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">]</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">H</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">h_l</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">h_r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">[</span> <span class="special">+</span> <span class="identifier">h_a</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">]</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">D</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">d_l</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">d_r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">[</span> <span class="special">+</span> <span class="identifier">d_a</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">]</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">R</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">r_l</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">r_r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">[</span> <span class="special">+</span> <span class="identifier">r_a</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">]</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">M</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">m_l</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">m_r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">[</span> <span class="special">+</span> <span class="identifier">m_a</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">]</span></code> + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.bimap_reference.set_type_specification"></a><a class="link" href="bimap_reference.html#boost_bimap.reference.bimap_reference.set_type_specification" title="Set type specification">Set + type specification</a> +</h4></div></div></div> +<p> + Set type specifiers are passed as instantiation arguments to <code class="computeroutput"><span class="identifier">bimap</span></code> and provide the information needed + to incorporate the corresponding views. Currently, Boost.Bimap provides + the collection type specifiers. The <span class="emphasis"><em>side collection type</em></span> + specifiers define the constraints of the two map views of the bimap. The + <span class="emphasis"><em>collection type of relation</em></span> specifier defines the + main set view constraints. If <code class="computeroutput"><span class="identifier">left_based</span></code> + (the default parameter) or <code class="computeroutput"><span class="identifier">right_based</span></code> + is used, then the collection type of relation will be based on the left + or right collection type correspondingly. + </p> +<div class="informaltable"><table class="table"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Side collection type + </p> + </th> +<th> + <p> + Collection type of relation + </p> + </th> +<th> + <p> + Include + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">set_of</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">set_of_relation</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">set_of</span><span class="special">.</span><span class="identifier">hpp</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">multiset_of</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">multiset_of_relation</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">multiset_of</span><span class="special">.</span><span class="identifier">hpp</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_set_of</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_set_of_relation</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">unordered_set_of</span><span class="special">.</span><span class="identifier">hpp</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_multiset_of</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_multiset_of_relation</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">unordered_multiset_of</span><span class="special">.</span><span class="identifier">hpp</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">list_of</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">list_of_relation</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">list_of</span><span class="special">.</span><span class="identifier">hpp</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">vector_of</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">vector_of_relation</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">vector_of</span><span class="special">.</span><span class="identifier">hpp</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">unconstrained_set_of</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">unconstrained_set_of_relation</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">unconstrained_set_of</span><span class="special">.</span><span class="identifier">hpp</span></code> + </p> + </td> +</tr> +<tr> +<td> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">left_based</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">.</span><span class="identifier">hpp</span></code> + </p> + </td> +</tr> +<tr> +<td> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">right_based</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">.</span><span class="identifier">hpp</span></code> + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.bimap_reference.tags"></a><a class="link" href="bimap_reference.html#boost_bimap.reference.bimap_reference.tags" title="Tags">Tags</a> +</h4></div></div></div> +<p> + Tags are just conventional types used as mnemonics for the types stored + in a <code class="computeroutput"><span class="identifier">bimap</span></code>. Boost.Bimap + uses the tagged idiom to let the user specify this tags. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.bimap_reference.header__boost_bimap_bimap_hpp__synopsis"></a><a class="link" href="bimap_reference.html#boost_bimap.reference.bimap_reference.header__boost_bimap_bimap_hpp__synopsis" title='Header "boost/bimap/bimap.hpp" synopsis'>Header + "boost/bimap/bimap.hpp" synopsis</a> +</h4></div></div></div> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">bimaps</span> <span class="special">{</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Type</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Tag</span> <span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">tagged</span><span class="special">;</span> + +<span class="comment">// bimap template class +</span> +<span class="keyword">template</span> +<span class="special"><</span> + <span class="keyword">class</span> <span class="identifier">LeftCollectionType</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">RightCollectionType</span><span class="special">,</span> + + <span class="keyword">class</span> <span class="identifier">AdditionalParameter_1</span> <span class="special">=</span> <span class="identifier">detail</span><span class="special">::</span><span class="identifier">not_specified</span><span class="special">,</span> + <span class="keyword">class</span> <span class="identifier">AdditionalParameter_2</span> <span class="special">=</span> <span class="identifier">detail</span><span class="special">::</span><span class="identifier">not_specified</span> +<span class="special">></span> +<span class="keyword">class</span> <span class="identifier">bimap</span> <span class="emphasis"><em>- implementation defined { : public SetView } -</em></span> +<span class="special">{</span> + <span class="keyword">public</span><span class="special">:</span> + + <span class="comment">// Metadata +</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">left_tag</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">left_map</span><span class="special">;</span> + + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">right_tag</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">right_map</span><span class="special">;</span> + + <span class="comment">// Shortcuts +</span> <span class="comment">// typedef -side-_map::-type- -side-_-type-; +</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">info_type</span><span class="special">;</span> + + <span class="comment">// Map views +</span> + <span class="identifier">left_map</span> <span class="identifier">left</span><span class="special">;</span> + <span class="identifier">right_map</span> <span class="identifier">right</span><span class="special">;</span> + + <span class="comment">// Constructors +</span> + <span class="identifier">bimap</span><span class="special">();</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">InputIterator</span> <span class="special">></span> + <span class="identifier">bimap</span><span class="special">(</span><span class="identifier">InputIterator</span> <span class="identifier">first</span><span class="special">,</span><span class="identifier">InputIterator</span> <span class="identifier">last</span><span class="special">);</span> + + <span class="identifier">bimap</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bimap</span> <span class="special">&);</span> + + <span class="identifier">bimap</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">bimap</span><span class="special">&</span> <span class="identifier">b</span><span class="special">);</span> + + <span class="comment">// Projection of iterators +</span> + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> + <span class="identifier">left_iterator</span> <span class="identifier">project_left</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> + <span class="identifier">left_const_iterator</span> <span class="identifier">project_left</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> + <span class="identifier">right_iterator</span> <span class="identifier">project_right</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> + <span class="identifier">right_const_iterator</span> <span class="identifier">project_right</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> + <span class="identifier">iterator</span> <span class="identifier">project_up</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> + <span class="identifier">const_iterator</span> <span class="identifier">project_up</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// Support for tags +</span> + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Tag</span> <span class="special">></span> + <span class="keyword">struct</span> <span class="identifier">map_by</span><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Tag</span> <span class="special">></span> + <span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">by</span><span class="special">();</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Tag</span> <span class="special">></span> + <span class="keyword">const</span> <span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">type</span> <span class="special">&</span> <span class="identifier">by</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Tag</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> + <span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">project</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Tag</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> + <span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">const_iterator</span> <span class="identifier">project</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">)</span> <span class="keyword">const</span> + +<span class="special">};</span> + + +<span class="special">}</span> <span class="comment">// namespace bimap +</span><span class="special">}</span> <span class="comment">// namespace boost +</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.bimap_reference.class_template_bimap"></a><a class="link" href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap" title="Class template bimap">Class + template bimap</a> +</h4></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.complexity">Complexity</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.instantiation_types">Instantiation + types</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.nested_types">Nested + types</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.constructors__copy_and_assignment">Constructors, + copy and assignment</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.projection_operations"> Projection + operations</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.support_for_user_defined_names"> Support + for user defined names</a></span></dt> +<dt><span class="section"><a href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.serialization">Serialization</a></span></dt> +</dl></div> +<p> + This is the main component of Boost.Bimap. + </p> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.bimap_reference.class_template_bimap.complexity"></a><a class="link" href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.complexity" title="Complexity">Complexity</a> +</h5></div></div></div> +<p> + In the descriptions of the operations of <code class="computeroutput"><span class="identifier">bimap</span></code>, + we adopt the scheme outlined in the complexity signature section. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.bimap_reference.class_template_bimap.instantiation_types"></a><a class="link" href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.instantiation_types" title="Instantiation types">Instantiation + types</a> +</h5></div></div></div> +<p> + <code class="computeroutput"><span class="identifier">bimap</span></code> is instantiated + with the following types: + </p> +<div class="orderedlist"><ol class="orderedlist" type="1"> +<li class="listitem"> + LeftCollectionType and RightCollectionType are collection type specifications + optionally tagged, or any type optionally tagged, in which case that + side acts as a set. + </li> +<li class="listitem"> +<p class="simpara"> + AdditionalParameter_{1/2} can be any ordered subset of: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + CollectionTypeOfRelation specification + </li> +<li class="listitem"> + Allocator + </li> +</ul></div> +</li> +</ol></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.bimap_reference.class_template_bimap.nested_types"></a><a class="link" href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.nested_types" title="Nested types">Nested + types</a> +</h5></div></div></div> +<pre class="programlisting"><span class="identifier">left_tag</span><span class="special">,</span> <span class="identifier">right_tag</span> +</pre> +<div class="blockquote"><blockquote class="blockquote"><p> + Tags for each side of the bimap. If the user has not specified any + tag the tags default to <code class="computeroutput"><span class="identifier">member_at</span><span class="special">::</span><span class="identifier">left</span></code> + and <code class="computeroutput"><span class="identifier">member_at</span><span class="special">::</span><span class="identifier">right</span></code>. + </p></blockquote></div> +<pre class="programlisting"><span class="identifier">left_key_type</span><span class="special">,</span> <span class="identifier">right_key_type</span> +</pre> +<div class="blockquote"><blockquote class="blockquote"><p> + Key type of each side. In a <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span> </code> <code class="computeroutput"><span class="identifier">left_key_type</span></code> + is <code class="computeroutput"><span class="identifier">A</span></code> and <code class="computeroutput"><span class="identifier">right_key_type</span></code> is <code class="computeroutput"><span class="identifier">B</span></code>. + If there are tags, it is better to use: <code class="computeroutput"><span class="identifier">Bimap</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">key_type</span></code>. + </p></blockquote></div> +<pre class="programlisting"><span class="identifier">left_data_type</span><span class="special">,</span> <span class="identifier">right_data_type</span> +</pre> +<div class="blockquote"><blockquote class="blockquote"><p> + Data type of each side. In a bimap<A,B> left_key_type is B and + right_key_type is A. If there are tags, it is better to use: <code class="computeroutput"><span class="identifier">Bimap</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">data_type</span></code>. + </p></blockquote></div> +<pre class="programlisting"><span class="identifier">left_value_type</span><span class="special">,</span> <span class="identifier">right_value_type</span> +</pre> +<div class="blockquote"><blockquote class="blockquote"><p> + Value type used for the views. If there are tags, it is better to use: + <code class="computeroutput"><span class="identifier">Bimap</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">value_type</span></code>. + </p></blockquote></div> +<pre class="programlisting"><span class="identifier">left_iterator</span><span class="special">,</span> <span class="identifier">right_iterator</span> +<span class="identifier">left_const_iterator</span><span class="special">,</span> <span class="identifier">right_const_iterator</span> +</pre> +<div class="blockquote"><blockquote class="blockquote"><p> + Iterators of the views. If there are tags, it is better to use: <code class="computeroutput"><span class="identifier">Bimap</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">iterator</span></code> and <code class="computeroutput"><span class="identifier">Bimap</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">const_iterator</span></code> + </p></blockquote></div> +<pre class="programlisting"><span class="identifier">left_map</span><span class="special">,</span> <span class="identifier">right_map</span> +</pre> +<div class="blockquote"><blockquote class="blockquote"><p> + Map view type of each side. If there are tags, it is better to use: + <code class="computeroutput"><span class="identifier">Bimap</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">type</span></code>. + </p></blockquote></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.bimap_reference.class_template_bimap.constructors__copy_and_assignment"></a><a class="link" href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.constructors__copy_and_assignment" title="Constructors, copy and assignment">Constructors, + copy and assignment</a> +</h5></div></div></div> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special">();</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Constructs an empty <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Constant. + </li> +</ul></div> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">InputIterator</span><span class="special">></span> +<span class="identifier">bimap</span><span class="special">(</span><span class="identifier">InputIterator</span> <span class="identifier">first</span><span class="special">,</span><span class="identifier">InputIterator</span> <span class="identifier">last</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">InputIterator</span></code> + is a model of Input Iterator over elements of type <code class="computeroutput"><span class="identifier">relation</span></code> or a type convertible + to <code class="computeroutput"><span class="identifier">relation</span></code>. last + is reachable from <code class="computeroutput"><span class="identifier">first</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Constructs an empty <code class="computeroutput"><span class="identifier">bimap</span></code> and fills it with the elements + in the range <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. Insertion of each element may or + may not succeed depending on acceptance by the collection types of + the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +<li class="listitem"> + <a class="link" href="bimap_reference.html#complexity_signature_explanation"><span class="bold"><strong>Complexity:</strong></span></a> + O(m*H(m)), where m is the number of elements in <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +</ul></div> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bimap</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Constructs a copy of x, + copying its elements as well as its internal objects (key extractors, + comparison objects, allocator.) + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span> <span class="special">==</span> + <span class="identifier">x</span></code>. The order of the views + of the <code class="computeroutput"><span class="identifier">bimap</span></code> is preserved + as well. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(x.size()*log(x.size()) + + C(x.size())) + </li> +</ul></div> +<pre class="programlisting"><span class="special">~</span><span class="identifier">bimap</span><span class="special">()</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Destroys the <code class="computeroutput"><span class="identifier">bimap</span></code> and all the elements contained. + The order in which the elements are destroyed is not specified. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(n). + </li> +</ul></div> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">bimap</span><span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Replaces the elements and + internal objects of the <code class="computeroutput"><span class="identifier">bimap</span></code> + with copies from x. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span><span class="special">==</span><span class="identifier">x</span></code>. The order on the views of the + <code class="computeroutput"><span class="identifier">bimap</span></code> is preserved + as well. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(n + x.size()*log(x.size()) + + C(x.size())). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong, provided + the copy and assignment operations of the types of <code class="computeroutput"><span class="identifier">ctor_args_list</span></code> do not throw. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.bimap_reference.class_template_bimap.projection_operations"></a><a name="reference_projection_operations"></a> <a class="link" href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.projection_operations" title="Projection operations">Projection + operations</a> +</h5></div></div></div> +<p> + Given a <code class="computeroutput"><span class="identifier">bimap</span></code> with views + v1 and v2, we say than an v1-iterator it1 and an v2-iterator it2 are + equivalent if: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">it1</span> <span class="special">==</span> + <span class="identifier">i1</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span></code> + AND <code class="computeroutput"><span class="identifier">it2</span> <span class="special">==</span> + <span class="identifier">i2</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span></code>, + </li> +<li class="listitem"> + OR <code class="computeroutput"><span class="identifier">it1</span></code> and <code class="computeroutput"><span class="identifier">it2</span></code> point to the same element. + </li> +</ul></div> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> +<span class="identifier">left_iterator</span> <span class="identifier">project_left</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">);</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> +<span class="identifier">left_const_iterator</span> <span class="identifier">project_left</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="identifier">IteratorType</span></code> + is a bimap view iterator. it is a valid iterator of some view of + <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + (i.e. does not refer to some other <code class="computeroutput"><span class="identifier">bimap</span></code>.) + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns a left map view + iterator equivalent to <code class="computeroutput"><span class="identifier">it</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Constant. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> +<span class="identifier">right_iterator</span> <span class="identifier">project_right</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">);</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> +<span class="identifier">right_const_iterator</span> <span class="identifier">project_right</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="identifier">IteratorType</span></code> + is a bimap view iterator. it is a valid iterator of some view of + <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + (i.e. does not refer to some other <code class="computeroutput"><span class="identifier">bimap</span></code>.) + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns a right map view + iterator equivalent to <code class="computeroutput"><span class="identifier">it</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Constant. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> +<span class="identifier">iterator</span> <span class="identifier">project_up</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">);</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> +<span class="identifier">const_iterator</span> <span class="identifier">project_up</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="identifier">IteratorType</span></code> + is a bimap view iterator. it is a valid iterator of some view of + <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + (i.e. does not refer to some other <code class="computeroutput"><span class="identifier">bimap</span></code>.) + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns a collection of + relations view iterator equivalent to <code class="computeroutput"><span class="identifier">it</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Constant. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.bimap_reference.class_template_bimap.support_for_user_defined_names"></a><a name="reference_support_for_used_defined_names"></a> <a class="link" href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.support_for_user_defined_names" title="Support for user defined names">Support + for user defined names</a> +</h5></div></div></div> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Tag</span> <span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">map_by</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">type</span></code> yields the type of the map + view tagged with <code class="computeroutput"><span class="identifier">Tag</span></code>. + <code class="computeroutput"><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span></code><span class="emphasis"><em>-type + name-</em></span> is the same as <code class="computeroutput"><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">type</span><span class="special">::</span></code><span class="emphasis"><em>-type name-</em></span>. + </li> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">Tag</span></code> + is a valid user defined name of the bimap. + </li> +</ul></div> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Tag</span> <span class="special">></span> +<span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">by</span><span class="special">();</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Tag</span> <span class="special">></span> +<span class="keyword">const</span> <span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">type</span> <span class="special">&</span> <span class="identifier">by</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">Tag</span></code> + is a valid user defined name of the bimap. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns a reference to + the map view tagged with <code class="computeroutput"><span class="identifier">Tag</span></code> + held by <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Constant. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Tag</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> +<span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">project</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">);</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Tag</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">IteratorType</span> <span class="special">></span> +<span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Tag</span><span class="special">>::</span><span class="identifier">const_iterator</span> <span class="identifier">project</span><span class="special">(</span><span class="identifier">IteratorType</span> <span class="identifier">iter</span><span class="special">)</span> <span class="keyword">const</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">Tag</span></code> + is a valid user defined name of the bimap. <code class="computeroutput"><span class="identifier">IteratorType</span></code> + is a bimap view iterator. it is a valid iterator of some view of + <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + (i.e. does not refer to some other <code class="computeroutput"><span class="identifier">bimap</span></code>.) + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns a reference to + the map view tagged with <code class="computeroutput"><span class="identifier">Tag</span></code> + held by <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Constant. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.bimap_reference.class_template_bimap.serialization"></a><a class="link" href="bimap_reference.html#boost_bimap.reference.bimap_reference.class_template_bimap.serialization" title="Serialization">Serialization</a> +</h5></div></div></div> +<p> + A <code class="computeroutput"><span class="identifier">bimap</span></code> can be archived + and retrieved by means of <a href="http://www.boost.org/libs/serialization/doc/index.html" target="_top"><span class="bold"><strong>Boost.Serialization</strong></span></a>. Boost.Bimap does + not expose a public serialisation interface, as this is provided by Boost.Serialization + itself. Both regular and XML archives are supported. + </p> +<p> + Each of the set specifications comprising a given <code class="computeroutput"><span class="identifier">bimap</span></code> + contributes its own preconditions as well as guarantees on the retrieved + containers. In describing these, the following concepts are used. A type + <code class="computeroutput"><span class="identifier">T</span></code> is <span class="emphasis"><em>serializable</em></span> + (resp. XML-serializable) if any object of type <code class="computeroutput"><span class="identifier">T</span></code> + can be saved to an output archive (XML archive) and later retrieved from + an input archive (XML archive) associated to the same storage. If <code class="computeroutput"><span class="identifier">x</span></code>' of type <code class="computeroutput"><span class="identifier">T</span></code> + is loaded from the serialization information saved from another object + x, we say that x' is a <span class="emphasis"><em>restored copy</em></span> of x. Given + a <a href="http://www.sgi.com/tech/stl/BinaryPredicate.html" target="_top">Binary + Predicate</a> <code class="computeroutput"><span class="identifier">Pred</span></code> + over <code class="computeroutput"><span class="special">(</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span><span class="special">)</span></code>, and objects <code class="computeroutput"><span class="identifier">p</span></code> + and <code class="computeroutput"><span class="identifier">q</span></code> of type <code class="computeroutput"><span class="identifier">Pred</span></code>, we say that <code class="computeroutput"><span class="identifier">q</span></code> + is <span class="emphasis"><em>serialization-compatible</em></span> with <code class="computeroutput"><span class="identifier">p</span></code> + if + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><span class="identifier">p</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span><span class="identifier">y</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">q</span><span class="special">(</span><span class="identifier">x</span></code>'<code class="computeroutput"><span class="special">,</span><span class="identifier">y</span></code>'<code class="computeroutput"><span class="special">)</span></code> + </li></ul></div> +<p> + for every <code class="computeroutput"><span class="identifier">x</span></code> and <code class="computeroutput"><span class="identifier">y</span></code> of type <code class="computeroutput"><span class="identifier">T</span></code> + and <code class="computeroutput"><span class="identifier">x</span></code>' and <code class="computeroutput"><span class="identifier">y</span></code>' being restored copies of <code class="computeroutput"><span class="identifier">x</span></code> and <code class="computeroutput"><span class="identifier">y</span></code>, + respectively. + </p> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> saving of a <code class="computeroutput"><span class="identifier">bimap</span> <span class="identifier">b</span></code> + to an output archive (XML archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> Value is serializable + (XML-serializable). Additionally, each of the views of b can impose + other requirements. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong with respect + to <code class="computeroutput"><span class="identifier">b</span></code>. If an exception + is thrown, ar may be left in an inconsistent state. + </li> +</ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> loading of a <code class="computeroutput"><span class="identifier">bimap</span></code> m' from an input archive (XML + archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> Value is serializable + (XML-serializable). Additionally, each of the views of <code class="computeroutput"><span class="identifier">b</span></code>' can impose other requirements. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. If an exception + is thrown, ar may be left in an inconsistent state. + </li> +</ul></div> +</div> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="set_of_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/reference/list_of_reference.html b/libs/bimap/doc/html/boost_bimap/reference/list_of_reference.html new file mode 100644 index 0000000000..67d0843004 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/reference/list_of_reference.html @@ -0,0 +1,1254 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>list_of Reference</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../reference.html" title="Reference"> +<link rel="prev" href="unordered_set_of_reference.html" title="unordered_set_of Reference"> +<link rel="next" href="vector_of_reference.html" title="vector_of Reference"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="unordered_set_of_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="vector_of_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.reference.list_of_reference"></a><a class="link" href="list_of_reference.html" title="list_of Reference">list_of Reference</a> +</h3></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.header__boost_bimap_list_of_hpp__synopsis">Header + "boost/bimap/list_of.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views">list_of + Views</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.complexity_signature"> Complexity + signature</a></span></dt> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.instantiation_types">Instantiation + types</a></span></dt> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.constructors__copy_and_assignment">Constructors, + copy and assignment</a></span></dt> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.capacity_operations">Capacity + operations</a></span></dt> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.modifiers">Modifiers</a></span></dt> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.list_operations">List + operations</a></span></dt> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.rearrange_operations">Rearrange + operations</a></span></dt> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.serialization">Serialization</a></span></dt> +</dl></dd> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.list_of_reference.header__boost_bimap_list_of_hpp__synopsis"></a><a class="link" href="list_of_reference.html#boost_bimap.reference.list_of_reference.header__boost_bimap_list_of_hpp__synopsis" title='Header "boost/bimap/list_of.hpp" synopsis'>Header + "boost/bimap/list_of.hpp" synopsis</a> +</h4></div></div></div> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">bimaps</span> <span class="special">{</span> + + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">KeyType</span> <span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">list_of</span><span class="special">;</span> + +<span class="keyword">struct</span> <span class="identifier">list_of_relation</span><span class="special">;</span> + + +<span class="special">}</span> <span class="comment">// namespace bimap +</span><span class="special">}</span> <span class="comment">// namespace boost +</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.list_of_reference.list_of_views"></a><a class="link" href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views" title="list_of Views">list_of + Views</a> +</h4></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.complexity_signature"> Complexity + signature</a></span></dt> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.instantiation_types">Instantiation + types</a></span></dt> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.constructors__copy_and_assignment">Constructors, + copy and assignment</a></span></dt> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.capacity_operations">Capacity + operations</a></span></dt> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.modifiers">Modifiers</a></span></dt> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.list_operations">List + operations</a></span></dt> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.rearrange_operations">Rearrange + operations</a></span></dt> +<dt><span class="section"><a href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.serialization">Serialization</a></span></dt> +</dl></div> +<p> + A list_of set view is a std::list signature compatible interface to the + underlying heap of elements contained in a <code class="computeroutput"><span class="identifier">bimap</span></code>. + </p> +<p> + If you look the bimap by a side, you will use a map view and if you looked + it as a whole you will be using a set view. + </p> +<p> + Elements in a list_of view are by default sorted according to their order + of insertion: this means that new elements inserted through a different + view of the <code class="computeroutput"><span class="identifier">bimap</span></code> are appended + to the end of the list_of view. Additionally, the view allows for free + reordering of elements in the same vein as <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span></code> + does. Validity of iterators and references to elements is preserved in + all operations. + </p> +<p> + There are a number of differences with respect to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">lists</span></code>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + list_of views are not <a href="http://www.sgi.com/tech/stl/Assignable.html" target="_top">Assignable</a> + (like any other view.) + </li> +<li class="listitem"> + Unlike as in <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span></code>, insertions into a list_of view + may fail due to clashings with other views. This alters the semantics + of the operations provided with respect to their analogues in <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span></code>. + </li> +<li class="listitem"> + Elements in a list_of view are not mutable, and can only be changed + by means of <code class="computeroutput"><span class="identifier">replace</span></code> + and <code class="computeroutput"><span class="identifier">modify</span></code> member functions. + </li> +</ul></div> +<p> + Having these restrictions into account, list_of views are models of <a href="http://www.sgi.com/tech/stl/ReversibleContainer.html" target="_top">Reversible Container</a>, + <a href="http://www.sgi.com/tech/stl/FrontInsertionSequence.html" target="_top">Front + Insertion Sequence</a> and <a href="http://www.sgi.com/tech/stl/BackInsertionSequence.html" target="_top">Back + Insertion Sequence</a>. We only provide descriptions of those types + and operations that are either not present in the concepts modeled or do + not exactly conform to the requirements for these types of containers. + </p> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">bimaps</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">views</span> <span class="special">{</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="emphasis"><em>-implementation defined parameter list-</em></span> <span class="special">></span> +<span class="keyword">class</span> <span class="emphasis"><em>-implementation defined view name-</em></span> +<span class="special">{</span> + <span class="keyword">public</span><span class="special">:</span> + + <span class="comment">// types +</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">value_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">allocator_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">reference</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_reference</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">iterator</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_iterator</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">size_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">difference_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">pointer</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_pointer</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">reverse_iterator</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_reverse_iterator</span><span class="special">;</span> + + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">info_type</span><span class="special">;</span> + + <span class="comment">// construct/copy/destroy +</span> + <span class="identifier">this_type</span> <span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">InputIterator</span> <span class="special">></span> + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_assign_iterator_iterator">assign</a><span class="special">(</span><span class="identifier">InputIterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">InputIterator</span> <span class="identifier">last</span><span class="special">);</span> + + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_assign_size_value">assign</a><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">value</span><span class="special">);</span> + + <span class="identifier">allocator_type</span> <span class="identifier">get_allocator</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// iterators +</span> + <span class="identifier">iterator</span> <span class="identifier">begin</span><span class="special">();</span> + <span class="identifier">const_iterator</span> <span class="identifier">begin</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">iterator</span> <span class="identifier">end</span><span class="special">();</span> + <span class="identifier">const_iterator</span> <span class="identifier">end</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">reverse_iterator</span> <span class="identifier">rbegin</span><span class="special">();</span> + <span class="identifier">const_reverse_iterator</span> <span class="identifier">rbegin</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">reverse_iterator</span> <span class="identifier">rend</span><span class="special">();</span> + <span class="identifier">const_reverse_iterator</span> <span class="identifier">rend</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// capacity +</span> + <span class="keyword">bool</span> <span class="identifier">empty</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">size_type</span> <span class="identifier">size</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">size_type</span> <span class="identifier">max_size</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_resize_size_value">resize</a><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">value_type</span><span class="special">());</span> + + <span class="comment">// access +</span> + <span class="identifier">const_reference</span> <span class="identifier">front</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + <span class="identifier">const_reference</span> <span class="identifier">back</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// modifiers +</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <a class="link" href="list_of_reference.html#reference_list_of_push_front_value">push_front</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + <span class="keyword">void</span> <span class="identifier">pop_front</span><span class="special">();</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <a class="link" href="list_of_reference.html#reference_list_of_push_back_value">push_back</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + <span class="keyword">void</span> <span class="identifier">pop_back</span><span class="special">();</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <a class="link" href="list_of_reference.html#reference_list_of_insert_iterator_value">insert</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_insert_iterator_size_value">insert</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">InputIterator</span> <span class="special">></span> + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_insert_iterator_iterator_iterator">insert</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">InputIterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">InputIterator</span> <span class="identifier">last</span><span class="special">);</span> + + <span class="identifier">iterator</span> <a class="link" href="list_of_reference.html#reference_list_of_erase_iterator">erase</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">);</span> + <span class="identifier">iterator</span> <a class="link" href="list_of_reference.html#reference_list_of_erase_iterator_iterator">erase</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> + + <span class="keyword">bool</span> <a class="link" href="list_of_reference.html#reference_list_of_replace_iterator_value">replace</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="comment">// Only in map views +</span> <span class="comment">// { +</span> + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="list_of_reference.html#reference_list_of_replace_key_iterator_key">replace_key</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleData</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="list_of_reference.html#reference_list_of_replace_data_iterator_data">replace_data</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleData</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">KeyModifier</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="list_of_reference.html#reference_list_of_modify_key_iterator_modifier">modify_key</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">KeyModifier</span> <span class="identifier">mod</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">DataModifier</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="list_of_reference.html#reference_list_of_modify_data_iterator_modifier">modify_data</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">DataModifier</span> <span class="identifier">mod</span><span class="special">);</span> + + <span class="comment">// } +</span> + + <span class="keyword">void</span> <span class="identifier">clear</span><span class="special">();</span> + + <span class="comment">// list operations +</span> + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_splice_iterator_this">splice</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_splice_iterator_this_iterator">splice</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">);</span> + <span class="keyword">void</span> <span class="identifier">splice</span><span class="special">(</span> + <span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> + + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_remove_value">remove</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">value</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Predicate</span> <span class="special">></span> + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_remove_if_predicate">remove_if</a><span class="special">(</span><span class="identifier">Predicate</span> <span class="identifier">pred</span><span class="special">);</span> + + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_unique">unique</a><span class="special">();</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">BinaryPredicate</span> <span class="special">></span> + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_unique_predicate">unique</a><span class="special">(</span><span class="identifier">BinaryPredicate</span> <span class="identifier">binary_pred</span><span class="special">);</span> + + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_merge_this">merge</a><span class="special">(</span><span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Compare</span> <span class="special">></span> + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_merge_this_compare">merge</a><span class="special">(</span><span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">,</span><span class="identifier">Compare</span> <span class="identifier">comp</span><span class="special">);</span> + + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_sort">sort</a><span class="special">();</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Compare</span> <span class="special">></span> + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_sort_compare">sort</a><span class="special">(</span><span class="identifier">Compare</span> <span class="identifier">comp</span><span class="special">);</span> + + <span class="keyword">void</span> <a class="link" href="list_of_reference.html#reference_list_of_reverse">reverse</a><span class="special">();</span> + + <span class="comment">// rearrange operations +</span> + <span class="keyword">void</span> <span class="identifier">relocate</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">);</span> + <span class="keyword">void</span> <span class="identifier">relocate</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> + +<span class="special">}</span> + +<span class="comment">// view comparison +</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">==(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">!=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">></span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">>=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> + +<span class="special">}</span> <span class="comment">// namespace views +</span><span class="special">}</span> <span class="comment">// namespace bimap +</span><span class="special">}</span> <span class="comment">// namespace boost +</span></pre> +<p> + In the case of a <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">list_of</span><span class="special"><</span><span class="identifier">Left</span><span class="special">>,</span> <span class="special">...</span> <span class="special">></span></code> + </p> +<p> + In the set view: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">relation</span><span class="special"><</span> <span class="identifier">Left</span><span class="special">,</span> <span class="special">...</span> <span class="special">></span> <span class="identifier">key_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">relation</span><span class="special"><</span> <span class="identifier">Left</span><span class="special">,</span> <span class="special">...</span> <span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> +</pre> +<p> + In the left map view: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">Left</span> <span class="identifier">key_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="special">...</span> <span class="identifier">data_type</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span> <span class="identifier">Left</span><span class="special">,</span> <span class="special">...</span> <span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> +</pre> +<p> + In the right map view: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="special">...</span> <span class="identifier">key_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">Left</span> <span class="identifier">data_type</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span> <span class="special">...</span> <span class="special">,</span> <span class="identifier">Left</span> <span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> +</pre> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.list_of_reference.list_of_views.complexity_signature"></a><a name="list_of_complexity_signature"></a> <a class="link" href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.complexity_signature" title="Complexity signature">Complexity + signature</a> +</h5></div></div></div> +<p> + Here and in the descriptions of operations of <code class="computeroutput"><span class="identifier">list_of</span></code> + views, we adopt the scheme outlined in the <a class="link" href="bimap_reference.html#complexity_signature_explanation">complexity + signature section</a>. The complexity signature of a <code class="computeroutput"><span class="identifier">list_of</span></code> view is: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + copying: <code class="computeroutput"><span class="identifier">c</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">n</span> <span class="special">*</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>, + </li> +<li class="listitem"> + insertion: <code class="computeroutput"><span class="identifier">i</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> + (constant), + </li> +<li class="listitem"> + hinted insertion: <code class="computeroutput"><span class="identifier">h</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> (constant), + </li> +<li class="listitem"> + deletion: <code class="computeroutput"><span class="identifier">d</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> + (constant), + </li> +<li class="listitem"> + replacement: <code class="computeroutput"><span class="identifier">r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> + (constant), + </li> +<li class="listitem"> + modifying: <code class="computeroutput"><span class="identifier">m</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> + (constant). + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.list_of_reference.list_of_views.instantiation_types"></a><a class="link" href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.instantiation_types" title="Instantiation types">Instantiation + types</a> +</h5></div></div></div> +<p> + <code class="computeroutput"><span class="identifier">list_of</span></code> views are instantiated + internally to <code class="computeroutput"><span class="identifier">bimap</span></code> and + specified by means of the collection type specifiers and the bimap itself. + Instantiations are dependent on the following types: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">Value</span></code> from <code class="computeroutput"><span class="identifier">list_of</span></code>, + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">Allocator</span></code> from <code class="computeroutput"><span class="identifier">bimap</span></code>, + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.list_of_reference.list_of_views.constructors__copy_and_assignment"></a><a class="link" href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.constructors__copy_and_assignment" title="Constructors, copy and assignment">Constructors, + copy and assignment</a> +</h5></div></div></div> +<p> + As explained in the view concepts section, views do not have public constructors + or destructors. Assignment, on the other hand, is provided. + </p> +<pre class="programlisting"><span class="identifier">this_type</span> <span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="identifier">a</span> + <span class="special">=</span> <span class="identifier">b</span><span class="special">;</span></code> where a and b are the <code class="computeroutput"><span class="identifier">bimap</span></code> objects to which <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + and <code class="computeroutput"><span class="identifier">x</span></code> belong, respectively. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>. + </li> +</ul></div> +<a name="reference_list_of_assign_iterator_iterator"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">InputIterator</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">assign</span><span class="special">(</span><span class="identifier">InputIterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">InputIterator</span> <span class="identifier">last</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">InputIterator</span></code> + is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html" target="_top">Input + Iterator</a> over elements of type <code class="computeroutput"><span class="identifier">value_type</span></code> + or a type convertible to <code class="computeroutput"><span class="identifier">value_type</span></code>. + first and last are not iterators into any views of the <code class="computeroutput"><span class="identifier">bimap</span></code> to which this view belongs. + <code class="computeroutput"><span class="identifier">last</span></code> is reachable + from <code class="computeroutput"><span class="identifier">first</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="identifier">clear</span><span class="special">();</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">end</span><span class="special">(),</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">);</span></code> + </li> +</ul></div> +<a name="reference_list_of_assign_size_value"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">assign</span><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">value</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="identifier">clear</span><span class="special">();</span> <span class="keyword">for</span><span class="special">(</span><span class="identifier">size_type</span> + <span class="identifier">i</span> <span class="special">=</span> + <span class="number">0</span><span class="special">;</span> + <span class="identifier">i</span> <span class="special"><</span> + <span class="identifier">n</span> <span class="special">;</span> + <span class="special">++</span><span class="identifier">n</span><span class="special">)</span> <span class="identifier">push_back</span><span class="special">(</span><span class="identifier">v</span><span class="special">);</span></code> + </li></ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.list_of_reference.list_of_views.capacity_operations"></a><a class="link" href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.capacity_operations" title="Capacity operations">Capacity + operations</a> +</h5></div></div></div> +<a name="reference_list_of_resize_size_value"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">resize</span><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">,</span><span class="keyword">const</span> <span class="identifier">value_type</span><span class="special">&</span> <span class="identifier">x</span><span class="special">=</span><span class="identifier">value_type</span><span class="special">());</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="keyword">if</span><span class="special">(</span> <span class="identifier">n</span> <span class="special">></span> <span class="identifier">size</span><span class="special">()</span> <span class="special">)</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">end</span><span class="special">(),</span> + <span class="identifier">n</span> <span class="special">-</span> + <span class="identifier">size</span><span class="special">(),</span> + <span class="identifier">x</span><span class="special">);</span></code> + <code class="computeroutput"><span class="keyword">else</span> <span class="keyword">if</span><span class="special">(</span> <span class="identifier">n</span> <span class="special"><</span> <span class="identifier">size</span><span class="special">()</span> <span class="special">)</span> <span class="special">{</span></code> <code class="computeroutput"> <span class="identifier">iterator</span> + <span class="identifier">it</span> <span class="special">=</span> + <span class="identifier">begin</span><span class="special">();</span></code> + <code class="computeroutput"> <span class="identifier">std</span><span class="special">::</span><span class="identifier">advance</span><span class="special">(</span><span class="identifier">it</span><span class="special">,</span> <span class="identifier">n</span><span class="special">);</span></code> + <code class="computeroutput"> <span class="identifier">erase</span><span class="special">(</span><span class="identifier">it</span><span class="special">,</span> <span class="identifier">end</span><span class="special">());</span></code> + <code class="computeroutput"><span class="special">}</span></code> + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> If an expansion is requested, + the size of the view is not guaranteed to be n after this operation + (other views may ban insertions.) + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.list_of_reference.list_of_views.modifiers"></a><a class="link" href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.modifiers" title="Modifiers">Modifiers</a> +</h5></div></div></div> +<a name="reference_list_of_push_front_value"></a><pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">push_front</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span><span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Inserts <code class="computeroutput"><span class="identifier">x</span></code> + at the beginning of the sequence if no other views of the <code class="computeroutput"><span class="identifier">bimap</span></code> bans the insertion. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> The return value is a pair + <code class="computeroutput"><span class="identifier">p</span></code>. <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span></code> is <code class="computeroutput"><span class="keyword">true</span></code> + if and only if insertion took place. On successful insertion, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to the element inserted; + otherwise, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to an element that + caused the insertion to be banned. Note that more than one element + can be causing insertion not to be allowed. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(I(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. + </li> +</ul></div> +<a name="reference_list_of_push_back_value"></a><pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">push_back</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Inserts <code class="computeroutput"><span class="identifier">x</span></code> + at the end of the sequence if no other views of the <code class="computeroutput"><span class="identifier">bimap</span></code> bans the insertion. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> The return value is a pair + <code class="computeroutput"><span class="identifier">p</span></code>. <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span></code> is <code class="computeroutput"><span class="keyword">true</span></code> + if and only if insertion took place. On successful insertion, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to the element inserted; + otherwise, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to an element that + caused the insertion to be banned. Note that more than one element + can be causing insertion not to be allowed. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(I(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. + </li> +</ul></div> +<a name="reference_list_of_insert_iterator_value"></a><pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid <code class="computeroutput"><span class="identifier">iterator</span></code> + of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Inserts <code class="computeroutput"><span class="identifier">x</span></code> + before position if insertion is allowed by all other views of the + <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> The return value is a pair + <code class="computeroutput"><span class="identifier">p</span></code>. <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span></code> is <code class="computeroutput"><span class="keyword">true</span></code> + if and only if insertion took place. On successful insertion, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to the element inserted; + otherwise, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to an element that + caused the insertion to be banned. Note that more than one element + can be causing insertion not to be allowed. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(I(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. + </li> +</ul></div> +<a name="reference_list_of_insert_iterator_size_value"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid <code class="computeroutput"><span class="identifier">iterator</span></code> + of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="keyword">for</span><span class="special">(</span><span class="identifier">size_type</span> + <span class="identifier">i</span> <span class="special">=</span> + <span class="number">0</span><span class="special">;</span> + <span class="identifier">i</span> <span class="special"><</span> + <span class="identifier">n</span><span class="special">;</span> + <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">position</span><span class="special">,</span> <span class="identifier">x</span><span class="special">);</span></code> + </li> +</ul></div> +<a name="reference_list_of_insert_iterator_iterator_iterator"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">InputIterator</span><span class="special">></span> +<span class="keyword">void</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span><span class="identifier">InputIterator</span> <span class="identifier">first</span><span class="special">,</span><span class="identifier">InputIterator</span> <span class="identifier">last</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid <code class="computeroutput"><span class="identifier">iterator</span></code> + of the view. <code class="computeroutput"><span class="identifier">InputIterator</span></code> + is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html" target="_top">Input + Iterator</a> over elements of type <code class="computeroutput"><span class="identifier">value_type</span></code>. + <code class="computeroutput"><span class="identifier">first</span></code> and <code class="computeroutput"><span class="identifier">last</span></code> are not iterators into any + view of the <code class="computeroutput"><span class="identifier">bimap</span></code> + to which this view belongs. <code class="computeroutput"><span class="identifier">last</span></code> + is reachable from <code class="computeroutput"><span class="identifier">first</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="keyword">while</span><span class="special">(</span><span class="identifier">first</span> + <span class="special">!=</span> <span class="identifier">last</span><span class="special">)</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">position</span><span class="special">,</span> <span class="special">*</span><span class="identifier">first</span><span class="special">++);</span></code> + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(m*I(n+m)), where m is the number of elements in <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_list_of_erase_iterator"></a><pre class="programlisting"><span class="identifier">iterator</span> <span class="identifier">erase</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable <code class="computeroutput"><span class="identifier">iterator</span></code> + of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Deletes the element pointed + to by <code class="computeroutput"><span class="identifier">position</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> An iterator pointing to + the element immediately following the one that was deleted, or <code class="computeroutput"><span class="identifier">end</span><span class="special">()</span></code> + if no such element exists. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(D(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +<a name="reference_list_of_erase_iterator_iterator"></a><pre class="programlisting"><span class="identifier">iterator</span> <span class="identifier">erase</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code> + is a valid range of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Deletes the elements in + <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="identifier">last</span></code>. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(m*D(n)), where m is the number of elements in <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +<a name="reference_list_of_replace_iterator_value"></a><pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">replace</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span><span class="keyword">const</span> <span class="identifier">value_type</span><span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Assigns the value <code class="computeroutput"><span class="identifier">x</span></code> to the element pointed to by + <code class="computeroutput"><span class="identifier">position</span></code> into the + <code class="computeroutput"><span class="identifier">bimap</span></code> to which the + view belongs if replacing is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of <code class="computeroutput"><span class="identifier">position</span></code> is preserved in all cases. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the replacement took place, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(R(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. If an + exception is thrown by some user-provided operation the <code class="computeroutput"><span class="identifier">bimap</span></code> to which the view belongs + remains in its original state. + </li> +</ul></div> +<a name="reference_list_of_replace_key_iterator_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">replace_key</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the set view. <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> can be assigned to + <code class="computeroutput"><span class="identifier">key_type</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Assigns the value <code class="computeroutput"><span class="identifier">x</span></code> to <code class="computeroutput"><span class="identifier">e</span><span class="special">.</span><span class="identifier">first</span></code>, + where <code class="computeroutput"><span class="identifier">e</span></code> is the element + pointed to by <code class="computeroutput"><span class="identifier">position</span></code> + into the <code class="computeroutput"><span class="identifier">bimap</span></code> to + which the set view belongs if replacing is allowed by all other views + of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of position + is preserved in all cases. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the replacement took place, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(R(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. If an + exception is thrown by some user-provided operation, the <code class="computeroutput"><span class="identifier">bimap</span></code> to which the set view belongs + remains in its original state. + </li> +</ul></div> +<a name="reference_list_of_replace_data_iterator_data"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleData</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">replace_data</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleData</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the set view. <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> can be assigned to + <code class="computeroutput"><span class="identifier">data_type</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Assigns the value <code class="computeroutput"><span class="identifier">x</span></code> to <code class="computeroutput"><span class="identifier">e</span><span class="special">.</span><span class="identifier">second</span></code>, + where <code class="computeroutput"><span class="identifier">e</span></code> is the element + pointed to by <code class="computeroutput"><span class="identifier">position</span></code> + into the <code class="computeroutput"><span class="identifier">bimap</span></code> to + which the set view belongs if replacing is allowed by all other views + of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of position + is preserved in all cases. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the replacement took place, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(R(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. If an + exception is thrown by some user-provided operation, the <code class="computeroutput"><span class="identifier">bimap</span></code> to which the set view belongs + remains in its original state. + </li> +</ul></div> +<a name="reference_list_of_modify_key_iterator_modifier"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">KeyModifier</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">modify_key</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">KeyModifier</span> <span class="identifier">mod</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">KeyModifier</span></code> + is a model of <a href="http://www.sgi.com/tech/stl/UnaryFunction.html" target="_top">Unary + Function</a> accepting arguments of type: <code class="computeroutput"><span class="identifier">key_type</span><span class="special">&</span></code>; <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Calls <code class="computeroutput"><span class="identifier">mod</span><span class="special">(</span><span class="identifier">e</span><span class="special">.</span><span class="identifier">first</span><span class="special">)</span></code> where e is the element pointed to + by position and rearranges <code class="computeroutput"><span class="special">*</span><span class="identifier">position</span></code> into all the views of + the <code class="computeroutput"><span class="identifier">bimap</span></code>. If the + rearrangement fails, the element is erased. It is successful if the + rearrangement is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of <code class="computeroutput"><span class="identifier">position</span></code> is preserved if the operation + succeeds. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the operation succeeded, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(M(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. If an exception + is thrown by some user-provided operation (except possibly mod), + then the element pointed to by position is erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided for map views. + </li> +</ul></div> +<a name="reference_list_of_modify_data_iterator_modifier"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">DataModifier</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">modify_data</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">DataModifier</span> <span class="identifier">mod</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">DataModifier</span></code> + is a model of <a href="http://www.sgi.com/tech/stl/UnaryFunction.html" target="_top">Unary + Function</a> accepting arguments of type: <code class="computeroutput"><span class="identifier">data_type</span><span class="special">&</span></code>; <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Calls <code class="computeroutput"><span class="identifier">mod</span><span class="special">(</span><span class="identifier">e</span><span class="special">.</span><span class="identifier">second</span><span class="special">)</span></code> where e is the element pointed to + by position and rearranges <code class="computeroutput"><span class="special">*</span><span class="identifier">position</span></code> into all the views of + the <code class="computeroutput"><span class="identifier">bimap</span></code>. If the + rearrangement fails, the element is erased. It is successful if the + rearrangement is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of <code class="computeroutput"><span class="identifier">position</span></code> is preserved if the operation + succeeds. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the operation succeeded, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(M(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. If an exception + is thrown by some user-provided operation (except possibly mod), + then the element pointed to by position is erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided for map views. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.list_of_reference.list_of_views.list_operations"></a><a class="link" href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.list_operations" title="List operations">List + operations</a> +</h5></div></div></div> +<p> + <code class="computeroutput"><span class="identifier">list_of</span></code> views provide + the full set of list operations found in <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span></code>; + the semantics of these member functions, however, differ from that of + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span></code> in some cases as insertions might + not succeed due to banning by other views. Similarly, the complexity + of the operations may depend on the other views belonging to the same + <code class="computeroutput"><span class="identifier">bimap</span></code>. + </p> +<a name="reference_list_of_splice_iterator_this"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">splice</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid iterator of the view. <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">!=</span><span class="keyword">this</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Inserts the contents of + <code class="computeroutput"><span class="identifier">x</span></code> before position, + in the same order as they were in <code class="computeroutput"><span class="identifier">x</span></code>. + Those elements successfully inserted are erased from <code class="computeroutput"><span class="identifier">x</span></code>. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(<code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>*I(n+<code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>) + + <code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>*D(<code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_list_of_splice_iterator_this_iterator"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">splice</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">,</span><span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid iterator of the view. <code class="computeroutput"><span class="identifier">i</span></code> + is a valid dereferenceable iterator <code class="computeroutput"><span class="identifier">x</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Inserts the element pointed + to by <code class="computeroutput"><span class="identifier">i</span></code> before position: + if insertion is successful, the element is erased from <code class="computeroutput"><span class="identifier">x</span></code>. In the special case <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + no copy or deletion is performed, and the operation is always successful. + If <code class="computeroutput"><span class="identifier">position</span><span class="special">==</span><span class="identifier">i</span></code>, no operation is performed. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + no iterator or reference is invalidated. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + constant; otherwise O(I(n) + D(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + nothrow; otherwise, strong. + </li> +</ul></div> +<a name="reference_list_of_splice_iterator_this_iterator_iterator"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">splice</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid iterator of the view. <code class="computeroutput"><span class="identifier">first</span></code> + and <code class="computeroutput"><span class="identifier">last</span></code> are valid + iterators of <code class="computeroutput"><span class="identifier">x</span></code>. last + is reachable from <code class="computeroutput"><span class="identifier">first</span></code>. + position is not in the range <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> For each element in the + range <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>, insertion is tried before position; + if the operation is successful, the element is erased from x. In + the special case <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, no copy or deletion is performed, + and insertions are always successful. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + no iterator or reference is invalidated. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + constant; otherwise O(m*I(n+m) + m*D(x.size())) where m is the number + of elements in <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + nothrow; otherwise, basic. + </li> +</ul></div> +<a name="reference_list_of_remove_value"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">remove</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">value</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Erases all elements of + the view which compare equal to <code class="computeroutput"><span class="identifier">value</span></code>. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(n + m*D(n)), where m is the number of elements erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_list_of_remove_if_predicate"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Predicate</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">remove_if</span><span class="special">(</span><span class="identifier">Predicate</span> <span class="identifier">pred</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Erases all elements <code class="computeroutput"><span class="identifier">x</span></code> of the view for which <code class="computeroutput"><span class="identifier">pred</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code> + holds. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(n + m*D(n)), where m is the number of elements erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_list_of_unique"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">unique</span><span class="special">();</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Eliminates all but the + first element from every consecutive group of equal elements referred + to by the iterator <code class="computeroutput"><span class="identifier">i</span></code> + in the range <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">+</span><span class="number">1</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code> for which <code class="computeroutput"><span class="special">*</span><span class="identifier">i</span><span class="special">==*(</span><span class="identifier">i</span><span class="special">-</span><span class="number">1</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(n + m*D(n)), where m is the number of elements erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_list_of_unique_predicate"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">BinaryPredicate</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">unique</span><span class="special">(</span><span class="identifier">BinaryPredicate</span> <span class="identifier">binary_pred</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Eliminates all but the + first element from every consecutive group of elements referred to + by the iterator i in the range [first+1,last) for which <code class="computeroutput"><span class="identifier">binary_pred</span><span class="special">(*</span><span class="identifier">i</span><span class="special">,*(</span><span class="identifier">i</span><span class="special">-</span><span class="number">1</span><span class="special">))</span></code> + holds. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(n + m*D(n)), where m is the number of elements erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_list_of_merge_this"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">merge</span><span class="special">(</span><span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">value_type</span><span class="special">></span></code> is a <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html" target="_top">Strict + Weak Ordering</a> over <code class="computeroutput"><span class="identifier">value_type</span></code>. + Both the view and <code class="computeroutput"><span class="identifier">x</span></code> + are sorted according to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">value_type</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Attempts to insert every + element of <code class="computeroutput"><span class="identifier">x</span></code> into + the corresponding position of the view (according to the order). + Elements successfully inserted are erased from <code class="computeroutput"><span class="identifier">x</span></code>. + The resulting sequence is stable, i.e. equivalent elements of either + container preserve their relative position. In the special case + <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + no operation is performed. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Elements in the + view and remaining elements in <code class="computeroutput"><span class="identifier">x</span></code> + are sorted. Validity of iterators to the view and of non-erased elements + of <code class="computeroutput"><span class="identifier">x</span></code> references is + preserved. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + constant; otherwise O(n + <code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>*I(n+<code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>) + <code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>*D(<code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + nothrow; otherwise, basic. + </li> +</ul></div> +<a name="reference_list_of_merge_this_compare"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Compare</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">merge</span><span class="special">(</span><span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">Compare</span> <span class="identifier">comp</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> Compare is a <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html" target="_top">Strict + Weak Ordering</a> over <code class="computeroutput"><span class="identifier">value_type</span></code>. + Both the view and <code class="computeroutput"><span class="identifier">x</span></code> + are sorted according to <code class="computeroutput"><span class="identifier">comp</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Attempts to insert every + element of <code class="computeroutput"><span class="identifier">x</span></code> into + the corresponding position of the view (according to <code class="computeroutput"><span class="identifier">comp</span></code>). Elements successfully inserted + are erased from <code class="computeroutput"><span class="identifier">x</span></code>. + The resulting sequence is stable, i.e. equivalent elements of either + container preserve their relative position. In the special case + <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + no operation is performed. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Elements in the + view and remaining elements in <code class="computeroutput"><span class="identifier">x</span></code> + are sorted according to <code class="computeroutput"><span class="identifier">comp</span></code>. + Validity of iterators to the view and of non-erased elements of + <code class="computeroutput"><span class="identifier">x</span></code> references is preserved. + </li> +<li class="listitem"> + <a class="link" href="list_of_reference.html#list_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + constant; otherwise O(n + <code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>*I(n+<code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>) + <code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>*D(<code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + nothrow; otherwise, basic. + </li> +</ul></div> +<a name="reference_list_of_sort"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">sort</span><span class="special">();</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">value_type</span><span class="special">></span></code> is a <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html" target="_top">Strict + Weak Ordering</a> over value_type. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Sorts the view according + to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">value_type</span><span class="special">></span></code>. + The sorting is stable, i.e. equivalent elements preserve their relative + position. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of iterators + and references is preserved. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(n*log(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow if <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">value_type</span><span class="special">></span></code> + does not throw; otherwise, basic. + </li> +</ul></div> +<a name="reference_list_of_sort_compare"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">Compare</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">sort</span><span class="special">(</span><span class="identifier">Compare</span> <span class="identifier">comp</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> Compare is a <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html" target="_top">Strict + Weak Ordering</a> over value_type. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Sorts the view according + to comp. The sorting is stable, i.e. equivalent elements preserve + their relative position. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of iterators + and references is preserved. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(n*log(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow if comp + does not throw; otherwise, basic. + </li> +</ul></div> +<a name="reference_list_of_reverse"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">reverse</span><span class="special">();</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Reverses the order of the + elements in the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of iterators + and references is preserved. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(n). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.list_of_reference.list_of_views.rearrange_operations"></a><a class="link" href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.rearrange_operations" title="Rearrange operations">Rearrange + operations</a> +</h5></div></div></div> +<p> + These operations, without counterpart in <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span></code> + (although splice provides partially overlapping functionality), perform + individual and global repositioning of elements inside the index. + </p> +<a name="reference_list_of_relocate_iterator_iterator"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">relocate</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid iterator of the view. <code class="computeroutput"><span class="identifier">i</span></code> + is a valid dereferenceable iterator of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Inserts the element pointed + to by <code class="computeroutput"><span class="identifier">i</span></code> before <code class="computeroutput"><span class="identifier">position</span></code>. If <code class="computeroutput"><span class="identifier">position</span><span class="special">==</span><span class="identifier">i</span></code>, + no operation is performed. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> No iterator or reference + is invalidated. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Constant. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +<a name="reference_list_of_relocate_iterator_iterator_iterator"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">relocate</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid iterator of the view. <code class="computeroutput"><span class="identifier">first</span></code> + and <code class="computeroutput"><span class="identifier">last</span></code> are valid + iterators of the view. <code class="computeroutput"><span class="identifier">last</span></code> + is reachable from <code class="computeroutput"><span class="identifier">first</span></code>. + <code class="computeroutput"><span class="identifier">position</span></code> is not in + the range <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> The range of elements + <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code> is repositioned just before <code class="computeroutput"><span class="identifier">position</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> No iterator or reference + is invalidated. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Constant. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.list_of_reference.list_of_views.serialization"></a><a class="link" href="list_of_reference.html#boost_bimap.reference.list_of_reference.list_of_views.serialization" title="Serialization">Serialization</a> +</h5></div></div></div> +<p> + Views cannot be serialized on their own, but only as part of the <code class="computeroutput"><span class="identifier">bimap</span></code> into which they are embedded. + In describing the additional preconditions and guarantees associated + to <code class="computeroutput"><span class="identifier">list_of</span></code> views with + respect to serialization of their embedding containers, we use the concepts + defined in the <code class="computeroutput"><span class="identifier">bimap</span></code> + serialization section. + </p> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> saving of a <code class="computeroutput"><span class="identifier">bimap</span></code> b to an output archive (XML archive) + ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> No additional requirements + to those imposed by the container. + </li></ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> loading of a <code class="computeroutput"><span class="identifier">bimap</span></code> b' from an input archive (XML + archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> No additional requirements + to those imposed by the container. <span class="bold"><strong>Postconditions:</strong></span> + On successful loading, each of the elements of <code class="computeroutput"><span class="special">[</span><span class="identifier">begin</span><span class="special">(),</span> + <span class="identifier">end</span><span class="special">())</span></code> + is a restored copy of the corresponding element in <code class="computeroutput"><span class="special">[</span><span class="identifier">m</span><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="identifier">i</span><span class="special">>().</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">m</span><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="identifier">i</span><span class="special">>().</span><span class="identifier">end</span><span class="special">())</span></code>, where <code class="computeroutput"><span class="identifier">i</span></code> + is the position of the <code class="computeroutput"><span class="identifier">list_of</span></code> + view in the container. + </li></ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> saving of an <code class="computeroutput"><span class="identifier">iterator</span></code> or <code class="computeroutput"><span class="identifier">const_iterator</span></code> + it to an output archive (XML archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">it</span></code> + is a valid iterator of the view. The associated <code class="computeroutput"><span class="identifier">bimap</span></code> + has been previously saved. + </li></ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> loading of an <code class="computeroutput"><span class="identifier">iterator</span></code> or <code class="computeroutput"><span class="identifier">const_iterator</span> + <span class="identifier">it</span></code>' from an input archive (XML + archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> On successful loading, + if it was dereferenceable then <code class="computeroutput"><span class="special">*</span><span class="identifier">it</span></code>' is the restored copy of <code class="computeroutput"><span class="special">*</span><span class="identifier">it</span></code>, + otherwise <code class="computeroutput"><span class="identifier">it</span></code>'<code class="computeroutput"> + <span class="special">==</span> <span class="identifier">end</span><span class="special">()</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> It is allowed that <code class="computeroutput"><span class="identifier">it</span></code> be a <code class="computeroutput"><span class="identifier">const_iterator</span></code> + and the restored <code class="computeroutput"><span class="identifier">it</span></code>' + an iterator, or viceversa. + </li> +</ul></div> +</div> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="unordered_set_of_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="vector_of_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/reference/set_of_reference.html b/libs/bimap/doc/html/boost_bimap/reference/set_of_reference.html new file mode 100644 index 0000000000..447fa9955e --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/reference/set_of_reference.html @@ -0,0 +1,1282 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>set_of Reference</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../reference.html" title="Reference"> +<link rel="prev" href="bimap_reference.html" title="Bimap Reference"> +<link rel="next" href="unordered_set_of_reference.html" title="unordered_set_of Reference"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="bimap_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unordered_set_of_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.reference.set_of_reference"></a><a class="link" href="set_of_reference.html" title="set_of Reference">set_of Reference</a> +</h3></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.header__boost_bimap_set_of_hpp__synopsis">Header + "boost/bimap/set_of.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.header__boost_bimap_multiset_of_hpp__synopsis">Header + "boost/bimap/multiset_of.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.collection_type_specifiers_set_of_and_multiset_of">Collection + type specifiers set_of and multiset_of</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views">[multi]set_of + Views</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.complexity_signature"> Complexity + signature</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.instantiation_types">Instantiation + types</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.constructors__copy_and_assignment">Constructors, + copy and assignment</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.modifiers">Modifiers</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.set_operations">Set + operations</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.range_operations">Range + operations</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.at____info_at___and_operator_______set_of_only">at(), + info_at() and operator[] - set_of only</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.serialization">Serialization</a></span></dt> +</dl></dd> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.set_of_reference.header__boost_bimap_set_of_hpp__synopsis"></a><a class="link" href="set_of_reference.html#boost_bimap.reference.set_of_reference.header__boost_bimap_set_of_hpp__synopsis" title='Header "boost/bimap/set_of.hpp" synopsis'>Header + "boost/bimap/set_of.hpp" synopsis</a> +</h4></div></div></div> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">bimaps</span> <span class="special">{</span> + + +<span class="keyword">template</span> +<span class="special"><</span> + <span class="keyword">class</span> <span class="identifier">KeyType</span><span class="special">,</span> + <span class="keyword">class</span> <span class="identifier">KeyCompare</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span> <span class="identifier">KeyType</span> <span class="special">></span> +<span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">set_of</span><span class="special">;</span> + + +<span class="keyword">template</span> +<span class="special"><</span> + <span class="keyword">class</span> <span class="identifier">KeyCompare</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span> <span class="identifier">_relation</span> <span class="special">></span> +<span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">set_of_relation</span><span class="special">;</span> + + +<span class="special">}</span> <span class="comment">// namespace bimap +</span><span class="special">}</span> <span class="comment">// namespace boost +</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.set_of_reference.header__boost_bimap_multiset_of_hpp__synopsis"></a><a class="link" href="set_of_reference.html#boost_bimap.reference.set_of_reference.header__boost_bimap_multiset_of_hpp__synopsis" title='Header "boost/bimap/multiset_of.hpp" synopsis'>Header + "boost/bimap/multiset_of.hpp" synopsis</a> +</h4></div></div></div> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">bimaps</span> <span class="special">{</span> + + +<span class="keyword">template</span> +<span class="special"><</span> + <span class="keyword">class</span> <span class="identifier">KeyType</span><span class="special">,</span> + <span class="keyword">class</span> <span class="identifier">KeyCompare</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span> <span class="identifier">KeyType</span> <span class="special">></span> +<span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">multiset_of</span><span class="special">;</span> + + +<span class="keyword">template</span> +<span class="special"><</span> + <span class="keyword">class</span> <span class="identifier">KeyCompare</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span> <span class="identifier">_relation</span> <span class="special">></span> +<span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">multiset_of_relation</span><span class="special">;</span> + + +<span class="special">}</span> <span class="comment">// namespace bimap +</span><span class="special">}</span> <span class="comment">// namespace boost +</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.set_of_reference.collection_type_specifiers_set_of_and_multiset_of"></a><a class="link" href="set_of_reference.html#boost_bimap.reference.set_of_reference.collection_type_specifiers_set_of_and_multiset_of" title="Collection type specifiers set_of and multiset_of">Collection + type specifiers set_of and multiset_of</a> +</h4></div></div></div> +<p> + These collection type specifiers allow for insertion of sets disallowing + or allowing duplicate elements, respectively. The syntaxes of <code class="computeroutput"><span class="identifier">set_of</span></code> and <code class="computeroutput"><span class="identifier">multiset_of</span></code> + coincide, so they are described together. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.set_of_reference.__multi__set_of_views"></a><a class="link" href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views" title="[multi]set_of Views">[multi]set_of + Views</a> +</h4></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.complexity_signature"> Complexity + signature</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.instantiation_types">Instantiation + types</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.constructors__copy_and_assignment">Constructors, + copy and assignment</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.modifiers">Modifiers</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.set_operations">Set + operations</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.range_operations">Range + operations</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.at____info_at___and_operator_______set_of_only">at(), + info_at() and operator[] - set_of only</a></span></dt> +<dt><span class="section"><a href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.serialization">Serialization</a></span></dt> +</dl></div> +<p> + A [multi]set_of set view is a std::[multi]set signature-compatible interface + to the underlying heap of elements contained in a <code class="computeroutput"><span class="identifier">bimap</span></code>. + </p> +<p> + There are two variants: set_of, which does not allow duplicate elements + (with respect to its associated comparison predicate) and multiset_of, + which does accept those duplicates. The interface of these two variants + is largely the same, so they are documented together with their differences + explicitly noted where they exist. + </p> +<p> + If you look the bimap from a side, you will use a map view, and if you + look at it as a whole, you will be using a set view. + </p> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">bimaps</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">views</span> <span class="special">{</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="emphasis"><em>-implementation defined parameter list-</em></span> <span class="special">></span> +<span class="keyword">class</span> <span class="emphasis"><em>-implementation defined view name-</em></span> +<span class="special">{</span> + <span class="keyword">public</span><span class="special">:</span> + + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">key_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">value_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">key_compare</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">value_compare</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">allocator_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">reference</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_reference</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">iterator</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_iterator</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">size_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">difference_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">pointer</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_pointer</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">reverse_iterator</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_reverse_iterator</span><span class="special">;</span> + + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">info_type</span><span class="special">;</span> + + <span class="identifier">this_type</span> <span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="identifier">allocator_type</span> <span class="identifier">get_allocator</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// iterators +</span> + <span class="identifier">iterator</span> <span class="identifier">begin</span><span class="special">();</span> + <span class="identifier">const_iterator</span> <span class="identifier">begin</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">iterator</span> <span class="identifier">end</span><span class="special">();</span> + <span class="identifier">const_iterator</span> <span class="identifier">end</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">reverse_iterator</span> <span class="identifier">rbegin</span><span class="special">();</span> + <span class="identifier">const_reverse_iterator</span> <span class="identifier">rbegin</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">reverse_iterator</span> <span class="identifier">rend</span><span class="special">();</span> + <span class="identifier">const_reverse_iterator</span> <span class="identifier">rend</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// capacity +</span> + <span class="keyword">bool</span> <span class="identifier">empty</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">size_type</span> <span class="identifier">size</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">size_type</span> <span class="identifier">max_size</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// modifiers +</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <a class="link" href="set_of_reference.html#reference_set_of_insert_value">insert</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="identifier">iterator</span> <a class="link" href="set_of_reference.html#reference_set_of_insert_iterator_value">insert</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">InputIterator</span><span class="special">></span> + <span class="keyword">void</span> <a class="link" href="set_of_reference.html#reference_set_of_insert_iterator_iterator">insert</a><span class="special">(</span><span class="identifier">InputIterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">InputIterator</span> <span class="identifier">last</span><span class="special">);</span> + + <span class="identifier">iterator</span> <a class="link" href="set_of_reference.html#reference_set_of_erase_iterator">erase</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">size_type</span> <a class="link" href="set_of_reference.html#reference_set_of_erase_key">erase</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="identifier">iterator</span> <a class="link" href="set_of_reference.html#reference_set_of_erase_iterator_iterator">erase</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> + + <span class="keyword">bool</span> <a class="link" href="set_of_reference.html#reference_set_of_replace_iterator_value">replace</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span><span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="comment">// Only in map views +</span> <span class="comment">// { +</span> + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="set_of_reference.html#reference_set_of_replace_key_iterator_key">replace_key</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleData</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="set_of_reference.html#reference_set_of_replace_data_iterator_data">replace_data</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleData</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">KeyModifier</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="set_of_reference.html#reference_set_of_modify_key_iterator_modifier">modify_key</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">KeyModifier</span> <span class="identifier">mod</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">DataModifier</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="set_of_reference.html#reference_set_of_modify_data_iterator_modifier">modify_data</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">DataModifier</span> <span class="identifier">mod</span><span class="special">);</span> + + <span class="comment">// } +</span> + <span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span><span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">void</span> <span class="identifier">clear</span><span class="special">();</span> + + <span class="comment">// observers +</span> + <span class="identifier">key_compare</span> <span class="identifier">key_comp</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">value_compare</span> <span class="identifier">value_comp</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// set operations +</span> + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">iterator</span> <a class="link" href="set_of_reference.html#reference_set_of_find_key">find</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">const_iterator</span> <a class="link" href="set_of_reference.html#reference_set_of_find_key">find</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">size_type</span> <a class="link" href="set_of_reference.html#reference_set_of_count_key">count</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">iterator</span> <a class="link" href="set_of_reference.html#reference_set_of_lower_bound_key">lower_bound</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">const_iterator</span> <a class="link" href="set_of_reference.html#reference_set_of_lower_bound_key">lower_bound</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">iterator</span> <a class="link" href="set_of_reference.html#reference_set_of_upper_bound_key">upper_bound</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">const_iterator</span> <a class="link" href="set_of_reference.html#reference_set_of_upper_bound_key">upper_bound</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="identifier">iterator</span><span class="special">></span> + <a class="link" href="set_of_reference.html#reference_set_of_equal_range_key">equal_range</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">const_iterator</span><span class="special">,</span><span class="identifier">const_iterator</span><span class="special">></span> + <a class="link" href="set_of_reference.html#reference_set_of_equal_range_key">equal_range</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// Only in maps views +</span> <span class="comment">// { +</span> + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">LowerBounder</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">UpperBounder</span><span class="special">></span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="identifier">iterator</span><span class="special">></span> <a class="link" href="set_of_reference.html#reference_set_of_range_lower_upper">range</a><span class="special">(</span> + <span class="identifier">LowerBounder</span> <span class="identifier">lower</span><span class="special">,</span> <span class="identifier">UpperBounder</span> <span class="identifier">upper</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">LowerBounder</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">UpperBounder</span><span class="special">></span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">const_iterator</span><span class="special">,</span><span class="identifier">const_iterator</span><span class="special">></span> <a class="link" href="set_of_reference.html#reference_set_of_range_lower_upper">range</a><span class="special">(</span> + <span class="identifier">LowerBounder</span> <span class="identifier">lower</span><span class="special">,</span> <span class="identifier">UpperBounder</span> <span class="identifier">upper</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">data_type</span><span class="special">;</span> + + <span class="comment">// Only in for `set_of` collection type +</span> <span class="comment">// { +</span> + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="keyword">const</span> <span class="identifier">data_type</span> <span class="special">&</span> <a class="link" href="set_of_reference.html#reference_set_of_at_key_const">at</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// Only if the other collection type is mutable +</span> <span class="comment">// { +</span> + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">data_type</span> <span class="special">&</span> <a class="link" href="set_of_reference.html#reference_set_of_operator_bracket_key">operator[]</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">data_type</span> <span class="special">&</span> <a class="link" href="set_of_reference.html#reference_set_of_at_key">at</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">);</span> + + <span class="comment">// } +</span> + <span class="comment">// Only if info_hook is used +</span> <span class="comment">// { +</span> + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">info_type</span> <span class="special">&</span> <a class="link" href="set_of_reference.html#reference_set_of_info_at_key">info_at</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="keyword">const</span> <span class="identifier">info_type</span> <span class="special">&</span> <a class="link" href="set_of_reference.html#reference_set_of_info_at_key">info_at</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// } +</span> + <span class="comment">// } +</span> + <span class="comment">// } +</span><span class="special">};</span> + +<span class="comment">// view comparison +</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">==(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">!=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">></span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">>=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> + +<span class="special">}</span> <span class="comment">// namespace views +</span><span class="special">}</span> <span class="comment">// namespace bimap +</span><span class="special">}</span> <span class="comment">// namespace boost +</span></pre> +<p> + In the case of a <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span> <span class="special">{</span><span class="identifier">multi</span><span class="special">}</span><span class="identifier">set_of</span><span class="special"><</span><span class="identifier">Left</span><span class="special">>,</span> <span class="special">...</span> <span class="special">></span></code> + </p> +<p> + In the set view: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">relation</span><span class="special"><</span> <span class="identifier">Left</span><span class="special">,</span> <span class="special">...</span> <span class="special">></span> <span class="identifier">key_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">relation</span><span class="special"><</span> <span class="keyword">const</span> <span class="identifier">Left</span><span class="special">,</span> <span class="special">...</span> <span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> +</pre> +<p> + In the left map view: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">Left</span> <span class="identifier">key_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="special">...</span> <span class="identifier">data_type</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span> <span class="keyword">const</span> <span class="identifier">Left</span><span class="special">,</span> <span class="special">...</span> <span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> +</pre> +<p> + In the right map view: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="special">...</span> <span class="identifier">key_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">Left</span> <span class="identifier">data_type</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span> <span class="special">...</span> <span class="special">,</span><span class="keyword">const</span> <span class="identifier">Left</span> <span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> +</pre> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.set_of_reference.__multi__set_of_views.complexity_signature"></a><a name="set_of_complexity_signature"></a> <a class="link" href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.complexity_signature" title="Complexity signature">Complexity + signature</a> +</h5></div></div></div> +<p> + Here and in the descriptions of operations of this view, we adopt the + scheme outlined in the <a class="link" href="bimap_reference.html#complexity_signature_explanation">complexity + signature section</a>. The complexity signature of [multi]set_of view + is: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + copying: <code class="computeroutput"><span class="identifier">c</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">n</span> <span class="special">*</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>, + </li> +<li class="listitem"> + insertion: <code class="computeroutput"><span class="identifier">i</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>, + </li> +<li class="listitem"> + hinted insertion: <code class="computeroutput"><span class="identifier">h</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> (constant) if the hint element precedes + the point of insertion, <code class="computeroutput"><span class="identifier">h</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code> + otherwise, + </li> +<li class="listitem"> + deletion: <code class="computeroutput"><span class="identifier">d</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> + (amortized constant), + </li> +<li class="listitem"> + replacement: <code class="computeroutput"><span class="identifier">r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> + (constant) if the element position does not change, <code class="computeroutput"><span class="identifier">r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code> otherwise, + </li> +<li class="listitem"> + modifying: <code class="computeroutput"><span class="identifier">m</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> + (constant) if the element position does not change, <code class="computeroutput"><span class="identifier">m</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code> otherwise. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.set_of_reference.__multi__set_of_views.instantiation_types"></a><a class="link" href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.instantiation_types" title="Instantiation types">Instantiation + types</a> +</h5></div></div></div> +<p> + Set views are instantiated internally to a <code class="computeroutput"><span class="identifier">bimap</span></code>. + Instantiations are dependent on the following types: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">Value</span></code> from the set + specifier, + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">Allocator</span></code> from <code class="computeroutput"><span class="identifier">bimap</span></code>, + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">Compare</span></code> from the + set specifier. + </li> +</ul></div> +<p> + <code class="computeroutput"><span class="identifier">Compare</span></code> is a <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html" target="_top">Strict + Weak Ordering</a> on elements of <code class="computeroutput"><span class="identifier">Value</span></code>. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.set_of_reference.__multi__set_of_views.constructors__copy_and_assignment"></a><a class="link" href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.constructors__copy_and_assignment" title="Constructors, copy and assignment">Constructors, + copy and assignment</a> +</h5></div></div></div> +<p> + Set views do not have public constructors or destructors. Assignment, + on the other hand, is provided. + </p> +<pre class="programlisting"><span class="identifier">this_type</span> <span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="identifier">a</span> + <span class="special">=</span> <span class="identifier">b</span><span class="special">;</span></code> where a and b are the <code class="computeroutput"><span class="identifier">bimap</span></code> objects to which <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + and x belong, respectively. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.set_of_reference.__multi__set_of_views.modifiers"></a><a class="link" href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.modifiers" title="Modifiers">Modifiers</a> +</h5></div></div></div> +<a name="reference_set_of_insert_value"></a><pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">insert</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>Effects:</strong></span> Inserts <code class="computeroutput"><span class="identifier">x</span></code> + into the <code class="computeroutput"><span class="identifier">bimap</span></code> to + which the set view belongs if + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + the set view is non-unique OR no other element with equivalent + key exists, + </li> +<li class="listitem"> + AND insertion is allowed by the other set specifications the + <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +</ul></div> +</li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> The return value is a pair + <code class="computeroutput"><span class="identifier">p</span></code>. <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span></code> is <code class="computeroutput"><span class="keyword">true</span></code> + if and only if insertion took place. On successful insertion, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to the element inserted; + otherwise, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to an element that + caused the insertion to be banned. Note that more than one element + can be causing insertion not to be allowed. + </li> +<li class="listitem"> + <a class="link" href="set_of_reference.html#set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(I(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. + </li> +</ul></div> +<a name="reference_set_of_insert_iterator_value"></a><pre class="programlisting"><span class="identifier">iterator</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid iterator of the view. + </li> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is used as a hint to improve the efficiency of the operation. Inserts + <code class="computeroutput"><span class="identifier">x</span></code> into the <code class="computeroutput"><span class="identifier">bimap</span></code> to which the view belongs + if + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + the set view is non-unique OR no other element with equivalent + key exists, + </li> +<li class="listitem"> + AND insertion is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +</ul></div> +</li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> On successful insertion, + an iterator to the newly inserted element. Otherwise, an iterator + to an element that caused the insertion to be banned. Note that more + than one element can be causing insertion not to be allowed. + </li> +<li class="listitem"> + <a class="link" href="set_of_reference.html#set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(H(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. + </li> +</ul></div> +<a name="reference_set_of_insert_iterator_iterator"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">InputIterator</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">InputIterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">InputIterator</span> <span class="identifier">last</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">InputIterator</span></code> + is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html" target="_top">Input + Iterator</a> over elements of type <code class="computeroutput"><span class="identifier">value_type</span></code> + or a type convertible to value_type. <code class="computeroutput"><span class="identifier">first</span></code> + and <code class="computeroutput"><span class="identifier">last</span></code> are not + iterators into any view of the <code class="computeroutput"><span class="identifier">bimap</span></code> + to which this index belongs. <code class="computeroutput"><span class="identifier">last</span></code> + is reachable from <code class="computeroutput"><span class="identifier">first</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="identifier">iterator</span> + <span class="identifier">hint</span> <span class="special">=</span> + <span class="identifier">end</span><span class="special">()</span></code>; + <code class="computeroutput"><span class="keyword">while</span><span class="special">(</span> + <span class="identifier">first</span> <span class="special">!=</span> + <span class="identifier">last</span> <span class="special">)</span> + <span class="identifier">hint</span> <span class="special">=</span> + <span class="identifier">insert</span><span class="special">(</span> + <span class="identifier">hint</span><span class="special">,</span> + <span class="special">*</span><span class="identifier">first</span><span class="special">++</span> <span class="special">);</span></code> + </li> +<li class="listitem"> + <a class="link" href="set_of_reference.html#set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(m*H(n+m)), where m is the number of elements in <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span> + <span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_set_of_erase_iterator"></a><pre class="programlisting"><span class="identifier">iterator</span> <span class="identifier">erase</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator if the set view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Deletes the element pointed + to by <code class="computeroutput"><span class="identifier">position</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> An iterator pointing to + the element immediately following the one that was deleted, or <code class="computeroutput"><span class="identifier">end</span><span class="special">()</span></code> + if no such element exists. + </li> +<li class="listitem"> + <a class="link" href="set_of_reference.html#set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(D(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +<a name="reference_set_of_erase_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">size_type</span> <span class="identifier">erase</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is a compatible key of <code class="computeroutput"><span class="identifier">key_compare</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Deletes the elements with + key equivalent to <code class="computeroutput"><span class="identifier">x</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> Number of elements deleted. + </li> +<li class="listitem"> + <a class="link" href="set_of_reference.html#set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(log(n) + m*D(n)), where m is the number of elements deleted. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_set_of_erase_iterator_iterator"></a><pre class="programlisting"><span class="identifier">iterator</span> <span class="identifier">erase</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code> + is a valid range of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Deletes the elements in + <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> last. + </li> +<li class="listitem"> + <a class="link" href="set_of_reference.html#set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(log(n) + m*D(n)), where m is the number of elements in <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +<a name="reference_set_of_replace_iterator_value"></a><pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">replace</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span><span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the set view. + </li> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>Effects:</strong></span> Assigns the value <code class="computeroutput"><span class="identifier">x</span></code> to the element pointed to by + <code class="computeroutput"><span class="identifier">position</span></code> into the + <code class="computeroutput"><span class="identifier">bimap</span></code> to which the + set view belongs if, for the value <code class="computeroutput"><span class="identifier">x</span></code> + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + the set view is non-unique OR no other element with equivalent + key exists (except possibly <code class="computeroutput"><span class="special">*</span><span class="identifier">position</span></code>), + </li> +<li class="listitem"> + AND replacing is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +</ul></div> +</li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of position + is preserved in all cases. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the replacement took place, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="set_of_reference.html#set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(R(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. If an + exception is thrown by some user-provided operation, the <code class="computeroutput"><span class="identifier">bimap</span></code> to which the set view belongs + remains in its original state. + </li> +</ul></div> +<a name="reference_set_of_replace_key_iterator_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">replace_key</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the set view. <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> can be assigned to + <code class="computeroutput"><span class="identifier">key_type</span></code>. + </li> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>Effects:</strong></span> Assigns the value <code class="computeroutput"><span class="identifier">x</span></code> to <code class="computeroutput"><span class="identifier">e</span><span class="special">.</span><span class="identifier">first</span></code>, + where <code class="computeroutput"><span class="identifier">e</span></code> is the element + pointed to by <code class="computeroutput"><span class="identifier">position</span></code> + into the <code class="computeroutput"><span class="identifier">bimap</span></code> to + which the set view belongs if, + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + the map view is non-unique OR no other element with equivalent + key exists (except possibly <code class="computeroutput"><span class="special">*</span><span class="identifier">position</span></code>), + </li> +<li class="listitem"> + AND replacing is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +</ul></div> +</li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of position + is preserved in all cases. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the replacement took place, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="set_of_reference.html#set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(R(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. If an + exception is thrown by some user-provided operation, the <code class="computeroutput"><span class="identifier">bimap</span></code> to which the set view belongs + remains in its original state. + </li> +</ul></div> +<a name="reference_set_of_replace_data_iterator_data"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleData</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">replace_data</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleData</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the set view. <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> can be assigned to + <code class="computeroutput"><span class="identifier">data_type</span></code>. + </li> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>Effects:</strong></span> Assigns the value <code class="computeroutput"><span class="identifier">x</span></code> to <code class="computeroutput"><span class="identifier">e</span><span class="special">.</span><span class="identifier">second</span></code>, + where <code class="computeroutput"><span class="identifier">e</span></code> is the element + pointed to by <code class="computeroutput"><span class="identifier">position</span></code> + into the <code class="computeroutput"><span class="identifier">bimap</span></code> to + which the set view belongs if, + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + the map view is non-unique OR no other element with equivalent + key exists (except possibly <code class="computeroutput"><span class="special">*</span><span class="identifier">position</span></code>), + </li> +<li class="listitem"> + AND replacing is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +</ul></div> +</li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of position + is preserved in all cases. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the replacement took place, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="set_of_reference.html#set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(R(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. If an + exception is thrown by some user-provided operation, the <code class="computeroutput"><span class="identifier">bimap</span></code> to which the set view belongs + remains in its original state. + </li> +</ul></div> +<a name="reference_set_of_modify_key_iterator_modifier"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">KeyModifier</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">modify_key</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">KeyModifier</span> <span class="identifier">mod</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">KeyModifier</span></code> + is a model of <a href="http://www.sgi.com/tech/stl/UnaryFunction.html" target="_top">Unary + Function</a> accepting arguments of type: <code class="computeroutput"><span class="identifier">key_type</span><span class="special">&</span></code>; <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the view. + </li> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>Effects:</strong></span> Calls <code class="computeroutput"><span class="identifier">mod</span><span class="special">(</span><span class="identifier">e</span><span class="special">.</span><span class="identifier">first</span><span class="special">)</span></code> where e is the element pointed to + by position and rearranges <code class="computeroutput"><span class="special">*</span><span class="identifier">position</span></code> into all the views of + the <code class="computeroutput"><span class="identifier">bimap</span></code>. If the + rearrangement fails, the element is erased. Rearrangement is successful + if + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + the map view is non-unique OR no other element with equivalent + key exists, + </li> +<li class="listitem"> + AND rearrangement is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +</ul></div> +</li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of <code class="computeroutput"><span class="identifier">position</span></code> is preserved if the operation + succeeds. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the operation succeeded, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="set_of_reference.html#set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(M(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. If an exception + is thrown by some user-provided operation (except possibly mod), + then the element pointed to by position is erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided for map views. + </li> +</ul></div> +<a name="reference_set_of_modify_data_iterator_modifier"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">DataModifier</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">modify_data</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">DataModifier</span> <span class="identifier">mod</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">DataModifier</span></code> + is a model of <a href="http://www.sgi.com/tech/stl/UnaryFunction.html" target="_top">Unary + Function</a> accepting arguments of type: <code class="computeroutput"><span class="identifier">data_type</span><span class="special">&</span></code>; <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the view. + </li> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>Effects:</strong></span> Calls <code class="computeroutput"><span class="identifier">mod</span><span class="special">(</span><span class="identifier">e</span><span class="special">.</span><span class="identifier">second</span><span class="special">)</span></code> where e is the element pointed to + by position and rearranges <code class="computeroutput"><span class="special">*</span><span class="identifier">position</span></code> into all the views of + the <code class="computeroutput"><span class="identifier">bimap</span></code>. If the + rearrangement fails, the element is erased. Rearrangement is successful + if + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + the oppositte map view is non-unique OR no other element with + equivalent key in that view exists, + </li> +<li class="listitem"> + AND rearrangement is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +</ul></div> +</li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of <code class="computeroutput"><span class="identifier">position</span></code> is preserved if the operation + succeeds. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the operation succeeded, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="set_of_reference.html#set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(M(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. If an exception + is thrown by some user-provided operation (except possibly mod), + then the element pointed to by position is erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided for map views. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.set_of_reference.__multi__set_of_views.set_operations"></a><a class="link" href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.set_operations" title="Set operations">Set + operations</a> +</h5></div></div></div> +<p> + <code class="computeroutput"><span class="special">[</span><span class="identifier">multi</span><span class="special">]</span><span class="identifier">set_of</span></code> + views provide the full lookup functionality required by <a href="http://www.sgi.com/tech/stl/SortedAssociativeContainer.html" target="_top">Sorted + Associative Container</a> and <a href="http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html" target="_top">Unique + Associative Container</a>, namely <code class="computeroutput"><span class="identifier">find</span></code>, + <code class="computeroutput"><span class="identifier">count</span></code>, <code class="computeroutput"><span class="identifier">lower_bound</span></code>, <code class="computeroutput"><span class="identifier">upper_bound</span></code> + and <code class="computeroutput"><span class="identifier">equal_range</span></code>. Additionally, + these member functions are templatized to allow for non-standard arguments, + so extending the types of search operations allowed. + </p> +<p> + A type <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is said to be a <span class="emphasis"><em>compatible key</em></span> of <code class="computeroutput"><span class="identifier">Compare</span></code> if <code class="computeroutput"><span class="special">(</span><span class="identifier">CompatibleKey</span><span class="special">,</span> + <span class="identifier">Compare</span><span class="special">)</span></code> + is a compatible extension of <code class="computeroutput"><span class="identifier">Compare</span></code>. + This implies that <code class="computeroutput"><span class="identifier">Compare</span></code>, + as well as being a strict weak ordering, accepts arguments of type <code class="computeroutput"><span class="identifier">CompatibleKey</span></code>, which usually means + it has several overloads of <code class="computeroutput"><span class="keyword">operator</span><span class="special">()</span></code>. + </p> +<a name="reference_set_of_find_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">iterator</span> <span class="identifier">find</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">const_iterator</span> <span class="identifier">find</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is a compatible key of <code class="computeroutput"><span class="identifier">key_compare</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns a pointer to an + element whose key is equivalent to <code class="computeroutput"><span class="identifier">x</span></code>, + or <code class="computeroutput"><span class="identifier">end</span><span class="special">()</span></code> + if such an element does not exist. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(log(n)). + </li> +</ul></div> +<a name="reference_set_of_count_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">size_type</span> <span class="identifier">count</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">key_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is a compatible key of <code class="computeroutput"><span class="identifier">key_compare</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns the number of elements + with key equivalent to <code class="computeroutput"><span class="identifier">x</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(log(n) + count(x)). + </li> +</ul></div> +<a name="reference_set_of_lower_bound_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">iterator</span> <span class="identifier">lower_bound</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">key_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">const_iterator</span> <span class="identifier">lower_bound</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">key_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is a compatible key of <code class="computeroutput"><span class="identifier">key_compare</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns an iterator pointing + to the first element with key not less than <code class="computeroutput"><span class="identifier">x</span></code>, + or <code class="computeroutput"><span class="identifier">end</span><span class="special">()</span></code> + if such an element does not exist. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(log(n)). + </li> +</ul></div> +<a name="reference_set_of_upper_bound_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">iterator</span> <span class="identifier">upper_bound</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">key_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">const_iterator</span> <span class="identifier">upper_bound</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">key_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is a compatible key of <code class="computeroutput"><span class="identifier">key_compare</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns an iterator pointing + to the first element with key greater than <code class="computeroutput"><span class="identifier">x</span></code>, + or <code class="computeroutput"><span class="identifier">end</span><span class="special">()</span></code> + if such an element does not exist. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(log(n)). + </li> +</ul></div> +<a name="reference_set_of_equal_range_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="identifier">iterator</span><span class="special">></span> + <span class="identifier">equal_range</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">key_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">const_iterator</span><span class="special">,</span><span class="identifier">const_iterator</span><span class="special">></span> + <span class="identifier">equal_range</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">key_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is a compatible key of <code class="computeroutput"><span class="identifier">key_compare</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Equivalent to <code class="computeroutput"><span class="identifier">make_pair</span><span class="special">(</span><span class="identifier">lower_bound</span><span class="special">(</span><span class="identifier">x</span><span class="special">),</span><span class="identifier">upper_bound</span><span class="special">(</span><span class="identifier">x</span><span class="special">))</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(log(n)). + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.set_of_reference.__multi__set_of_views.range_operations"></a><a class="link" href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.range_operations" title="Range operations">Range + operations</a> +</h5></div></div></div> +<p> + The member function range is not defined for sorted associative containers, + but <code class="computeroutput"><span class="special">[</span><span class="identifier">multi</span><span class="special">]</span><span class="identifier">set_of</span></code> + map views provide it as a convenient utility. A range or interval is + defined by two conditions for the lower and upper bounds, which are modelled + after the following concepts. + </p> +<p> + Consider a <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html" target="_top">Strict + Weak Ordering</a> <code class="computeroutput"><span class="identifier">Compare</span></code> + over values of type Key. A type <code class="computeroutput"><span class="identifier">LowerBounder</span></code> + is said to be a lower bounder of <code class="computeroutput"><span class="identifier">Compare</span></code> + if + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">LowerBounder</span></code> is a + <code class="computeroutput"><span class="identifier">Predicate</span></code> over <code class="computeroutput"><span class="identifier">Key</span></code>, + </li> +<li class="listitem"> + if <code class="computeroutput"><span class="identifier">lower</span><span class="special">(</span><span class="identifier">k1</span><span class="special">)</span></code> + and <code class="computeroutput"><span class="special">!</span><span class="identifier">comp</span><span class="special">(</span><span class="identifier">k2</span><span class="special">,</span><span class="identifier">k1</span><span class="special">)</span></code> then <code class="computeroutput"><span class="identifier">lower</span><span class="special">(</span><span class="identifier">k2</span><span class="special">)</span></code>, + </li> +</ul></div> +<p> + for every <code class="computeroutput"><span class="identifier">lower</span></code> of type + <code class="computeroutput"><span class="identifier">LowerBounder</span></code>, <code class="computeroutput"><span class="identifier">comp</span></code> of type <code class="computeroutput"><span class="identifier">Compare</span></code>, + and <code class="computeroutput"><span class="identifier">k1</span></code>, <code class="computeroutput"><span class="identifier">k2</span></code> of type <code class="computeroutput"><span class="identifier">Key</span></code>. + Similarly, an upper bounder is a type <code class="computeroutput"><span class="identifier">UpperBounder</span></code> + such that + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">UpperBounder</span></code> is a + <code class="computeroutput"><span class="identifier">Predicate</span></code> over <code class="computeroutput"><span class="identifier">Key</span></code>, + </li> +<li class="listitem"> + if <code class="computeroutput"><span class="identifier">upper</span><span class="special">(</span><span class="identifier">k1</span><span class="special">)</span></code> + and <code class="computeroutput"><span class="special">!</span><span class="identifier">comp</span><span class="special">(</span><span class="identifier">k1</span><span class="special">,</span><span class="identifier">k2</span><span class="special">)</span></code> then <code class="computeroutput"><span class="identifier">upper</span><span class="special">(</span><span class="identifier">k2</span><span class="special">)</span></code>, + </li> +</ul></div> +<p> + for every <code class="computeroutput"><span class="identifier">upper</span></code> of type + <code class="computeroutput"><span class="identifier">UpperBounder</span></code>, <code class="computeroutput"><span class="identifier">comp</span></code> of type <code class="computeroutput"><span class="identifier">Compare</span></code>, + and <code class="computeroutput"><span class="identifier">k1</span></code>, <code class="computeroutput"><span class="identifier">k2</span></code> of type <code class="computeroutput"><span class="identifier">Key</span></code>. + </p> +<a name="reference_set_of_range_lower_upper"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">LowerBounder</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">UpperBounder</span><span class="special">></span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">const_iterator</span><span class="special">,</span><span class="identifier">const_iterator</span><span class="special">></span> <span class="identifier">range</span><span class="special">(</span> + <span class="identifier">LowerBounder</span> <span class="identifier">lower</span><span class="special">,</span> <span class="identifier">UpperBounder</span> <span class="identifier">upper</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">LowerBounder</span></code> + and <code class="computeroutput"><span class="identifier">UpperBounder</span></code> + are a lower and upper bounder of <code class="computeroutput"><span class="identifier">key_compare</span></code>, + respectively. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns a pair of iterators + pointing to the beginning and one past the end of the subsequence + of elements satisfying lower and upper simultaneously. If no such + elements exist, the iterators both point to the first element satisfying + lower, or else are equal to <code class="computeroutput"><span class="identifier">end</span><span class="special">()</span></code> if this latter element does not + exist. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(log(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Variants:</strong></span> In place of lower or upper + (or both), the singular value <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">bimap</span><span class="special">::</span><span class="identifier">unbounded</span></code> + can be provided. This acts as a predicate which all values of type + <code class="computeroutput"><span class="identifier">key_type</span></code> satisfy. + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided for map views. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.set_of_reference.__multi__set_of_views.at____info_at___and_operator_______set_of_only"></a><a class="link" href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.at____info_at___and_operator_______set_of_only" title="at(), info_at() and operator[] - set_of only">at(), + info_at() and operator[] - set_of only</a> +</h5></div></div></div> +<a name="reference_set_of_at_key_const"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="keyword">const</span> <span class="identifier">data_type</span> <span class="special">&</span> <span class="identifier">at</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is a compatible key of <code class="computeroutput"><span class="identifier">key_compare</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns the <code class="computeroutput"><span class="identifier">data_type</span></code> reference that is associated + with <code class="computeroutput"><span class="identifier">k</span></code>, or throws + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">out_of_range</span></code> if such key does not + exist. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(log(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided when <code class="computeroutput"><span class="identifier">set_of</span></code> is used. + </li> +</ul></div> +<p> + The symmetry of bimap imposes some constraints on <code class="computeroutput"><span class="keyword">operator</span><span class="special">[]</span></code> and the non constant version of at() + that are not found in <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">maps</span></code>. + Tey are only provided if the other collection type is mutable (<code class="computeroutput"><span class="identifier">list_of</span></code>, <code class="computeroutput"><span class="identifier">vector_of</span></code> + and <code class="computeroutput"><span class="identifier">unconstrained_set_of</span></code>). + </p> +<a name="reference_set_of_operator_bracket_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">data_type</span> <span class="special">&</span> <span class="keyword">operator</span><span class="special">[](</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is a compatible key of <code class="computeroutput"><span class="identifier">key_compare</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="keyword">return</span> + <span class="identifier">insert</span><span class="special">(</span><span class="identifier">value_type</span><span class="special">(</span><span class="identifier">k</span><span class="special">,</span><span class="identifier">data_type</span><span class="special">()))-></span><span class="identifier">second</span><span class="special">;</span></code> + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(log(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided when <code class="computeroutput"><span class="identifier">set_of</span></code> is used and the other collection + type is mutable. + </li> +</ul></div> +<a name="reference_set_of_at_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">data_type</span> <span class="special">&</span> <span class="identifier">at</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is a compatible key of <code class="computeroutput"><span class="identifier">key_compare</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> Returns the <code class="computeroutput"><span class="identifier">data_type</span></code> reference that is associated + with <code class="computeroutput"><span class="identifier">k</span></code>, or throws + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">out_of_range</span></code> if such key does not + exist. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(log(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided when <code class="computeroutput"><span class="identifier">set_of</span></code> is used and the other collection + type is mutable. + </li> +</ul></div> +<a name="reference_set_of_info_at_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">info_type</span> <span class="special">&</span> <span class="identifier">info_at</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">);</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="keyword">const</span> <span class="identifier">info_type</span> <span class="special">&</span> <span class="identifier">info_at</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is a compatible key of <code class="computeroutput"><span class="identifier">key_compare</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns the <code class="computeroutput"><span class="identifier">info_type</span></code> reference that is associated + with <code class="computeroutput"><span class="identifier">k</span></code>, or throws + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">out_of_range</span></code> if such key does not + exist. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(log(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided when <code class="computeroutput"><span class="identifier">set_of</span></code> and <code class="computeroutput"><span class="identifier">info_hook</span></code> + are used + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.set_of_reference.__multi__set_of_views.serialization"></a><a class="link" href="set_of_reference.html#boost_bimap.reference.set_of_reference.__multi__set_of_views.serialization" title="Serialization">Serialization</a> +</h5></div></div></div> +<p> + Views cannot be serialized on their own, but only as part of the <code class="computeroutput"><span class="identifier">bimap</span></code> into which they are embedded. + In describing the additional preconditions and guarantees associated + to <code class="computeroutput"><span class="special">[</span><span class="identifier">multi</span><span class="special">]</span><span class="identifier">set_of</span></code> + views with respect to serialization of their embedding containers, we + use the concepts defined in the <code class="computeroutput"><span class="identifier">bimap</span></code> + serialization section. + </p> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> saving of a <code class="computeroutput"><span class="identifier">bimap</span></code> m to an output archive (XML archive) + ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> No additional requirements + to those imposed by the container. + </li></ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> loading of a <code class="computeroutput"><span class="identifier">bimap</span></code> m' from an input archive (XML + archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> In addition to the general + requirements, <code class="computeroutput"><span class="identifier">value_comp</span><span class="special">()</span></code> must be serialization-compatible + with <code class="computeroutput"><span class="identifier">m</span><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="identifier">i</span><span class="special">>().</span><span class="identifier">value_comp</span><span class="special">()</span></code>, + where i is the position of the ordered view in the container. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> On successful loading, + each of the elements of <code class="computeroutput"><span class="special">[</span><span class="identifier">begin</span><span class="special">(),</span> + <span class="identifier">end</span><span class="special">())</span></code> + is a restored copy of the corresponding element in <code class="computeroutput"><span class="special">[</span><span class="identifier">m</span><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="identifier">i</span><span class="special">>().</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">m</span><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="identifier">i</span><span class="special">>().</span><span class="identifier">end</span><span class="special">())</span></code>. + </li> +</ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> saving of an iterator or + <code class="computeroutput"><span class="identifier">const_iterator</span></code> it to + an output archive (XML archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">it</span></code> + is a valid iterator of the view. The associated <code class="computeroutput"><span class="identifier">bimap</span></code> + has been previously saved. + </li></ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> loading of an <code class="computeroutput"><span class="identifier">iterator</span></code> or <code class="computeroutput"><span class="identifier">const_iterator</span></code> + <code class="computeroutput"><span class="identifier">it</span></code>' from an input archive + ( XML archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> On successful loading, + if it was dereferenceable then <code class="computeroutput"><span class="special">*</span><span class="identifier">it</span></code>' is the restored copy of <code class="computeroutput"><span class="special">*</span><span class="identifier">it</span></code>, + otherwise <code class="computeroutput"><span class="identifier">it</span></code>'<code class="computeroutput"> + <span class="special">==</span> <span class="identifier">end</span><span class="special">()</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> It is allowed that it be a + <code class="computeroutput"><span class="identifier">const_iterator</span></code> and + the restored <code class="computeroutput"><span class="identifier">it</span></code>' + an iterator, or viceversa. + </li> +</ul></div> +</div> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="bimap_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unordered_set_of_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/reference/unconstrained_set_of_reference.html b/libs/bimap/doc/html/boost_bimap/reference/unconstrained_set_of_reference.html new file mode 100644 index 0000000000..6d38ce6193 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/reference/unconstrained_set_of_reference.html @@ -0,0 +1,196 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>unconstrained_set_of Reference</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../reference.html" title="Reference"> +<link rel="prev" href="vector_of_reference.html" title="vector_of Reference"> +<link rel="next" href="../compiler_specifics.html" title="Compiler specifics"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="vector_of_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../compiler_specifics.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.reference.unconstrained_set_of_reference"></a><a class="link" href="unconstrained_set_of_reference.html" title="unconstrained_set_of Reference">unconstrained_set_of + Reference</a> +</h3></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="unconstrained_set_of_reference.html#boost_bimap.reference.unconstrained_set_of_reference.header__boost_bimap_unconstrained_set_of_hpp__synopsis">Header + "boost/bimap/unconstrained_set_of.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="unconstrained_set_of_reference.html#boost_bimap.reference.unconstrained_set_of_reference.unconstrained_set_of_views">unconstrained_set_of + Views</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="unconstrained_set_of_reference.html#boost_bimap.reference.unconstrained_set_of_reference.unconstrained_set_of_views.complexity_signature"> Complexity + signature</a></span></dt> +<dt><span class="section"><a href="unconstrained_set_of_reference.html#boost_bimap.reference.unconstrained_set_of_reference.unconstrained_set_of_views.serialization">Serialization</a></span></dt> +</dl></dd> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.unconstrained_set_of_reference.header__boost_bimap_unconstrained_set_of_hpp__synopsis"></a><a class="link" href="unconstrained_set_of_reference.html#boost_bimap.reference.unconstrained_set_of_reference.header__boost_bimap_unconstrained_set_of_hpp__synopsis" title='Header "boost/bimap/unconstrained_set_of.hpp" synopsis'>Header + "boost/bimap/unconstrained_set_of.hpp" synopsis</a> +</h4></div></div></div> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">bimaps</span> <span class="special">{</span> + + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">KeyType</span> <span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">unconstrained_set_of</span><span class="special">;</span> + +<span class="keyword">struct</span> <span class="identifier">unconstrained_set_of_relation</span><span class="special">;</span> + + +<span class="special">}</span> <span class="comment">// namespace bimap +</span><span class="special">}</span> <span class="comment">// namespace boost +</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.unconstrained_set_of_reference.unconstrained_set_of_views"></a><a class="link" href="unconstrained_set_of_reference.html#boost_bimap.reference.unconstrained_set_of_reference.unconstrained_set_of_views" title="unconstrained_set_of Views">unconstrained_set_of + Views</a> +</h4></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="unconstrained_set_of_reference.html#boost_bimap.reference.unconstrained_set_of_reference.unconstrained_set_of_views.complexity_signature"> Complexity + signature</a></span></dt> +<dt><span class="section"><a href="unconstrained_set_of_reference.html#boost_bimap.reference.unconstrained_set_of_reference.unconstrained_set_of_views.serialization">Serialization</a></span></dt> +</dl></div> +<p> + An unconstrained_set_of set view is a view with no constraints. The use + of these kind of view boost the bimap performance but the view can not + be accessed. An unconstrained view is an empty class. + </p> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">bimaps</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">views</span> <span class="special">{</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="emphasis"><em>-implementation defined parameter list-</em></span> <span class="special">></span> +<span class="keyword">class</span> <span class="emphasis"><em>-implementation defined view name-</em></span> +<span class="special">{</span> + <span class="comment">// Empty view +</span><span class="special">};</span> + +<span class="special">}</span> <span class="comment">// namespace views +</span><span class="special">}</span> <span class="comment">// namespace bimap +</span><span class="special">}</span> <span class="comment">// namespace boost +</span></pre> +<p> + In the case of a <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">unconstrained_set_of</span><span class="special"><</span><span class="identifier">Left</span><span class="special">>,</span> <span class="special">...</span> <span class="special">></span></code> + </p> +<p> + In the set view: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">relation</span><span class="special"><</span> <span class="identifier">Left</span><span class="special">,</span> <span class="special">...</span> <span class="special">></span> <span class="identifier">key_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">relation</span><span class="special"><</span> <span class="identifier">Left</span><span class="special">,</span> <span class="special">...</span> <span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> +</pre> +<p> + In the left map view: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">Left</span> <span class="identifier">key_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="special">...</span> <span class="identifier">data_type</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span> <span class="identifier">Left</span><span class="special">,</span> <span class="special">...</span> <span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> +</pre> +<p> + In the right map view: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="special">...</span> <span class="identifier">key_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">Left</span> <span class="identifier">data_type</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span> <span class="special">...</span> <span class="special">,</span> <span class="identifier">Left</span> <span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> +</pre> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.unconstrained_set_of_reference.unconstrained_set_of_views.complexity_signature"></a><a name="unconstrained_set_of_complexity_signature"></a> <a class="link" href="unconstrained_set_of_reference.html#boost_bimap.reference.unconstrained_set_of_reference.unconstrained_set_of_views.complexity_signature" title="Complexity signature">Complexity + signature</a> +</h5></div></div></div> +<p> + We adopt the scheme outlined in the <a class="link" href="bimap_reference.html#complexity_signature_explanation">complexity + signature section</a>. An unconstrained view can not be accessed by + the user, but the formulas to find the order of an operation for a bimap + hold with the following definitions. The complexity signature of a <code class="computeroutput"><span class="identifier">unconstrained_set_of</span></code> view is: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + copying: <code class="computeroutput"><span class="identifier">c</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">0</span></code> + </li> +<li class="listitem"> + insertion: <code class="computeroutput"><span class="identifier">i</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">0</span></code> + </li> +<li class="listitem"> + hinted insertion: <code class="computeroutput"><span class="identifier">h</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">0</span></code> + </li> +<li class="listitem"> + deletion: <code class="computeroutput"><span class="identifier">d</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">0</span></code> + </li> +<li class="listitem"> + replacement: <code class="computeroutput"><span class="identifier">r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">0</span></code> + </li> +<li class="listitem"> + modifying: <code class="computeroutput"><span class="identifier">m</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">0</span></code> + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.unconstrained_set_of_reference.unconstrained_set_of_views.serialization"></a><a class="link" href="unconstrained_set_of_reference.html#boost_bimap.reference.unconstrained_set_of_reference.unconstrained_set_of_views.serialization" title="Serialization">Serialization</a> +</h5></div></div></div> +<p> + Views cannot be serialized on their own, but only as part of the <code class="computeroutput"><span class="identifier">bimap</span></code> into which they are embedded. + In describing the additional preconditions and guarantees associated + to <code class="computeroutput"><span class="identifier">list_of</span></code> views with + respect to serialization of their embedding containers, we use the concepts + defined in the <code class="computeroutput"><span class="identifier">bimap</span></code> + serialization section. + </p> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> saving of a <code class="computeroutput"><span class="identifier">bimap</span></code> b to an output archive (XML archive) + ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> No additional requirements + to those imposed by the container. + </li></ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> loading of a <code class="computeroutput"><span class="identifier">bimap</span></code> b' from an input archive (XML + archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> No additional requirements + to those imposed by the container. + </li></ul></div> +</div> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="vector_of_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../compiler_specifics.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/reference/unordered_set_of_reference.html b/libs/bimap/doc/html/boost_bimap/reference/unordered_set_of_reference.html new file mode 100644 index 0000000000..92ea284292 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/reference/unordered_set_of_reference.html @@ -0,0 +1,1264 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>unordered_set_of Reference</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../reference.html" title="Reference"> +<link rel="prev" href="set_of_reference.html" title="set_of Reference"> +<link rel="next" href="list_of_reference.html" title="list_of Reference"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="set_of_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="list_of_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.reference.unordered_set_of_reference"></a><a class="link" href="unordered_set_of_reference.html" title="unordered_set_of Reference">unordered_set_of + Reference</a> +</h3></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.header__boost_bimap_unordered_set_of_hpp__synopsis">Header + "boost/bimap/unordered_set_of.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.header__boost_bimap_unordered_multiset_of_hpp__synopsis">Header + "boost/bimap/unordered_multiset_of.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.collection_type_specifiers_unordered_set_of_and_unordered_multiset_of">Collection + type specifiers unordered_set_of and unordered_multiset_of</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views">unordered_[multi]set_of + Views</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.complexity_signature"> Complexity + signature</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.instantiation_types">Instantiation + types</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.nested_types">Nested + types</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.constructors__copy_and_assignment">Constructors, + copy and assignment</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.modifiers">Modifiers</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.lookup">Lookup</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.at____info_at___and_operator_______set_of_only">at(), + info_at() and operator[] - set_of only</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.hash_policy">Hash + policy</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.serialization">Serialization</a></span></dt> +</dl></dd> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.unordered_set_of_reference.header__boost_bimap_unordered_set_of_hpp__synopsis"></a><a class="link" href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.header__boost_bimap_unordered_set_of_hpp__synopsis" title='Header "boost/bimap/unordered_set_of.hpp" synopsis'>Header + "boost/bimap/unordered_set_of.hpp" synopsis</a> +</h4></div></div></div> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">bimaps</span> <span class="special">{</span> + + +<span class="keyword">template</span> +<span class="special"><</span> + <span class="keyword">class</span> <span class="identifier">KeyType</span><span class="special">,</span> + <span class="keyword">class</span> <span class="identifier">HashFunctor</span> <span class="special">=</span> <span class="identifier">hash</span><span class="special"><</span> <span class="identifier">KeyType</span> <span class="special">>,</span> + <span class="keyword">class</span> <span class="identifier">EqualKey</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">equal_to</span><span class="special"><</span> <span class="identifier">KeyType</span> <span class="special">></span> +<span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">unordered_set_of</span><span class="special">;</span> + + +<span class="keyword">template</span> +<span class="special"><</span> + <span class="keyword">class</span> <span class="identifier">HashFunctor</span> <span class="special">=</span> <span class="identifier">hash</span><span class="special"><</span> <span class="identifier">_relation</span> <span class="special">>,</span> + <span class="keyword">class</span> <span class="identifier">EqualKey</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">equal_to</span><span class="special"><</span> <span class="identifier">_relation</span> <span class="special">></span> +<span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">unordered_set_of_relation</span><span class="special">;</span> + + +<span class="special">}</span> <span class="comment">// namespace bimap +</span><span class="special">}</span> <span class="comment">// namespace boost +</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.unordered_set_of_reference.header__boost_bimap_unordered_multiset_of_hpp__synopsis"></a><a class="link" href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.header__boost_bimap_unordered_multiset_of_hpp__synopsis" title='Header "boost/bimap/unordered_multiset_of.hpp" synopsis'>Header + "boost/bimap/unordered_multiset_of.hpp" synopsis</a> +</h4></div></div></div> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">bimaps</span> <span class="special">{</span> + + +<span class="keyword">template</span> +<span class="special"><</span> + <span class="keyword">class</span> <span class="identifier">KeyType</span><span class="special">,</span> + <span class="keyword">class</span> <span class="identifier">HashFunctor</span> <span class="special">=</span> <span class="identifier">hash</span><span class="special"><</span> <span class="identifier">KeyType</span> <span class="special">>,</span> + <span class="keyword">class</span> <span class="identifier">EqualKey</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">equal_to</span><span class="special"><</span> <span class="identifier">KeyType</span> <span class="special">></span> +<span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">unordered_multiset_of</span><span class="special">;</span> + + +<span class="keyword">template</span> +<span class="special"><</span> + <span class="keyword">class</span> <span class="identifier">HashFunctor</span> <span class="special">=</span> <span class="identifier">hash</span><span class="special"><</span> <span class="identifier">_relation</span> <span class="special">>,</span> + <span class="keyword">class</span> <span class="identifier">EqualKey</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">equal_to</span><span class="special"><</span> <span class="identifier">_relation</span> <span class="special">></span> +<span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">unordered_multiset_of_relation</span><span class="special">;</span> + + +<span class="special">}</span> <span class="comment">// namespace bimap +</span><span class="special">}</span> <span class="comment">// namespace boost +</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.unordered_set_of_reference.collection_type_specifiers_unordered_set_of_and_unordered_multiset_of"></a><a class="link" href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.collection_type_specifiers_unordered_set_of_and_unordered_multiset_of" title="Collection type specifiers unordered_set_of and unordered_multiset_of">Collection + type specifiers unordered_set_of and unordered_multiset_of</a> +</h4></div></div></div> +<p> + These collection types specifiers allow for set views without and with + allowance of duplicate elements, respectively. The syntax of <code class="computeroutput"><span class="identifier">set_of</span></code> and <code class="computeroutput"><span class="identifier">multiset_of</span></code> + coincide, thus we describe them in a grouped manner. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views"></a><a class="link" href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views" title="unordered_[multi]set_of Views">unordered_[multi]set_of + Views</a> +</h4></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.complexity_signature"> Complexity + signature</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.instantiation_types">Instantiation + types</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.nested_types">Nested + types</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.constructors__copy_and_assignment">Constructors, + copy and assignment</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.modifiers">Modifiers</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.lookup">Lookup</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.at____info_at___and_operator_______set_of_only">at(), + info_at() and operator[] - set_of only</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.hash_policy">Hash + policy</a></span></dt> +<dt><span class="section"><a href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.serialization">Serialization</a></span></dt> +</dl></div> +<p> + An unordered_[multi]set_of set view is a tr1::unordered[multi]set signature + compatible interface to the underlying heap of elements contained in a + <code class="computeroutput"><span class="identifier">bimap</span></code>. + </p> +<p> + The interface and semantics of <code class="computeroutput"><span class="identifier">unordered_</span><span class="special">[</span><span class="identifier">multi</span><span class="special">]</span><span class="identifier">set_of</span></code> + views are modeled according to the proposal for unordered associative containers + given in the <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1836.pdf" target="_top">C++ + Standard Library Technical Report</a>, also known as TR1. An <code class="computeroutput"><span class="identifier">unordered_</span><span class="special">[</span><span class="identifier">multi</span><span class="special">]</span><span class="identifier">set_of</span></code> view is particularized according + to a given <code class="computeroutput"><span class="identifier">Hash</span></code> function + object which returns hash values for the keys and a binary predicate <code class="computeroutput"><span class="identifier">Pred</span></code> acting as an equivalence relation + on values of Key. + </p> +<p> + There are two variants: unordered_set_of, which do not allow duplicate + elements (with respect to its associated comparison predicate) and unordered_multiset_of, + which accept those duplicates. The interface of these two variants is the + same to a great extent, so they are documented together with their differences + explicitly noted when they exist. + </p> +<p> + If you look the bimap by a side, you will use a map view and if you looked + it as a whole you will be using a set view. + </p> +<p> + Except where noted, <code class="computeroutput"><span class="identifier">unordered_</span><span class="special">[</span><span class="identifier">multi</span><span class="special">]</span><span class="identifier">set_of</span></code> + views (both unique and non-unique) are models of <code class="literal">Unordered Associative + Container</code>. Validity of iterators and references to elements is + preserved in all cases. Occasionally, the exception safety guarantees provided + are actually stronger than required by the extension draft. We only provide + descriptions of those types and operations that are either not present + in the concepts modeled or do not exactly conform to the requirements for + unordered associative containers. + </p> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">bimap</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">views</span> <span class="special">{</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="emphasis"><em>-implementation defined parameter list-</em></span> <span class="special">></span> +<span class="keyword">class</span> <span class="emphasis"><em>-implementation defined view name-</em></span> +<span class="special">{</span> + <span class="keyword">public</span><span class="special">:</span> + + <span class="comment">// types +</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">key_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">value_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">key_compare</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">value_compare</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">hasher</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">key_equal</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">allocator_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">reference</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_reference</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">iterator</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_iterator</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">size_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">difference_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">pointer</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_pointer</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">local_iterator</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_local_iterator</span><span class="special">;</span> + + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">info_type</span><span class="special">;</span> + + <span class="comment">// construct/destroy/copy: +</span> + <span class="identifier">this_type</span> <span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="identifier">allocator_type</span> <span class="identifier">get_allocator</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// size and capacity +</span> + <span class="keyword">bool</span> <span class="identifier">empty</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + <span class="identifier">size_type</span> <span class="identifier">size</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + <span class="identifier">size_type</span> <span class="identifier">max_size</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// iterators +</span> + <span class="identifier">iterator</span> <span class="identifier">begin</span><span class="special">();</span> + <span class="identifier">const_iterator</span> <span class="identifier">begin</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + <span class="identifier">iterator</span> <span class="identifier">end</span><span class="special">();</span> + <span class="identifier">const_iterator</span> <span class="identifier">end</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// modifiers +</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span> <span class="identifier">iterator</span><span class="special">,</span> <span class="keyword">bool</span> <span class="special">></span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_insert_value">insert</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="identifier">iterator</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_insert_iterator_value">insert</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">InputIterator</span> <span class="special">></span> + <span class="keyword">void</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_insert_iterator_iterator">insert</a><span class="special">(</span><span class="identifier">InputIterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">InputIterator</span> <span class="identifier">last</span><span class="special">);</span> + + <span class="identifier">iterator</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_erase_iterator">erase</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">size_type</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_erase_key">erase</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="identifier">iterator</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_erase_iterator_iterator">erase</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> + + <span class="keyword">bool</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_replace_iterator_value">replace</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="comment">// Only in map views +</span> <span class="comment">// { +</span> + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_replace_key_iterator_key">replace_key</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleData</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_replace_data_iterator_data">replace_data</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleData</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">KeyModifier</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_modify_key_iterator_modifier">modify_key</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">KeyModifier</span> <span class="identifier">mod</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">DataModifier</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_modify_data_iterator_modifier">modify_data</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">DataModifier</span> <span class="identifier">mod</span><span class="special">);</span> + + <span class="comment">// } +</span> + + <span class="keyword">void</span> <span class="identifier">clear</span><span class="special">();</span> + + <span class="comment">// observers +</span> + <span class="identifier">key_from_value</span> <span class="identifier">key_extractor</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + <span class="identifier">hasher</span> <span class="identifier">hash_function</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + <span class="identifier">key_equal</span> <span class="identifier">key_eq</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// lookup +</span> + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">iterator</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_find_key">find</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">const_iterator</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_find_key">find</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">size_type</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_count_key">count</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="identifier">iterator</span><span class="special">></span> + <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_equal_range_key">equal_range</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">const_iterator</span><span class="special">,</span><span class="identifier">const_iterator</span><span class="special">></span> + <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_equal_range_key">equal_range</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// bucket interface +</span> + <span class="identifier">size_type</span> <span class="identifier">bucket_count</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + <span class="identifier">size_type</span> <span class="identifier">max_bucket_count</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + <span class="identifier">size_type</span> <span class="identifier">bucket_size</span><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + <span class="identifier">size_type</span> <span class="identifier">bucket</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">key_type</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">local_iterator</span> <span class="identifier">begin</span><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">);</span> + <span class="identifier">const_local_iterator</span> <span class="identifier">begin</span><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + <span class="identifier">local_iterator</span> <span class="identifier">end</span><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">);</span> + <span class="identifier">const_local_iterator</span> <span class="identifier">end</span><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// hash policy +</span> + <span class="keyword">float</span> <span class="identifier">load_factor</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + <span class="keyword">float</span> <span class="identifier">max_load_factor</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + <span class="keyword">void</span> <span class="identifier">max_load_factor</span><span class="special">(</span><span class="keyword">float</span> <span class="identifier">z</span><span class="special">);</span> + <span class="keyword">void</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_rehash_size">rehash</a><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">);</span> + + <span class="comment">// Only in maps views +</span> <span class="comment">// { +</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">data_type</span><span class="special">;</span> + + <span class="comment">// Only in for `unordered_set_of` collection type +</span> <span class="comment">// { +</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">CompatibleKey</span><span class="special">></span> + <span class="keyword">const</span> <span class="identifier">data_type</span> <span class="special">&</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_at_key_const">at</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// Only if the other collection type is mutable +</span> <span class="comment">// { +</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">CompatibleKey</span><span class="special">></span> + <span class="identifier">data_type</span> <span class="special">&</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_operator_bracket_key">operator[]</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">CompatibleKey</span><span class="special">></span> + <span class="identifier">data_type</span> <span class="special">&</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_at_key">at</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">);</span> + + <span class="comment">// } +</span> + <span class="comment">// Only if info_hook is used +</span> <span class="comment">// { +</span> + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="identifier">info_type</span> <span class="special">&</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_info_at_key">info_at</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="keyword">const</span> <span class="identifier">info_type</span> <span class="special">&</span> <a class="link" href="unordered_set_of_reference.html#reference_unordered_set_of_info_at_key">info_at</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// } +</span> + <span class="comment">// } +</span> +<span class="special">};</span> + +<span class="special">}</span> <span class="comment">// namespace views +</span><span class="special">}</span> <span class="comment">// namespace bimap +</span><span class="special">}</span> <span class="comment">// namespace boost +</span></pre> +<p> + In the case of a <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">unordered_</span><span class="special">{</span><span class="identifier">multi</span><span class="special">}</span><span class="identifier">set_of</span><span class="special"><</span><span class="identifier">Left</span><span class="special">>,</span> <span class="special">...</span> <span class="special">></span></code> + </p> +<p> + In the set view: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">relation</span><span class="special"><</span> <span class="identifier">Left</span><span class="special">,</span> <span class="special">...</span> <span class="special">></span> <span class="identifier">key_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">relation</span><span class="special"><</span> <span class="keyword">const</span> <span class="identifier">Left</span><span class="special">,</span> <span class="special">...</span> <span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> +</pre> +<p> + In the left map view: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">Left</span> <span class="identifier">key_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="special">...</span> <span class="identifier">data_type</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span> <span class="keyword">const</span> <span class="identifier">Left</span><span class="special">,</span> <span class="special">...</span> <span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> +</pre> +<p> + In the right map view: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="special">...</span> <span class="identifier">key_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">Left</span> <span class="identifier">data_type</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span> <span class="special">...</span> <span class="special">,</span><span class="keyword">const</span> <span class="identifier">Left</span> <span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> +</pre> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.complexity_signature"></a><a name="unordered_set_of_complexity_signature"></a> <a class="link" href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.complexity_signature" title="Complexity signature">Complexity + signature</a> +</h5></div></div></div> +<p> + Here and in the descriptions of operations of <code class="computeroutput"><span class="identifier">unordered_</span><span class="special">[</span><span class="identifier">multi</span><span class="special">]</span><span class="identifier">set_of</span></code> + views, we adopt the scheme outlined in the <a class="link" href="bimap_reference.html#complexity_signature_explanation">complexity + signature section</a>. The complexity signature of <code class="computeroutput"><span class="identifier">unordered_</span><span class="special">[</span><span class="identifier">multi</span><span class="special">]</span><span class="identifier">set_of</span></code> + view is: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + copying: <code class="computeroutput"><span class="identifier">c</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">n</span> <span class="special">*</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>, + </li> +<li class="listitem"> + insertion: average case <code class="computeroutput"><span class="identifier">i</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> (constant), worst case <code class="computeroutput"><span class="identifier">i</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">n</span></code>, + </li> +<li class="listitem"> + hinted insertion: average case <code class="computeroutput"><span class="identifier">h</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> (constant), worst case <code class="computeroutput"><span class="identifier">h</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">n</span></code>, + </li> +<li class="listitem"> + deletion: average case <code class="computeroutput"><span class="identifier">d</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> (constant), worst case <code class="computeroutput"><span class="identifier">d</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">n</span></code>, + </li> +<li class="listitem"> +<p class="simpara"> + replacement: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + if the new element key is equivalent to the original, <code class="computeroutput"><span class="identifier">r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> + <span class="special">=</span> <span class="number">1</span></code> + (constant), + </li> +<li class="listitem"> + otherwise, average case <code class="computeroutput"><span class="identifier">r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> + <span class="number">1</span></code> (constant), worst case + <code class="computeroutput"><span class="identifier">r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> + <span class="special">=</span> <span class="identifier">n</span></code>, + </li> +</ul></div> +</li> +<li class="listitem"> + modifying: average case <code class="computeroutput"><span class="identifier">m</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> (constant), worst case <code class="computeroutput"><span class="identifier">m</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">n</span></code>. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.instantiation_types"></a><a class="link" href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.instantiation_types" title="Instantiation types">Instantiation + types</a> +</h5></div></div></div> +<p> + <code class="computeroutput"><span class="identifier">unordered_</span><span class="special">[</span><span class="identifier">multi</span><span class="special">]</span><span class="identifier">set_of</span></code> views are instantiated internally + to <code class="computeroutput"><span class="identifier">bimap</span></code> specified by + means of the collection type specifiers and the <code class="computeroutput"><span class="identifier">bimap</span></code> + itself. Instantiations are dependent on the following types: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">Value</span></code> from <code class="computeroutput"><span class="identifier">bimap</span></code>, + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">Allocator</span></code> from <code class="computeroutput"><span class="identifier">bimap</span></code>, + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">Hash</span></code> from the collection + type specifier, + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">Pred</span></code> from the collection + type specifier. + </li> +</ul></div> +<p> + <code class="computeroutput"><span class="identifier">Hash</span></code> is a <a href="http://www.sgi.com/tech/stl/UnaryFunction.html" target="_top">Unary + Function</a> taking a single argument of type <code class="computeroutput"><span class="identifier">key_type</span></code> + and returning a value of type <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code> + in the range <code class="computeroutput"><span class="special">[</span><span class="number">0</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">>::</span><span class="identifier">max</span><span class="special">())</span></code>. Pred is a <a href="http://www.sgi.com/tech/stl/BinaryPredicate.html" target="_top">Binary + Predicate</a> inducing an equivalence relation on elements of <code class="computeroutput"><span class="identifier">key_type</span></code>. It is required that the + <code class="computeroutput"><span class="identifier">Hash</span></code> object return the + same value for keys equivalent under <code class="computeroutput"><span class="identifier">Pred</span></code>. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.nested_types"></a><a class="link" href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.nested_types" title="Nested types">Nested + types</a> +</h5></div></div></div> +<pre class="programlisting"><span class="identifier">iterator</span> +<span class="identifier">const_iterator</span> +<span class="identifier">local_iterator</span> +<span class="identifier">const_local_iterator</span> +</pre> +<div class="blockquote"><blockquote class="blockquote"><p> + These types are models of <a href="http://www.sgi.com/tech/stl/ForwardIterator.html" target="_top">Forward + Iterator</a>. + </p></blockquote></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.constructors__copy_and_assignment"></a><a class="link" href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.constructors__copy_and_assignment" title="Constructors, copy and assignment">Constructors, + copy and assignment</a> +</h5></div></div></div> +<p> + As explained in the concepts section, views do not have public constructors + or destructors. Assignment, on the other hand, is provided. Upon construction, + <code class="computeroutput"><span class="identifier">max_load_factor</span><span class="special">()</span></code> + is 1.0. + </p> +<pre class="programlisting"><span class="identifier">this_type</span> <span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="identifier">a</span> + <span class="special">=</span> <span class="identifier">b</span></code>; + where a and b are the <code class="computeroutput"><span class="identifier">bimap</span></code> + objects to which <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + and x belong, respectively. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span><span class="special">.</span></code> + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.modifiers"></a><a class="link" href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.modifiers" title="Modifiers">Modifiers</a> +</h5></div></div></div> +<a name="reference_unordered_set_of_insert_value"></a><pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">insert</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>Effects:</strong></span> Inserts <code class="computeroutput"><span class="identifier">x</span></code> + into the <code class="computeroutput"><span class="identifier">bimap</span></code> to + which the view belongs if + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + the view is non-unique OR no other element with equivalent key + exists, + </li> +<li class="listitem"> + AND insertion is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +</ul></div> +</li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> The return value is a pair + <code class="computeroutput"><span class="identifier">p</span></code>. <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span></code> is <code class="computeroutput"><span class="keyword">true</span></code> + if and only if insertion took place. On successful insertion, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to the element inserted; + otherwise, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to an element that + caused the insertion to be banned. Note that more than one element + can be causing insertion not to be allowed. + </li> +<li class="listitem"> + <a class="link" href="unordered_set_of_reference.html#unordered_set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(I(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. + </li> +</ul></div> +<a name="reference_unordered_set_of_insert_iterator_value"></a><pre class="programlisting"><span class="identifier">iterator</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid iterator of the view. + </li> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is used as a hint to improve the efficiency of the operation. Inserts + <code class="computeroutput"><span class="identifier">x</span></code> into the <code class="computeroutput"><span class="identifier">bimap</span></code> to which the view belongs + if + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + the view is non-unique OR no other element with equivalent key + exists, + </li> +<li class="listitem"> + AND insertion is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +</ul></div> +</li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> On successful insertion, + an iterator to the newly inserted element. Otherwise, an iterator + to an element that caused the insertion to be banned. Note that more + than one element can be causing insertion not to be allowed. + </li> +<li class="listitem"> + <a class="link" href="unordered_set_of_reference.html#unordered_set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(H(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. + </li> +</ul></div> +<a name="reference_unordered_set_of_insert_iterator_iterator"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">InputIterator</span><span class="special">></span> +<span class="keyword">void</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">InputIterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">InputIterator</span> <span class="identifier">last</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">InputIterator</span></code> + is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html" target="_top">Input + Iterator</a> over elements of type <code class="computeroutput"><span class="identifier">value_type</span></code>. + <code class="computeroutput"><span class="identifier">first</span></code> and <code class="computeroutput"><span class="identifier">last</span></code> are not iterators into any + views of the <code class="computeroutput"><span class="identifier">bimap</span></code> + to which this view belongs. <code class="computeroutput"><span class="identifier">last</span></code> + is reachable from first. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="identifier">iterator</span> + <span class="identifier">hint</span> <span class="special">=</span> + <span class="identifier">end</span><span class="special">();</span></code> + <code class="computeroutput"><span class="keyword">while</span><span class="special">(</span><span class="identifier">first</span> <span class="special">!=</span> + <span class="identifier">last</span><span class="special">)</span> + <span class="identifier">hint</span> <span class="special">=</span> + <span class="identifier">insert</span><span class="special">(</span><span class="identifier">hint</span><span class="special">,</span> + <span class="special">*</span><span class="identifier">first</span><span class="special">++);</span></code> + </li> +<li class="listitem"> + <a class="link" href="unordered_set_of_reference.html#unordered_set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(m*H(n+m)), where m is the number of elements in <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span> + <span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_unordered_set_of_erase_iterator"></a><pre class="programlisting"><span class="identifier">iterator</span> <span class="identifier">erase</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable <code class="computeroutput"><span class="identifier">iterator</span></code> + of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Deletes the element pointed + to by <code class="computeroutput"><span class="identifier">position</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> An <code class="computeroutput"><span class="identifier">iterator</span></code> + pointing to the element immediately following the one that was deleted, + or <code class="computeroutput"><span class="identifier">end</span><span class="special">()</span></code> + if no such element exists. + </li> +<li class="listitem"> + <a class="link" href="unordered_set_of_reference.html#unordered_set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(D(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +<a name="reference_unordered_set_of_erase_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">size_type</span> <span class="identifier">erase</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Deletes the elements with + key equivalent to <code class="computeroutput"><span class="identifier">x</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> Number of elements deleted. + </li> +<li class="listitem"> + <a class="link" href="unordered_set_of_reference.html#unordered_set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + Average case, O(1 + m*D(n)), worst case O(n + m*D(n)), where m is + the number of elements deleted. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_unordered_set_of_erase_iterator_iterator"></a><pre class="programlisting"><span class="identifier">iterator</span> <span class="identifier">erase</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code> + is a valid range of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Deletes the elements in + <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="identifier">last</span></code>. + </li> +<li class="listitem"> + <a class="link" href="unordered_set_of_reference.html#unordered_set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(m*D(n)), where m is the number of elements in <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +<a name="reference_unordered_set_of_replace_iterator_value"></a><pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">replace</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable <code class="computeroutput"><span class="identifier">iterator</span></code> + of the view. + </li> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>Effects:</strong></span> Assigns the value <code class="computeroutput"><span class="identifier">x</span></code> to the element pointed to by + <code class="computeroutput"><span class="identifier">position</span></code> into the + <code class="computeroutput"><span class="identifier">bimap</span></code> to which the + view belongs if, for the value <code class="computeroutput"><span class="identifier">x</span></code> + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + the view is non-unique OR no other element with equivalent key + exists (except possibly <code class="computeroutput"><span class="special">*</span><span class="identifier">position</span></code>), + </li> +<li class="listitem"> + AND replacing is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +</ul></div> +</li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of position + is preserved in all cases. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the replacement took place, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="unordered_set_of_reference.html#unordered_set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(R(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. If an + exception is thrown by some user-provided operation the <code class="computeroutput"><span class="identifier">bimap</span></code> to which the view belongs + remains in its original state. + </li> +</ul></div> +<a name="reference_unordered_set_of_replace_key_iterator_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">replace_key</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the set view. <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> can be assigned to + <code class="computeroutput"><span class="identifier">key_type</span></code>. + </li> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>Effects:</strong></span> Assigns the value <code class="computeroutput"><span class="identifier">x</span></code> to <code class="computeroutput"><span class="identifier">e</span><span class="special">.</span><span class="identifier">first</span></code>, + where <code class="computeroutput"><span class="identifier">e</span></code> is the element + pointed to by <code class="computeroutput"><span class="identifier">position</span></code> + into the <code class="computeroutput"><span class="identifier">bimap</span></code> to + which the set view belongs if, + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + the map view is non-unique OR no other element with equivalent + key exists (except possibly <code class="computeroutput"><span class="special">*</span><span class="identifier">position</span></code>), + </li> +<li class="listitem"> + AND replacing is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +</ul></div> +</li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of position + is preserved in all cases. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the replacement took place, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="unordered_set_of_reference.html#unordered_set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(R(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. If an + exception is thrown by some user-provided operation, the <code class="computeroutput"><span class="identifier">bimap</span></code> to which the set view belongs + remains in its original state. + </li> +</ul></div> +<a name="reference_unordered_set_of_replace_data_iterator_data"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleData</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">replace_data</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleData</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the set view. <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> can be assigned to + <code class="computeroutput"><span class="identifier">data_type</span></code>. + </li> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>Effects:</strong></span> Assigns the value <code class="computeroutput"><span class="identifier">x</span></code> to <code class="computeroutput"><span class="identifier">e</span><span class="special">.</span><span class="identifier">second</span></code>, + where <code class="computeroutput"><span class="identifier">e</span></code> is the element + pointed to by <code class="computeroutput"><span class="identifier">position</span></code> + into the <code class="computeroutput"><span class="identifier">bimap</span></code> to + which the set view belongs if, + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + the map view is non-unique OR no other element with equivalent + key exists (except possibly <code class="computeroutput"><span class="special">*</span><span class="identifier">position</span></code>), + </li> +<li class="listitem"> + AND replacing is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +</ul></div> +</li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of position + is preserved in all cases. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the replacement took place, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="unordered_set_of_reference.html#unordered_set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(R(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. If an + exception is thrown by some user-provided operation, the <code class="computeroutput"><span class="identifier">bimap</span></code> to which the set view belongs + remains in its original state. + </li> +</ul></div> +<a name="reference_unordered_set_of_modify_key_iterator_modifier"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">KeyModifier</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">modify_key</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">KeyModifier</span> <span class="identifier">mod</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">KeyModifier</span></code> + is a model of <a href="http://www.sgi.com/tech/stl/UnaryFunction.html" target="_top">Unary + Function</a> accepting arguments of type: <code class="computeroutput"><span class="identifier">key_type</span><span class="special">&</span></code>; <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the view. + </li> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>Effects:</strong></span> Calls <code class="computeroutput"><span class="identifier">mod</span><span class="special">(</span><span class="identifier">e</span><span class="special">.</span><span class="identifier">first</span><span class="special">)</span></code> where e is the element pointed to + by position and rearranges <code class="computeroutput"><span class="special">*</span><span class="identifier">position</span></code> into all the views of + the <code class="computeroutput"><span class="identifier">bimap</span></code>. If the + rearrangement fails, the element is erased. Rearrangement is successful + if + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + the map view is non-unique OR no other element with equivalent + key exists, + </li> +<li class="listitem"> + AND rearrangement is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +</ul></div> +</li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of <code class="computeroutput"><span class="identifier">position</span></code> is preserved if the operation + succeeds. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the operation succeeded, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="unordered_set_of_reference.html#unordered_set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(M(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. If an exception + is thrown by some user-provided operation (except possibly mod), + then the element pointed to by position is erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided for map views. + </li> +</ul></div> +<a name="reference_unordered_set_of_modify_data_iterator_modifier"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">DataModifier</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">modify_data</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">DataModifier</span> <span class="identifier">mod</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">DataModifier</span></code> + is a model of <a href="http://www.sgi.com/tech/stl/UnaryFunction.html" target="_top">Unary + Function</a> accepting arguments of type: <code class="computeroutput"><span class="identifier">data_type</span><span class="special">&</span></code>; <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the view. + </li> +<li class="listitem"> +<p class="simpara"> + <span class="bold"><strong>Effects:</strong></span> Calls <code class="computeroutput"><span class="identifier">mod</span><span class="special">(</span><span class="identifier">e</span><span class="special">.</span><span class="identifier">second</span><span class="special">)</span></code> where e is the element pointed to + by position and rearranges <code class="computeroutput"><span class="special">*</span><span class="identifier">position</span></code> into all the views of + the <code class="computeroutput"><span class="identifier">bimap</span></code>. If the + rearrangement fails, the element is erased. Rearrangement is successful + if + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + the oppositte map view is non-unique OR no other element with + equivalent key in that view exists, + </li> +<li class="listitem"> + AND rearrangement is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +</ul></div> +</li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of <code class="computeroutput"><span class="identifier">position</span></code> is preserved if the operation + succeeds. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the operation succeeded, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="unordered_set_of_reference.html#unordered_set_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(M(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. If an exception + is thrown by some user-provided operation (except possibly mod), + then the element pointed to by position is erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided for map views. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.lookup"></a><a class="link" href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.lookup" title="Lookup">Lookup</a> +</h5></div></div></div> +<p> + <code class="computeroutput"><span class="identifier">unordered_</span><span class="special">[</span><span class="identifier">multi</span><span class="special">]</span><span class="identifier">set_of</span></code> views provide the full lookup + functionality required by unordered associative containers, namely <code class="computeroutput"><span class="identifier">find</span></code>, <code class="computeroutput"><span class="identifier">count</span></code>, + and <code class="computeroutput"><span class="identifier">equal_range</span></code>. Additionally, + these member functions are templatized to allow for non-standard arguments, + so extending the types of search operations allowed. The kind of arguments + permissible when invoking the lookup member functions is defined by the + following concept. + </p> +<p> + A type <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is said to be a <span class="emphasis"><em>compatible key</em></span> of <code class="computeroutput"><span class="special">(</span><span class="identifier">Hash</span><span class="special">,</span> <span class="identifier">Pred</span><span class="special">)</span></code> if <code class="computeroutput"><span class="special">(</span><span class="identifier">CompatibleKey</span><span class="special">,</span> + <span class="identifier">Hash</span><span class="special">,</span> + <span class="identifier">Pred</span><span class="special">)</span></code> + is a compatible extension of <code class="computeroutput"><span class="special">(</span><span class="identifier">Hash</span><span class="special">,</span> <span class="identifier">Pred</span><span class="special">)</span></code>. + This implies that <code class="computeroutput"><span class="identifier">Hash</span></code> + and <code class="computeroutput"><span class="identifier">Pred</span></code> accept arguments + of type <code class="computeroutput"><span class="identifier">CompatibleKey</span></code>, + which usually means they have several overloads of their corresponding + <code class="computeroutput"><span class="keyword">operator</span><span class="special">()</span></code> + member functions. + </p> +<a name="reference_unordered_set_of_find_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">iterator</span> <span class="identifier">find</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">const_iterator</span> <span class="identifier">find</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns a pointer to an + element whose key is equivalent to <code class="computeroutput"><span class="identifier">x</span></code>, + or <code class="computeroutput"><span class="identifier">end</span><span class="special">()</span></code> + if such an element does not exist. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Average case O(1) (constant), + worst case O(n). + </li> +</ul></div> +<a name="reference_unordered_set_of_count_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">size_type</span> <span class="identifier">count</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns the number of elements + with key equivalent to <code class="computeroutput"><span class="identifier">x</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Average case O(count(x)), + worst case O(n). + </li> +</ul></div> +<a name="reference_unordered_set_of_equal_range_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="identifier">iterator</span><span class="special">></span> + <span class="identifier">equal_range</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">const_iterator</span><span class="special">,</span><span class="identifier">const_iterator</span><span class="special">></span> + <span class="identifier">equal_range</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns a range containing + all elements with keys equivalent to <code class="computeroutput"><span class="identifier">x</span></code> + (and only those). + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Average case O(count(x)), + worst case O(n). + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.at____info_at___and_operator_______set_of_only"></a><a class="link" href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.at____info_at___and_operator_______set_of_only" title="at(), info_at() and operator[] - set_of only">at(), + info_at() and operator[] - set_of only</a> +</h5></div></div></div> +<a name="reference_unordered_set_of_at_key_const"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="keyword">const</span> <span class="identifier">data_type</span> <span class="special">&</span> <span class="identifier">at</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is a compatible key of <code class="computeroutput"><span class="identifier">key_compare</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns the <code class="computeroutput"><span class="identifier">data_type</span></code> reference that is associated + with <code class="computeroutput"><span class="identifier">k</span></code>, or throws + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">out_of_range</span></code> if such key does not + exist. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Average case O(1) (constant), + worst case O(n). + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided when <code class="computeroutput"><span class="identifier">unordered_set_of</span></code> is used. + </li> +</ul></div> +<p> + The symmetry of bimap imposes some constraints on <code class="computeroutput"><span class="keyword">operator</span><span class="special">[]</span></code> and the non constant version of at() + that are not found in <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">maps</span></code>. + Tey are only provided if the other collection type is mutable (<code class="computeroutput"><span class="identifier">list_of</span></code>, <code class="computeroutput"><span class="identifier">vector_of</span></code> + and <code class="computeroutput"><span class="identifier">unconstrained_set_of</span></code>). + </p> +<a name="reference_unordered_set_of_operator_bracket_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">data_type</span> <span class="special">&</span> <span class="keyword">operator</span><span class="special">[](</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is a compatible key of <code class="computeroutput"><span class="identifier">key_compare</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="keyword">return</span> + <span class="identifier">insert</span><span class="special">(</span><span class="identifier">value_type</span><span class="special">(</span><span class="identifier">k</span><span class="special">,</span><span class="identifier">data_type</span><span class="special">()))-></span><span class="identifier">second</span><span class="special">;</span></code> + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> If the insertion is + performed O(I(n)), else: Average case O(1) (constant), worst case + O(n). + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided when <code class="computeroutput"><span class="identifier">unordered_set_of</span></code> is used and the + other collection type is mutable. + </li> +</ul></div> +<a name="reference_unordered_set_of_at_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">data_type</span> <span class="special">&</span> <span class="identifier">at</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is a compatible key of <code class="computeroutput"><span class="identifier">key_compare</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> Returns the <code class="computeroutput"><span class="identifier">data_type</span></code> reference that is associated + with <code class="computeroutput"><span class="identifier">k</span></code>, or throws + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">out_of_range</span></code> if such key does not + exist. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Average case O(1) (constant), + worst case O(n). + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided when <code class="computeroutput"><span class="identifier">unordered_set_of</span></code> is used and the + other collection type is mutable. + </li> +</ul></div> +<a name="reference_unordered_set_of_info_at_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="identifier">info_type</span> <span class="special">&</span> <span class="identifier">info_at</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">);</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="keyword">const</span> <span class="identifier">info_type</span> <span class="special">&</span> <span class="identifier">info_at</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> + is a compatible key of <code class="computeroutput"><span class="identifier">key_compare</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Returns the <code class="computeroutput"><span class="identifier">info_type</span></code> reference that is associated + with <code class="computeroutput"><span class="identifier">k</span></code>, or throws + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">out_of_range</span></code> if such key does not + exist. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Average case O(1) (constant), + worst case O(n). + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided when <code class="computeroutput"><span class="identifier">unordered_set_of</span></code> and <code class="computeroutput"><span class="identifier">info_hook</span></code> are used + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.hash_policy"></a><a class="link" href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.hash_policy" title="Hash policy">Hash + policy</a> +</h5></div></div></div> +<a name="reference_unordered_set_of_rehash_size"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">rehash</span><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Increases if necessary + the number of internal buckets so that <code class="computeroutput"><span class="identifier">size</span><span class="special">()/</span><span class="identifier">bucket_count</span><span class="special">()</span></code> does not exceed the maximum load + factor, and <code class="computeroutput"><span class="identifier">bucket_count</span><span class="special">()>=</span><span class="identifier">n</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of iterators + and references to the elements contained is preserved. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Average case O(size()), + worst case O(size(n)2). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.serialization"></a><a class="link" href="unordered_set_of_reference.html#boost_bimap.reference.unordered_set_of_reference.unordered___multi__set_of_views.serialization" title="Serialization">Serialization</a> +</h5></div></div></div> +<p> + Views cannot be serialized on their own, but only as part of the <code class="computeroutput"><span class="identifier">bimap</span></code> into which they are embedded. + In describing the additional preconditions and guarantees associated + to <code class="computeroutput"><span class="identifier">unordered_</span><span class="special">[</span><span class="identifier">multi</span><span class="special">]</span><span class="identifier">set_of</span></code> views with respect to serialization + of their embedding containers, we use the concepts defined in the <code class="computeroutput"><span class="identifier">bimap</span></code> serialization section. + </p> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> saving of a <code class="computeroutput"><span class="identifier">bimap</span></code> b to an output archive (XML archive) + ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> No additional requirements + to those imposed by the container. + </li></ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> loading of a <code class="computeroutput"><span class="identifier">bimap</span></code> b' from an input archive (XML + archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> Additionally to the general + requirements, <code class="computeroutput"><span class="identifier">key_eq</span><span class="special">()</span></code> must be serialization-compatible + with <code class="computeroutput"><span class="identifier">m</span><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="identifier">i</span><span class="special">>().</span><span class="identifier">key_eq</span><span class="special">()</span></code>, + where i is the position of the <code class="computeroutput"><span class="identifier">unordered_</span><span class="special">[</span><span class="identifier">multi</span><span class="special">]</span><span class="identifier">set_of</span></code> + view in the container. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> On successful loading, + the range <code class="computeroutput"><span class="special">[</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">end</span><span class="special">())</span></code> contains restored copies of every + element in <code class="computeroutput"><span class="special">[</span><span class="identifier">m</span><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="identifier">i</span><span class="special">>().</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">m</span><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="identifier">i</span><span class="special">>().</span><span class="identifier">end</span><span class="special">())</span></code>, though not necessarily in the + same order. + </li> +</ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> saving of an <code class="computeroutput"><span class="identifier">iterator</span></code> or <code class="computeroutput"><span class="identifier">const_iterator</span></code> + <code class="computeroutput"><span class="identifier">it</span></code> to an output archive + (XML archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">it</span></code> + is a valid <code class="computeroutput"><span class="identifier">iterator</span></code> + of the view. The associated <code class="computeroutput"><span class="identifier">bimap</span></code> + has been previously saved. + </li></ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> loading of an iterator or + <code class="computeroutput"><span class="identifier">const_iterator</span> <span class="identifier">it</span></code>' + from an input archive (XML archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> On successful loading, + if <code class="computeroutput"><span class="identifier">it</span></code> was dereferenceable + then <code class="computeroutput"><span class="special">*</span><span class="identifier">it</span></code>' + is the restored copy of <code class="computeroutput"><span class="special">*</span><span class="identifier">it</span></code>, otherwise <code class="computeroutput"><span class="identifier">it</span></code>'<code class="computeroutput"> + <span class="special">==</span> <span class="identifier">end</span><span class="special">()</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> It is allowed that <code class="computeroutput"><span class="identifier">it</span></code> be a <code class="computeroutput"><span class="identifier">const_iterator</span></code> + and the restored <code class="computeroutput"><span class="identifier">it</span></code>' + an <code class="computeroutput"><span class="identifier">iterator</span></code>, or viceversa. + </li> +</ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> saving of a local_iterator + or const_local_iterator it to an output archive (XML archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">it</span></code> + is a valid local iterator of the view. The associated <code class="computeroutput"><span class="identifier">bimap</span></code> has been previously saved. + </li></ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> loading of a <code class="computeroutput"><span class="identifier">local_iterator</span></code> or <code class="computeroutput"><span class="identifier">const_local_iterator</span></code> + <code class="computeroutput"><span class="identifier">it</span></code>' from an input archive + (XML archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> On successful loading, + if <code class="computeroutput"><span class="identifier">it</span></code> was dereferenceable + then <code class="computeroutput"><span class="special">*</span><span class="identifier">it</span></code>' + is the restored copy of <code class="computeroutput"><span class="special">*</span><span class="identifier">it</span></code>; if <code class="computeroutput"><span class="identifier">it</span></code> + was <code class="computeroutput"><span class="identifier">m</span><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="identifier">i</span><span class="special">>().</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code> + for some n, then <code class="computeroutput"><span class="identifier">it</span></code>'<code class="computeroutput"> + <span class="special">==</span> <span class="identifier">m</span></code>'<code class="computeroutput"><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="identifier">i</span><span class="special">>().</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code> (where <code class="computeroutput"><span class="identifier">b</span></code> + is the original <code class="computeroutput"><span class="identifier">bimap</span></code>, + <code class="computeroutput"><span class="identifier">b</span></code>' its restored copy + and <code class="computeroutput"><span class="identifier">i</span></code> is the ordinal + of the index.) + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> It is allowed that <code class="computeroutput"><span class="identifier">it</span></code> be a <code class="computeroutput"><span class="identifier">const_local_iterator</span></code> + and the restored <code class="computeroutput"><span class="identifier">it</span></code>' + a <code class="computeroutput"><span class="identifier">local_iterator</span></code>, + or viceversa. + </li> +</ul></div> +</div> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="set_of_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="list_of_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/reference/vector_of_reference.html b/libs/bimap/doc/html/boost_bimap/reference/vector_of_reference.html new file mode 100644 index 0000000000..85c07e4949 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/reference/vector_of_reference.html @@ -0,0 +1,1317 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>vector_of Reference</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../reference.html" title="Reference"> +<link rel="prev" href="list_of_reference.html" title="list_of Reference"> +<link rel="next" href="unconstrained_set_of_reference.html" title="unconstrained_set_of Reference"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="list_of_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unconstrained_set_of_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.reference.vector_of_reference"></a><a class="link" href="vector_of_reference.html" title="vector_of Reference">vector_of + Reference</a> +</h3></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.header__boost_bimap_vector_of_hpp__synopsis">Header + "boost/bimap/vector_of.hpp" synopsis</a></span></dt> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views">vector_of + views</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.complexity_signature"> Complexity + signature</a></span></dt> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.instantiation_types">Instantiation + types</a></span></dt> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.constructors__copy_and_assignment">Constructors, + copy and assignment</a></span></dt> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.capacity_operations">Capacity + operations</a></span></dt> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.modifiers">Modifiers</a></span></dt> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.list_operations">List + operations</a></span></dt> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.rearrange_operations">Rearrange + operations</a></span></dt> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.serialization">Serialization</a></span></dt> +</dl></dd> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.vector_of_reference.header__boost_bimap_vector_of_hpp__synopsis"></a><a class="link" href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.header__boost_bimap_vector_of_hpp__synopsis" title='Header "boost/bimap/vector_of.hpp" synopsis'>Header + "boost/bimap/vector_of.hpp" synopsis</a> +</h4></div></div></div> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">bimaps</span> <span class="special">{</span> + + +<span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">KeyType</span> <span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">vector_of</span><span class="special">;</span> + +<span class="keyword">struct</span> <span class="identifier">vector_of_relation</span><span class="special">;</span> + + +<span class="special">}</span> <span class="comment">// namespace bimap +</span><span class="special">}</span> <span class="comment">// namespace boost +</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.reference.vector_of_reference.vector_of_views"></a><a class="link" href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views" title="vector_of views">vector_of + views</a> +</h4></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.complexity_signature"> Complexity + signature</a></span></dt> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.instantiation_types">Instantiation + types</a></span></dt> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.constructors__copy_and_assignment">Constructors, + copy and assignment</a></span></dt> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.capacity_operations">Capacity + operations</a></span></dt> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.modifiers">Modifiers</a></span></dt> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.list_operations">List + operations</a></span></dt> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.rearrange_operations">Rearrange + operations</a></span></dt> +<dt><span class="section"><a href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.serialization">Serialization</a></span></dt> +</dl></div> +<p> + vector_of views are free-order sequences with constant time positional + access and random access iterators. Elements in a vector_of view are by + default sorted according to their order of insertion: this means that new + elements inserted through a different view of the <code class="computeroutput"><span class="identifier">bimap</span></code> + are appended to the end of the vector_of view; additionally, facilities + are provided for further rearrangement of the elements. The public interface + of vector_of views includes that of list_of views, with differences in + the complexity of the operations, plus extra operations for positional + access (<code class="computeroutput"><span class="keyword">operator</span><span class="special">[]</span></code> + and <code class="computeroutput"><span class="identifier">at</span><span class="special">()</span></code>) + and for capacity handling. Validity of iterators and references to elements + is preserved in all operations, regardless of the capacity status. + </p> +<p> + As is the case with list_of views, vector_of views have the following limitations + with respect to STL sequence containers: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + vector_of views are not <a href="http://www.sgi.com/tech/stl/Assignable.html" target="_top">Assignable</a> + (like any other view.) + </li> +<li class="listitem"> + Insertions into a vector_of view may fail due to clashings with other + views. This alters the semantics of the operations provided with respect + to their analogues in STL sequence containers. + </li> +<li class="listitem"> + Elements in a vector_of view are not mutable, and can only be changed + by means of replace and modify member functions. + </li> +</ul></div> +<p> + Having these restrictions into account, vector of views are models of + <a href="http://www.sgi.com/tech/stl/RandomAccessContainer.html" target="_top">Random + Access Container</a> and <a href="http://www.sgi.com/tech/stl/BackInsertionSequence.html" target="_top">Back + Insertion Sequence</a>. Although these views do not model <a href="http://www.sgi.com/tech/stl/FrontInsertionSequence.html" target="_top">Front + Insertion Sequence</a>, because front insertion and deletion take linear + time, front operations are nonetheless provided to match the interface + of list_of views. We only describe those types and operations that are + either not present in the concepts modeled or do not exactly conform to + the requirements for these types of containers. + </p> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">bimaps</span> <span class="special">{</span> +<span class="keyword">namespace</span> <span class="identifier">views</span> <span class="special">{</span> + +<span class="keyword">template</span><span class="special"><</span> <span class="emphasis"><em>-implementation defined parameter list-</em></span> <span class="special">></span> +<span class="keyword">class</span> <span class="emphasis"><em>-implementation defined view name-</em></span> +<span class="special">{</span> + <span class="keyword">public</span><span class="special">:</span> + + <span class="comment">// types +</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">value_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">allocator_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">reference</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_reference</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">iterator</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_iterator</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">size_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">difference_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">pointer</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_pointer</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">reverse_iterator</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">const_reverse_iterator</span><span class="special">;</span> + + <span class="keyword">typedef</span> <span class="emphasis"><em>-unspecified-</em></span> <span class="identifier">info_type</span><span class="special">;</span> + + <span class="comment">// construct / copy / destroy +</span> + <span class="identifier">this_type</span> <span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">InputIterator</span> <span class="special">></span> + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_assign_iterator_iterator">assign</a><span class="special">(</span><span class="identifier">InputIterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">InputIterator</span> <span class="identifier">last</span><span class="special">);</span> + + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_assign_size_value">assign</a><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">value</span><span class="special">);</span> + + <span class="identifier">allocator_type</span> <span class="identifier">get_allocator</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// iterators +</span> + <span class="identifier">iterator</span> <span class="identifier">begin</span><span class="special">();</span> + <span class="identifier">const_iterator</span> <span class="identifier">begin</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">iterator</span> <span class="identifier">end</span><span class="special">();</span> + <span class="identifier">const_iterator</span> <span class="identifier">end</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">reverse_iterator</span> <span class="identifier">rbegin</span><span class="special">();</span> + <span class="identifier">const_reverse_iterator</span> <span class="identifier">rbegin</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">reverse_iterator</span> <span class="identifier">rend</span><span class="special">();</span> + <span class="identifier">const_reverse_iterator</span> <span class="identifier">rend</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// capacity +</span> + <span class="keyword">bool</span> <span class="identifier">empty</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">size_type</span> <span class="identifier">size</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">size_type</span> <span class="identifier">max_size</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">size_type</span> <a class="link" href="vector_of_reference.html#reference_vector_of_capacity">capacity</a><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_reserve_size">reserve</a><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">m</span><span class="special">);</span> + + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_resize_size_value">resize</a><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">value_type</span><span class="special">());</span> + + <span class="comment">// access +</span> + <span class="identifier">const_reference</span> <span class="keyword">operator</span><span class="special">[](</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">const_reference</span> <span class="identifier">at</span><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">const_reference</span> <span class="identifier">front</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="identifier">const_reference</span> <span class="identifier">back</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="comment">// modifiers +</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <a class="link" href="vector_of_reference.html#reference_vector_of_push_front_value">push_front</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + <span class="keyword">void</span> <span class="identifier">pop_front</span><span class="special">();</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <a class="link" href="vector_of_reference.html#reference_vector_of_push_back_value">push_back</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + <span class="keyword">void</span> <span class="identifier">pop_back</span><span class="special">();</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <a class="link" href="vector_of_reference.html#reference_vector_of_insert_iterator_value">insert</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_insert_iterator_size_value">insert</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">size_type</span> <span class="identifier">m</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">InputIterator</span><span class="special">></span> + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_insert_iterator_iterator_iterator">insert</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">InputIterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">InputIterator</span> <span class="identifier">last</span><span class="special">);</span> + + <span class="identifier">iterator</span> <a class="link" href="vector_of_reference.html#reference_vector_of_erase_iterator">erase</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">);</span> + <span class="identifier">iterator</span> <a class="link" href="vector_of_reference.html#reference_vector_of_erase_iterator_iterator">erase</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> + + <span class="keyword">bool</span> <a class="link" href="vector_of_reference.html#reference_vector_of_replace_iterator_value">replace</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="comment">// Only in map views +</span> <span class="comment">// { +</span> + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="vector_of_reference.html#reference_vector_of_replace_key_iterator_key">replace_key</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleData</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="vector_of_reference.html#reference_vector_of_replace_data_iterator_data">replace_data</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleData</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">KeyModifier</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="vector_of_reference.html#reference_vector_of_modify_key_iterator_modifier">modify_key</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">KeyModifier</span> <span class="identifier">mod</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">DataModifier</span> <span class="special">></span> + <span class="keyword">bool</span> <a class="link" href="vector_of_reference.html#reference_vector_of_modify_data_iterator_modifier">modify_data</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">DataModifier</span> <span class="identifier">mod</span><span class="special">);</span> + + <span class="comment">// } +</span> + + <span class="keyword">void</span> <span class="identifier">clear</span><span class="special">();</span> + + <span class="comment">// list operations +</span> + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_splice_iterator_this">splice</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_splice_iterator_this_iterator">splice</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">);</span> + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_splice_iterator_this_iterator_iterator">splice</a><span class="special">(</span> + <span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> + + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_remove_value">remove</a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">value</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Predicate</span> <span class="special">></span> + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_remove_if_predicate">remove_if</a><span class="special">(</span><span class="identifier">Predicate</span> <span class="identifier">pred</span><span class="special">);</span> + + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_unique">unique</a><span class="special">();</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">BinaryPredicate</span> <span class="special">></span> + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_unique_predicate">unique</a><span class="special">(</span><span class="identifier">BinaryPredicate</span> <span class="identifier">binary_pred</span><span class="special">);</span> + + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_merge_this">merge</a><span class="special">(</span><span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">Compare</span> <span class="special">></span> + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_merge_this_compare">merge</a><span class="special">(</span><span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">Compare</span> <span class="identifier">comp</span><span class="special">);</span> + + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_sort">sort</a><span class="special">();</span> + + <span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">Compare</span> <span class="special">></span> + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_sort_compare">sort</a><span class="special">(</span><span class="identifier">Compare</span> <span class="identifier">comp</span><span class="special">);</span> + + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_reverse">reverse</a><span class="special">();</span> + + <span class="comment">// rearrange operations +</span> + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_relocate_iterator_iterator">relocate</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">);</span> + <span class="keyword">void</span> <a class="link" href="vector_of_reference.html#reference_vector_of_relocate_iterator_iterator_iterator">relocate</a><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> +<span class="special">};</span> + +<span class="comment">// view comparison +</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">==(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">!=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">></span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">>=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> +<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">v2</span> <span class="special">);</span> + +<span class="special">}</span> <span class="comment">// namespace views +</span><span class="special">}</span> <span class="comment">// namespace bimap +</span><span class="special">}</span> <span class="comment">// namespace boost +</span></pre> +<p> + In the case of a <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">vector_of</span><span class="special"><</span><span class="identifier">Left</span><span class="special">>,</span> <span class="special">...</span> <span class="special">></span></code> + </p> +<p> + In the set view: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">relation</span><span class="special"><</span> <span class="identifier">Left</span><span class="special">,</span> <span class="special">...</span> <span class="special">></span> <span class="identifier">key_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">relation</span><span class="special"><</span> <span class="identifier">Left</span><span class="special">,</span> <span class="special">...</span> <span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> +</pre> +<p> + In the left map view: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">Left</span> <span class="identifier">key_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="special">...</span> <span class="identifier">data_type</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span> <span class="identifier">Left</span><span class="special">,</span> <span class="special">...</span> <span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> +</pre> +<p> + In the right map view: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="special">...</span> <span class="identifier">key_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">Left</span> <span class="identifier">data_type</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">signature</span><span class="special">-</span><span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span> <span class="special">...</span> <span class="special">,</span> <span class="identifier">Left</span> <span class="special">></span> <span class="identifier">value_type</span><span class="special">;</span> +</pre> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.vector_of_reference.vector_of_views.complexity_signature"></a><a name="vector_of_complexity_signature"></a> <a class="link" href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.complexity_signature" title="Complexity signature">Complexity + signature</a> +</h5></div></div></div> +<p> + Here and in the descriptions of operations of <code class="computeroutput"><span class="identifier">vector_of</span></code> + views, we adopt the scheme outlined in the <a class="link" href="bimap_reference.html#complexity_signature_explanation">complexity + signature section</a>. The complexity signature of <code class="computeroutput"><span class="identifier">vector_of</span></code> + view is: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + copying: <code class="computeroutput"><span class="identifier">c</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">n</span> <span class="special">*</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>, + </li> +<li class="listitem"> + insertion: <code class="computeroutput"><span class="identifier">i</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> + (amortized constant), + </li> +<li class="listitem"> + hinted insertion: <code class="computeroutput"><span class="identifier">h</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> (amortized constant), + </li> +<li class="listitem"> + deletion: <code class="computeroutput"><span class="identifier">d</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">m</span></code>, + where m is the distance from the deleted element to the end of the + sequence, + </li> +<li class="listitem"> + replacement: <code class="computeroutput"><span class="identifier">r</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> + (constant), + </li> +<li class="listitem"> + modifying: <code class="computeroutput"><span class="identifier">m</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span></code> + (constant). + </li> +</ul></div> +<p> + The following expressions are also used as a convenience for writing + down some of the complexity formulas: + </p> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <code class="computeroutput"><span class="identifier">shl</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span><span class="identifier">b</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span></code> + if a is nonzero, 0 otherwise. <code class="computeroutput"><span class="identifier">rel</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span><span class="identifier">b</span><span class="special">,</span><span class="identifier">c</span><span class="special">)</span> <span class="special">=</span></code> if + <code class="computeroutput"><span class="identifier">a</span><span class="special"><</span><span class="identifier">b</span></code>, <code class="computeroutput"><span class="identifier">c</span><span class="special">-</span><span class="identifier">a</span></code>, + else <code class="computeroutput"><span class="identifier">a</span><span class="special">-</span><span class="identifier">b</span></code>, + </p> +</div> +<p> + (<code class="computeroutput"><span class="identifier">shl</span></code> and <code class="computeroutput"><span class="identifier">rel</span></code> stand for <span class="emphasis"><em>shift left</em></span> + and <span class="emphasis"><em>relocate</em></span>, respectively.) + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.vector_of_reference.vector_of_views.instantiation_types"></a><a class="link" href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.instantiation_types" title="Instantiation types">Instantiation + types</a> +</h5></div></div></div> +<p> + <code class="computeroutput"><span class="identifier">vector_of</span></code> views are instantiated + internally to <code class="computeroutput"><span class="identifier">bimap</span></code> and + specified by means of the collection type specifiers and the bimap itself. + Instantiations are dependent on the following types: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">Value</span></code> from <code class="computeroutput"><span class="identifier">vector_of</span></code>, + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">Allocator</span></code> from <code class="computeroutput"><span class="identifier">bimap</span></code>, + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.vector_of_reference.vector_of_views.constructors__copy_and_assignment"></a><a class="link" href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.constructors__copy_and_assignment" title="Constructors, copy and assignment">Constructors, + copy and assignment</a> +</h5></div></div></div> +<p> + As explained in the views concepts section, views do not have public + constructors or destructors. Assignment, on the other hand, is provided. + </p> +<pre class="programlisting"><span class="identifier">this_type</span> <span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="identifier">a</span><span class="special">=</span><span class="identifier">b</span><span class="special">;</span></code> where a and b are the <code class="computeroutput"><span class="identifier">bimap</span></code> objects to which <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + and <code class="computeroutput"><span class="identifier">x</span></code> belong, respectively. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>. + </li> +</ul></div> +<a name="reference_vector_of_assign_iterator_iterator"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">InputIterator</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">assign</span><span class="special">(</span><span class="identifier">InputIterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">InputIterator</span> <span class="identifier">last</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">InputIterator</span></code> + is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html" target="_top">Input + Iterator</a> over elements of type <code class="computeroutput"><span class="identifier">value_type</span></code> + or a type convertible to <code class="computeroutput"><span class="identifier">value_type</span></code>. + <code class="computeroutput"><span class="identifier">first</span></code> and <code class="computeroutput"><span class="identifier">last</span></code> are not iterators into any + view of the <code class="computeroutput"><span class="identifier">bimap</span></code> + to which this view belongs. <code class="computeroutput"><span class="identifier">last</span></code> + is reachable from <code class="computeroutput"><span class="identifier">first</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="identifier">clear</span><span class="special">();</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">end</span><span class="special">(),</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">);</span></code> + </li> +</ul></div> +<a name="reference_vector_of_assign_size_value"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">assign</span><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">value</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="identifier">clear</span><span class="special">();</span> <span class="keyword">for</span><span class="special">(</span><span class="identifier">size_type</span> + <span class="identifier">i</span> <span class="special">=</span> + <span class="number">0</span><span class="special">;</span> + <span class="identifier">i</span> <span class="special"><</span> + <span class="identifier">n</span><span class="special">;</span> + <span class="special">++</span><span class="identifier">n</span><span class="special">)</span> <span class="identifier">push_back</span><span class="special">(</span><span class="identifier">v</span><span class="special">);</span></code> + </li></ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.vector_of_reference.vector_of_views.capacity_operations"></a><a class="link" href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.capacity_operations" title="Capacity operations">Capacity + operations</a> +</h5></div></div></div> +<a name="reference_vector_of_capacity"></a><pre class="programlisting"><span class="identifier">size_type</span> <span class="identifier">capacity</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> The total number of elements + <code class="computeroutput"><span class="identifier">c</span></code> such that, when + <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span> + <span class="special"><</span> <span class="identifier">c</span></code>, + back insertions happen in constant time (the general case as described + by i(n) is <span class="emphasis"><em>amortized</em></span> constant time.) + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Validity of iterators and + references to elements is preserved in all insertions, regardless + of the capacity status. + </li> +</ul></div> +<a name="reference_vector_of_reserve_size"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">reserve</span><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">m</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> If the previous value of + <code class="computeroutput"><span class="identifier">capacity</span><span class="special">()</span></code> + was greater than or equal to <code class="computeroutput"><span class="identifier">m</span></code>, + nothing is done; otherwise, the internal capacity is changed so that + <code class="computeroutput"><span class="identifier">capacity</span><span class="special">()>=</span><span class="identifier">m</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> If the capacity is not + changed, constant; otherwise O(n). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> If the capacity + is not changed, nothrow; otherwise, strong. + </li> +</ul></div> +<a name="reference_vector_of_resize_size_value"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">resize</span><span class="special">(</span><span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">value_type</span><span class="special">());</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="keyword">if</span><span class="special">(</span> <span class="identifier">n</span> <span class="special">></span> <span class="identifier">size</span><span class="special">()</span> <span class="special">)</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">end</span><span class="special">(),</span> + <span class="identifier">n</span><span class="special">-</span><span class="identifier">size</span><span class="special">(),</span> + <span class="identifier">x</span><span class="special">);</span></code> + <code class="computeroutput"><span class="keyword">else</span> <span class="keyword">if</span><span class="special">(</span> <span class="identifier">n</span><span class="special"><</span><span class="identifier">size</span><span class="special">()</span> <span class="special">)</span> <span class="identifier">erase</span><span class="special">(</span><span class="identifier">begin</span><span class="special">()+</span><span class="identifier">n</span><span class="special">,</span><span class="identifier">end</span><span class="special">());</span></code> + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> If an expansion is requested, + the size of the view is not guaranteed to be n after this operation + (other views may ban insertions.) + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.vector_of_reference.vector_of_views.modifiers"></a><a class="link" href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.modifiers" title="Modifiers">Modifiers</a> +</h5></div></div></div> +<a name="reference_vector_of_push_front_value"></a><pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">push_front</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Inserts x at the beginning + of the sequence if no other view of the <code class="computeroutput"><span class="identifier">bimap</span></code> + bans the insertion. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> The return value is a pair + <code class="computeroutput"><span class="identifier">p</span></code>. <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span></code> is <code class="computeroutput"><span class="keyword">true</span></code> + if and only if insertion took place. On successful insertion, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to the element inserted; + otherwise, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to an element that + caused the insertion to be banned. Note that more than one element + can be causing insertion not to be allowed. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(n+I(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. + </li> +</ul></div> +<a name="reference_vector_of_push_back_value"></a><pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">push_back</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Inserts <code class="computeroutput"><span class="identifier">x</span></code> + at the end of the sequence if no other view of the <code class="computeroutput"><span class="identifier">bimap</span></code> bans the insertion. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> The return value is a pair + <code class="computeroutput"><span class="identifier">p</span></code>. <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span></code> is <code class="computeroutput"><span class="keyword">true</span></code> + if and only if insertion took place. On successful insertion, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to the element inserted; + otherwise, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to an element that + caused the insertion to be banned. Note that more than one element + can be causing insertion not to be allowed. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(I(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. + </li> +</ul></div> +<a name="reference_vector_of_insert_iterator_value"></a><pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid iterator of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Inserts <code class="computeroutput"><span class="identifier">x</span></code> + before position if insertion is allowed by all other views of the + <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> The return value is a pair + <code class="computeroutput"><span class="identifier">p</span></code>. <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span></code> is <code class="computeroutput"><span class="keyword">true</span></code> + if and only if insertion took place. On successful insertion, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to the element inserted; + otherwise, <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> points to an element that + caused the insertion to be banned. Note that more than one element + can be causing insertion not to be allowed. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(shl(end()-position,1) + I(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. + </li> +</ul></div> +<a name="reference_vector_of_insert_iterator_size_value"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">size_type</span> <span class="identifier">m</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid iterator of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="keyword">for</span><span class="special">(</span><span class="identifier">size_type</span> + <span class="identifier">i</span> <span class="special">=</span> + <span class="number">0</span><span class="special">;</span> + <span class="identifier">i</span> <span class="special"><</span> + <span class="identifier">m</span><span class="special">;</span> + <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">position</span><span class="special">,</span> <span class="identifier">x</span><span class="special">);</span></code> + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(shl(end()-position,m) + m*I(n+m)). + </li> +</ul></div> +<a name="reference_vector_of_insert_iterator_iterator_iterator"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">InputIterator</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">InputIterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">InputIterator</span> <span class="identifier">last</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid iterator of the view. <code class="computeroutput"><span class="identifier">InputIterator</span></code> + is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html" target="_top">Input + Iterator</a> over elements of type <code class="computeroutput"><span class="identifier">value_type</span></code> + or a type convertible to <code class="computeroutput"><span class="identifier">value_type</span></code>. + <code class="computeroutput"><span class="identifier">first</span></code> and <code class="computeroutput"><span class="identifier">last</span></code> are not iterators into any + view of the <code class="computeroutput"><span class="identifier">bimap</span></code> + to which this view belongs. <code class="computeroutput"><span class="identifier">last</span></code> + is reachable from <code class="computeroutput"><span class="identifier">first</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="keyword">while</span><span class="special">(</span><span class="identifier">first</span><span class="special">!=</span><span class="identifier">last</span><span class="special">)</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">position</span><span class="special">,*</span><span class="identifier">first</span><span class="special">++);</span></code> + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(shl(end()-position,m) + m*I(n+m)), where m is the number of elements + in <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_vector_of_erase_iterator"></a><pre class="programlisting"><span class="identifier">iterator</span> <span class="identifier">erase</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Deletes the element pointed + to by <code class="computeroutput"><span class="identifier">position</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> An iterator pointing to + the element immediately following the one that was deleted, or <code class="computeroutput"><span class="identifier">end</span><span class="special">()</span></code> + if no such element exists. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(D(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +<a name="reference_vector_of_erase_iterator_iterator"></a><pre class="programlisting"><span class="identifier">iterator</span> <span class="identifier">erase</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code> + is a valid range of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Deletes the elements in + <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns:</strong></span> last. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(m*D(n)), where m is the number of elements in <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +<a name="reference_vector_of_replace_iterator_value"></a><pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">replace</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Assigns the value x to + the element pointed to by position into the <code class="computeroutput"><span class="identifier">bimap</span></code> + to which the view belongs if replacing is allowed by all other views + of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of position + is preserved in all cases. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the replacement took place, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(R(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. If an + exception is thrown by some user-provided operation the <code class="computeroutput"><span class="identifier">bimap</span></code> to which the view belongs + remains in its original state. + </li> +</ul></div> +<a name="reference_vector_of_replace_key_iterator_key"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">replace_key</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the set view. <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> can be assigned to + <code class="computeroutput"><span class="identifier">key_type</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Assigns the value <code class="computeroutput"><span class="identifier">x</span></code> to <code class="computeroutput"><span class="identifier">e</span><span class="special">.</span><span class="identifier">first</span></code>, + where <code class="computeroutput"><span class="identifier">e</span></code> is the element + pointed to by <code class="computeroutput"><span class="identifier">position</span></code> + into the <code class="computeroutput"><span class="identifier">bimap</span></code> to + which the set view belongs if replacing is allowed by all other views + of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of position + is preserved in all cases. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the replacement took place, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(R(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. If an + exception is thrown by some user-provided operation, the <code class="computeroutput"><span class="identifier">bimap</span></code> to which the set view belongs + remains in its original state. + </li> +</ul></div> +<a name="reference_vector_of_replace_data_iterator_data"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">CompatibleData</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">replace_data</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">CompatibleData</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the set view. <code class="computeroutput"><span class="identifier">CompatibleKey</span></code> can be assigned to + <code class="computeroutput"><span class="identifier">data_type</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Assigns the value <code class="computeroutput"><span class="identifier">x</span></code> to <code class="computeroutput"><span class="identifier">e</span><span class="special">.</span><span class="identifier">second</span></code>, + where <code class="computeroutput"><span class="identifier">e</span></code> is the element + pointed to by <code class="computeroutput"><span class="identifier">position</span></code> + into the <code class="computeroutput"><span class="identifier">bimap</span></code> to + which the set view belongs if replacing is allowed by all other views + of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of position + is preserved in all cases. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the replacement took place, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(R(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Strong. If an + exception is thrown by some user-provided operation, the <code class="computeroutput"><span class="identifier">bimap</span></code> to which the set view belongs + remains in its original state. + </li> +</ul></div> +<a name="reference_vector_of_modify_key_iterator_modifier"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">KeyModifier</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">modify_key</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">KeyModifier</span> <span class="identifier">mod</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">KeyModifier</span></code> + is a model of <a href="http://www.sgi.com/tech/stl/UnaryFunction.html" target="_top">Unary + Function</a> accepting arguments of type: <code class="computeroutput"><span class="identifier">key_type</span><span class="special">&</span></code>; <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Calls <code class="computeroutput"><span class="identifier">mod</span><span class="special">(</span><span class="identifier">e</span><span class="special">.</span><span class="identifier">first</span><span class="special">)</span></code> where e is the element pointed to + by position and rearranges <code class="computeroutput"><span class="special">*</span><span class="identifier">position</span></code> into all the views of + the <code class="computeroutput"><span class="identifier">bimap</span></code>. If the + rearrangement fails, the element is erased. It is successful if the + rearrangement is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of <code class="computeroutput"><span class="identifier">position</span></code> is preserved if the operation + succeeds. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the operation succeeded, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(M(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. If an exception + is thrown by some user-provided operation (except possibly mod), + then the element pointed to by position is erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided for map views. + </li> +</ul></div> +<a name="reference_vector_of_modify_data_iterator_modifier"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">DataModifier</span> <span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">modify_data</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">DataModifier</span> <span class="identifier">mod</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">DataModifier</span></code> + is a model of <a href="http://www.sgi.com/tech/stl/UnaryFunction.html" target="_top">Unary + Function</a> accepting arguments of type: <code class="computeroutput"><span class="identifier">data_type</span><span class="special">&</span></code>; <code class="computeroutput"><span class="identifier">position</span></code> + is a valid dereferenceable iterator of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Calls <code class="computeroutput"><span class="identifier">mod</span><span class="special">(</span><span class="identifier">e</span><span class="special">.</span><span class="identifier">second</span><span class="special">)</span></code> where e is the element pointed to + by position and rearranges <code class="computeroutput"><span class="special">*</span><span class="identifier">position</span></code> into all the views of + the <code class="computeroutput"><span class="identifier">bimap</span></code>. If the + rearrangement fails, the element is erased. It is successful if the + rearrangement is allowed by all other views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of <code class="computeroutput"><span class="identifier">position</span></code> is preserved if the operation + succeeds. + </li> +<li class="listitem"> + <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="keyword">true</span></code> + if the operation succeeded, <code class="computeroutput"><span class="keyword">false</span></code> + otherwise. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(M(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. If an exception + is thrown by some user-provided operation (except possibly mod), + then the element pointed to by position is erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> Only provided for map views. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.vector_of_reference.vector_of_views.list_operations"></a><a class="link" href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.list_operations" title="List operations">List + operations</a> +</h5></div></div></div> +<p> + <code class="computeroutput"><span class="identifier">vector_of</span></code> views replicate + the interface of <code class="computeroutput"><span class="identifier">list_of</span></code> + views, which in turn includes the list operations provided by <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span></code>. The syntax and behavior of these + operations exactly matches those of <code class="computeroutput"><span class="identifier">list_of</span></code> + views, but the associated complexity bounds differ in general. + </p> +<a name="reference_vector_of_splice_iterator_this"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">splice</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid iterator of the view. <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">!=</span><span class="keyword">this</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Inserts the contents of + <code class="computeroutput"><span class="identifier">x</span></code> before position, + in the same order as they were in <code class="computeroutput"><span class="identifier">x</span></code>. + Those elements successfully inserted are erased from <code class="computeroutput"><span class="identifier">x</span></code>. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(shl(end()-position,x.size()) + x.size()*I(n+x.size()) + x.size()*D(x.size())). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_vector_of_splice_iterator_this_iterator"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">splice</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">,</span><span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid iterator of the view. <code class="computeroutput"><span class="identifier">i</span></code> + is a valid dereferenceable iterator <code class="computeroutput"><span class="identifier">x</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Inserts the element pointed + to by <code class="computeroutput"><span class="identifier">i</span></code> before <code class="computeroutput"><span class="identifier">position</span></code>: if insertion is successful, + the element is erased from <code class="computeroutput"><span class="identifier">x</span></code>. + In the special case <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, no copy or deletion is performed, + and the operation is always successful. If <code class="computeroutput"><span class="identifier">position</span><span class="special">==</span><span class="identifier">i</span></code>, + no operation is performed. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + no iterator or reference is invalidated. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + O(rel(position,i,i+1)); otherwise O(shl(end()-position,1) + I(n) + + D(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + nothrow; otherwise, strong. + </li> +</ul></div> +<a name="reference_vector_of_splice_iterator_this_iterator_iterator"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">splice</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid iterator of the view. <code class="computeroutput"><span class="identifier">first</span></code> + and <code class="computeroutput"><span class="identifier">last</span></code> are valid + iterators of <code class="computeroutput"><span class="identifier">x</span></code>. + <code class="computeroutput"><span class="identifier">last</span></code> is reachable + from <code class="computeroutput"><span class="identifier">first</span></code>. <code class="computeroutput"><span class="identifier">position</span></code> is not in the range <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> For each element in the + range <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>, insertion is tried before <code class="computeroutput"><span class="identifier">position</span></code>; if the operation is successful, + the element is erased from <code class="computeroutput"><span class="identifier">x</span></code>. + In the special case <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, no copy or deletion is performed, + and insertions are always successful. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + no iterator or reference is invalidated. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + O(rel(position,first,last)); otherwise O(shl(end()-position,m) + + m*I(n+m) + m*D(x.size())) where m is the number of elements in <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + nothrow; otherwise, basic. + </li> +</ul></div> +<a name="reference_vector_of_remove_value"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">remove</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span> <span class="identifier">value</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Erases all elements of + the view which compare equal to <code class="computeroutput"><span class="identifier">value</span></code>. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(n + m*D(n)), where m is the number of elements erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_vector_of_remove_if_predicate"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Predicate</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">remove_if</span><span class="special">(</span><span class="identifier">Predicate</span> <span class="identifier">pred</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Erases all elements <code class="computeroutput"><span class="identifier">x</span></code> of the view for which <code class="computeroutput"><span class="identifier">pred</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code> + holds. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(n + m*D(n)), where m is the number of elements erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_vector_of_unique"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">unique</span><span class="special">();</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Eliminates all but the + first element from every consecutive group of equal elements referred + to by the iterator <code class="computeroutput"><span class="identifier">i</span></code> + in the range <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">+</span><span class="number">1</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code> for which <code class="computeroutput"><span class="special">*</span><span class="identifier">i</span><span class="special">==*(</span><span class="identifier">i</span><span class="special">-</span><span class="number">1</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(n + m*D(n)), where m is the number of elements erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_vector_of_unique_predicate"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">BinaryPredicate</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">unique</span><span class="special">(</span><span class="identifier">BinaryPredicate</span> <span class="identifier">binary_pred</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Eliminates all but the + first element from every consecutive group of elements referred to + by the iterator i in the range <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">+</span><span class="number">1</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code> + for which <code class="computeroutput"><span class="identifier">binary_pred</span><span class="special">(*</span><span class="identifier">i</span><span class="special">,</span> <span class="special">*(</span><span class="identifier">i</span><span class="special">-</span><span class="number">1</span><span class="special">))</span></code> + holds. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + O(n + m*D(n)), where m is the number of elements erased. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_vector_of_merge_this"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">merge</span><span class="special">(</span><span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">value_type</span><span class="special">></span></code> is a <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html" target="_top">Strict + Weak Ordering</a> over <code class="computeroutput"><span class="identifier">value_type</span></code>. + Both the view and <code class="computeroutput"><span class="identifier">x</span></code> + are sorted according to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">value_type</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Attempts to insert every + element of x into the corresponding position of the view (according + to the order). Elements successfully inserted are erased from <code class="computeroutput"><span class="identifier">x</span></code>. The resulting sequence is stable, + i.e. equivalent elements of either container preserve their relative + position. In the special case <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, no operation is performed. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Elements in the + view and remaining elements in <code class="computeroutput"><span class="identifier">x</span></code> + are sorted. Validity of iterators to the view and of non-erased elements + of <code class="computeroutput"><span class="identifier">x</span></code> references is + preserved. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + constant; otherwise O(n + x.size()*I(n+x.size()) + x.size()*D(x.size())). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + nothrow; otherwise, basic. + </li> +</ul></div> +<a name="reference_vector_of_merge_this_compare"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Compare</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">merge</span><span class="special">(</span><span class="identifier">this_type</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">Compare</span> <span class="identifier">comp</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">Compare</span></code> + is a <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html" target="_top">Strict + Weak Ordering</a> over <code class="computeroutput"><span class="identifier">value_type</span></code>. + Both the view and <code class="computeroutput"><span class="identifier">x</span></code> + are sorted according to comp. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Attempts to insert every + element of <code class="computeroutput"><span class="identifier">x</span></code> into + the corresponding position of the view (according to <code class="computeroutput"><span class="identifier">comp</span></code>). Elements successfully inserted + are erased from <code class="computeroutput"><span class="identifier">x</span></code>. + The resulting sequence is stable, i.e. equivalent elements of either + container preserve their relative position. In the special case + <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + no operation is performed. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Elements in the + view and remaining elements in <code class="computeroutput"><span class="identifier">x</span></code> + are sorted according to <code class="computeroutput"><span class="identifier">comp</span></code>. + Validity of iterators to the view and of non-erased elements of + <code class="computeroutput"><span class="identifier">x</span></code> references is preserved. + </li> +<li class="listitem"> + <a class="link" href="vector_of_reference.html#vector_of_complexity_signature"><span class="bold"><strong>Complexity:</strong></span></a> + If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + constant; otherwise O(n + x.size()*I(n+x.size()) + x.size()*D(x.size())). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> If <code class="computeroutput"><span class="special">&</span><span class="identifier">x</span><span class="special">==</span><span class="keyword">this</span></code>, + nothrow; otherwise, basic. + </li> +</ul></div> +<a name="reference_vector_of_sort"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">sort</span><span class="special">();</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">value_type</span><span class="special">></span></code> is a <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html" target="_top">Strict + Weak Ordering</a> over <code class="computeroutput"><span class="identifier">value_type</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Sorts the view according + to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">value_type</span><span class="special">></span></code>. + The sorting is stable, i.e. equivalent elements preserve their relative + position. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of iterators + and references is preserved. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(n*log(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_vector_of_sort_compare"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Compare</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">sort</span><span class="special">(</span><span class="identifier">Compare</span> <span class="identifier">comp</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> Compare is a <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html" target="_top">Strict + Weak Ordering</a> over <code class="computeroutput"><span class="identifier">value_type</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Sorts the view according + to <code class="computeroutput"><span class="identifier">comp</span></code>. The sorting + is stable, i.e. equivalent elements preserve their relative position. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of iterators + and references is preserved. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(n*log(n)). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> Basic. + </li> +</ul></div> +<a name="reference_vector_of_reverse"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">reverse</span><span class="special">();</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Reverses the order of the + elements in the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> Validity of iterators + and references is preserved. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> O(n). + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.vector_of_reference.vector_of_views.rearrange_operations"></a><a class="link" href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.rearrange_operations" title="Rearrange operations">Rearrange + operations</a> +</h5></div></div></div> +<p> + These operations, without counterpart in <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span></code> + (although splice provides partially overlapping functionality), perform + individual and global repositioning of elements inside the index. + </p> +<a name="reference_vector_of_relocate_iterator_iterator"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">relocate</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid iterator of the view. <code class="computeroutput"><span class="identifier">i</span></code> + is a valid dereferenceable iterator of the view. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> Inserts the element pointed + to by <code class="computeroutput"><span class="identifier">i</span></code> before <code class="computeroutput"><span class="identifier">position</span></code>. If <code class="computeroutput"><span class="identifier">position</span><span class="special">==</span><span class="identifier">i</span></code>, + no operation is performed. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> No iterator or reference + is invalidated. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Constant. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +<a name="reference_vector_of_relocate_iterator_iterator_iterator"></a><pre class="programlisting"><span class="keyword">void</span> <span class="identifier">relocate</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">position</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">last</span><span class="special">);</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">position</span></code> + is a valid iterator of the view. <code class="computeroutput"><span class="identifier">first</span></code> + and <code class="computeroutput"><span class="identifier">last</span></code> are valid + iterators of the view. <code class="computeroutput"><span class="identifier">last</span></code> + is reachable from <code class="computeroutput"><span class="identifier">first</span></code>. + <code class="computeroutput"><span class="identifier">position</span></code> is not in + the range <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Effects:</strong></span> The range of elements + <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span><span class="identifier">last</span><span class="special">)</span></code> is repositioned just before <code class="computeroutput"><span class="identifier">position</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> No iterator or reference + is invalidated. + </li> +<li class="listitem"> + <span class="bold"><strong>Complexity:</strong></span> Constant. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception safety:</strong></span> nothrow. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h5 class="title"> +<a name="boost_bimap.reference.vector_of_reference.vector_of_views.serialization"></a><a class="link" href="vector_of_reference.html#boost_bimap.reference.vector_of_reference.vector_of_views.serialization" title="Serialization">Serialization</a> +</h5></div></div></div> +<p> + Views cannot be serialized on their own, but only as part of the <code class="computeroutput"><span class="identifier">bimap</span></code> into which they are embedded. + In describing the additional preconditions and guarantees associated + to <code class="computeroutput"><span class="identifier">vector_of</span></code> views with + respect to serialization of their embedding containers, we use the concepts + defined in the <code class="computeroutput"><span class="identifier">bimap</span></code> + serialization section. + </p> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> saving of a <code class="computeroutput"><span class="identifier">bimap</span></code> b to an output archive (XML archive) + ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> No additional requirements + to those imposed by the container. + </li></ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> loading of a <code class="computeroutput"><span class="identifier">bimap</span></code> b' from an input archive (XML + archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Requires:</strong></span> No additional requirements + to those imposed by the container. + </li> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> On successful loading, + each of the elements of <code class="computeroutput"><span class="special">[</span><span class="identifier">begin</span><span class="special">(),</span> + <span class="identifier">end</span><span class="special">())</span></code> + is a restored copy of the corresponding element in <code class="computeroutput"><span class="special">[</span><span class="identifier">m</span><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="identifier">i</span><span class="special">>().</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">m</span><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="identifier">i</span><span class="special">>().</span><span class="identifier">end</span><span class="special">())</span></code>, where <code class="computeroutput"><span class="identifier">i</span></code> + is the position of the <code class="computeroutput"><span class="identifier">vector_of</span></code> + view in the container. + </li> +</ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> saving of an <code class="computeroutput"><span class="identifier">iterator</span></code> or <code class="computeroutput"><span class="identifier">const_iterator</span></code> + <code class="computeroutput"><span class="identifier">it</span></code> to an output archive + (XML archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="identifier">it</span></code> + is a valid iterator of the view. The associated <code class="computeroutput"><span class="identifier">bimap</span></code> + has been previously saved. + </li></ul></div> +<div class="sidebar"> +<div class="titlepage"></div> +<p> + <span class="bold"><strong>Operation:</strong></span> loading of an <code class="computeroutput"><span class="identifier">iterator</span></code> or <code class="computeroutput"><span class="identifier">const_iterator</span></code> + <code class="computeroutput"><span class="identifier">it</span></code>' from an input archive + (XML archive) ar. + </p> +</div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Postconditions:</strong></span> On successful loading, + if it was dereferenceable then <code class="computeroutput"><span class="special">*</span><span class="identifier">it</span></code>' is the restored copy of <code class="computeroutput"><span class="special">*</span><span class="identifier">it</span></code>, + otherwise <code class="computeroutput"><span class="identifier">it</span></code>'<code class="computeroutput"><span class="special">==</span><span class="identifier">end</span><span class="special">()</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong>Note:</strong></span> It is allowed that it be a + <code class="computeroutput"><span class="identifier">const_iterator</span></code> and + the restored <code class="computeroutput"><span class="identifier">it</span></code>' + an <code class="computeroutput"><span class="identifier">iterator</span></code>, or viceversa. + </li> +</ul></div> +</div> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="list_of_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unconstrained_set_of_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/release_notes.html b/libs/bimap/doc/html/boost_bimap/release_notes.html new file mode 100644 index 0000000000..fb4e476c98 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/release_notes.html @@ -0,0 +1,46 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Release notes</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="prev" href="future_work.html" title="Future work"> +<link rel="next" href="rationale.html" title="Rationale"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> +<td align="center"><a href="../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="future_work.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="rationale.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="boost_bimap.release_notes"></a><a class="link" href="release_notes.html" title="Release notes">Release notes</a> +</h2></div></div></div> +<p> + Not yet released. + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="future_work.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="rationale.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/test_suite.html b/libs/bimap/doc/html/boost_bimap/test_suite.html new file mode 100644 index 0000000000..e77a7f754d --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/test_suite.html @@ -0,0 +1,459 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Test suite</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="prev" href="examples/multiindex_to_bimap_path___hashed_indices.html" title="MultiIndex to Bimap Path - Hashed indices"> +<link rel="next" href="future_work.html" title="Future work"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> +<td align="center"><a href="../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="examples/multiindex_to_bimap_path___hashed_indices.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="future_work.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="boost_bimap.test_suite"></a><a class="link" href="test_suite.html" title="Test suite">Test suite</a> +</h2></div></div></div> +<p> + The Boost.Bimap test suite exercises the whole spectrum of functionalities + provided by the library. Although the tests are not meant to serve as a learning + guide, the interested reader may find it useful to inspect the source code + to gain familiarity with some of the least common features offered by Boost.Bimap. + </p> +<div class="informaltable"><table class="table"> +<colgroup> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Program + </p> + </th> +<th> + <p> + Description + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <a href="../../../test/test_tagged.cpp" target="_top">test_tagged.cpp </a> + </p> + </td> +<td> + <p> + Tagged idiom checks + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_mutant.cpp" target="_top">test_mutant.cpp </a> + </p> + </td> +<td> + <p> + Test the mutant idiom + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_structured_pair.cpp" target="_top">test_structured_pair.cpp + </a> + </p> + </td> +<td> + <p> + Test structured pair class + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_mutant_relation.cpp" target="_top">test_mutant_relation.cpp + </a> + </p> + </td> +<td> + <p> + Test the relation class + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_set_of.cpp" target="_top">test_bimap_set_of.cpp + </a> + </p> + </td> +<td> + <p> + Library interface check + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_multiset_of.cpp" target="_top">test_bimap_multiset_of.cpp + </a> + </p> + </td> +<td> + <p> + Library interface check + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_unordered_set_of.cpp" target="_top">test_bimap_unordered_set_of.cpp + </a> + </p> + </td> +<td> + <p> + Library interface check + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_unordered_multiset_of.cpp" target="_top">test_bimap_unordered_multiset_of.cpp + </a> + </p> + </td> +<td> + <p> + Library interface check + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_list_of.cpp" target="_top">test_bimap_list_of.cpp + </a> + </p> + </td> +<td> + <p> + Library interface check + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_vector_of.cpp" target="_top">test_bimap_vector_of.cpp + </a> + </p> + </td> +<td> + <p> + Library interface check + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_convenience_header.cpp" target="_top">test_bimap_convenience_header.cpp + </a> + </p> + </td> +<td> + <p> + Library interface check + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_ordered.cpp" target="_top">test_bimap_ordered.cpp + </a> + </p> + </td> +<td> + <p> + Test set and multiset based bimaps + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_unordered.cpp" target="_top">test_bimap_unordered.cpp + </a> + </p> + </td> +<td> + <p> + Test unordered_set and unordered_multiset based bimaps + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_sequenced.cpp" target="_top">test_bimap_sequenced.cpp + </a> + </p> + </td> +<td> + <p> + Test list and vector based bimaps + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_unconstrained.cpp" target="_top">test_bimap_unconstrained.cpp + </a> + </p> + </td> +<td> + <p> + Test bimaps with unconstrained views + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_serialization.cpp" target="_top">test_bimap_serialization.cpp + </a> + </p> + </td> +<td> + <p> + Serialization support checks + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_property_map.cpp" target="_top">test_bimap_property_map.cpp + </a> + </p> + </td> +<td> + <p> + Property map concepts for the set and unordered set views + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_modify.cpp" target="_top">test_bimap_modify.cpp + </a> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">replace</span></code>, <code class="computeroutput"><span class="identifier">modify</span></code> and <code class="computeroutput"><span class="keyword">operator</span><span class="special">[]</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_lambda.cpp" target="_top">test_bimap_lambda.cpp + </a> + </p> + </td> +<td> + <p> + Test lambda modified idom support + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_assign.cpp" target="_top">test_bimap_assign.cpp + </a> + </p> + </td> +<td> + <p> + Test Boost.Assign support + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_project.cpp" target="_top">test_bimap_project.cpp + </a> + </p> + </td> +<td> + <p> + Projection of iterators support + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_operator_bracket.cpp" target="_top">test_bimap_operator_bracket.cpp + </a> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="keyword">operator</span><span class="special">[]</span></code> + and <code class="computeroutput"><span class="identifier">at</span><span class="special">()</span></code> + functions + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_info.cpp" target="_top">test_bimap_info.cpp + </a> + </p> + </td> +<td> + <p> + Information hooking support + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/test_bimap_extra.cpp" target="_top">test_bimap_extra.cpp + </a> + </p> + </td> +<td> + <p> + Additional checks + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/compile_fail/test_bimap_info_1.cpp" target="_top">test_bimap_info_1.cpp + </a> + </p> + </td> +<td> + <p> + Information hooking compilation fail test + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/compile_fail/test_bimap_info_2.cpp" target="_top">test_bimap_info_2.cpp + </a> + </p> + </td> +<td> + <p> + Information hooking compilation fail test + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/compile_fail/test_bimap_info_3.cpp" target="_top">test_bimap_info_3.cpp + </a> + </p> + </td> +<td> + <p> + Information hooking compilation fail test + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/compile_fail/test_bimap_mutable_1.cpp" target="_top">test_bimap_mutable_1.cpp + </a> + </p> + </td> +<td> + <p> + Mutable members compilation fail test + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/compile_fail/test_bimap_mutable_2.cpp" target="_top">test_bimap_mutable_2.cpp + </a> + </p> + </td> +<td> + <p> + Mutable members compilation fail test + </p> + </td> +</tr> +<tr> +<td> + <p> + <a href="../../../test/compile_fail/test_bimap_mutable_3.cpp" target="_top">test_bimap_mutable_3.cpp + </a> + </p> + </td> +<td> + <p> + Mutable members compilation fail test + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="examples/multiindex_to_bimap_path___hashed_indices.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="future_work.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/the_tutorial.html b/libs/bimap/doc/html/boost_bimap/the_tutorial.html new file mode 100644 index 0000000000..40f089bc08 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/the_tutorial.html @@ -0,0 +1,160 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>The tutorial</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="prev" href="one_minute_tutorial.html" title="One minute tutorial"> +<link rel="next" href="the_tutorial/discovering_the_bimap_framework.html" title="Discovering the bimap framework"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> +<td align="center"><a href="../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="one_minute_tutorial.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="the_tutorial/discovering_the_bimap_framework.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="boost_bimap.the_tutorial"></a><a class="link" href="the_tutorial.html" title="The tutorial">The tutorial</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="the_tutorial.html#boost_bimap.the_tutorial.roadmap">Roadmap</a></span></dt> +<dt><span class="section"><a href="the_tutorial/discovering_the_bimap_framework.html">Discovering + the bimap framework</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="the_tutorial/discovering_the_bimap_framework.html#boost_bimap.the_tutorial.discovering_the_bimap_framework.interpreting_bidirectional_maps">Interpreting + bidirectional maps</a></span></dt> +<dt><span class="section"><a href="the_tutorial/discovering_the_bimap_framework.html#boost_bimap.the_tutorial.discovering_the_bimap_framework.standard_mapping_framework">Standard + mapping framework</a></span></dt> +<dt><span class="section"><a href="the_tutorial/discovering_the_bimap_framework.html#boost_bimap.the_tutorial.discovering_the_bimap_framework.bimap_mapping_framework">Bimap + mapping framework</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="the_tutorial/controlling_collection_types.html">Controlling + collection types</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="the_tutorial/controlling_collection_types.html#boost_bimap.the_tutorial.controlling_collection_types.freedom_of_choice">Freedom + of choice</a></span></dt> +<dt><span class="section"><a href="the_tutorial/controlling_collection_types.html#boost_bimap.the_tutorial.controlling_collection_types.configuration_parameters">Configuration + parameters</a></span></dt> +<dt><span class="section"><a href="the_tutorial/controlling_collection_types.html#boost_bimap.the_tutorial.controlling_collection_types.examples">Examples</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="the_tutorial/the_collection_of_relations_type.html">The + collection of relations type</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="the_tutorial/the_collection_of_relations_type.html#boost_bimap.the_tutorial.the_collection_of_relations_type.a_new_point_of_view">A + new point of view</a></span></dt> +<dt><span class="section"><a href="the_tutorial/the_collection_of_relations_type.html#boost_bimap.the_tutorial.the_collection_of_relations_type.configuration_parameters">Configuration + parameters</a></span></dt> +<dt><span class="section"><a href="the_tutorial/the_collection_of_relations_type.html#boost_bimap.the_tutorial.the_collection_of_relations_type.examples">Examples</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="the_tutorial/differences_with_standard_maps.html">Differences + with standard maps</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="the_tutorial/differences_with_standard_maps.html#boost_bimap.the_tutorial.differences_with_standard_maps.insertion">Insertion</a></span></dt> +<dt><span class="section"><a href="the_tutorial/differences_with_standard_maps.html#boost_bimap.the_tutorial.differences_with_standard_maps.iterator__value_type">iterator::value_type</a></span></dt> +<dt><span class="section"><a href="the_tutorial/differences_with_standard_maps.html#boost_bimap.the_tutorial.differences_with_standard_maps.operator_____and_at__">operator[] + and at()</a></span></dt> +<dt><span class="section"><a href="the_tutorial/differences_with_standard_maps.html#boost_bimap.the_tutorial.differences_with_standard_maps.complexity_of_operations">Complexity + of operations</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="the_tutorial/useful_functions.html">Useful functions</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="the_tutorial/useful_functions.html#boost_bimap.the_tutorial.useful_functions.projection_of_iterators">Projection + of iterators</a></span></dt> +<dt><span class="section"><a href="the_tutorial/useful_functions.html#boost_bimap.the_tutorial.useful_functions.replace_and_modify">replace + and modify</a></span></dt> +<dt><span class="section"><a href="the_tutorial/useful_functions.html#boost_bimap.the_tutorial.useful_functions.retrieval_of_ranges">Retrieval + of ranges</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="the_tutorial/bimaps_with_user_defined_names.html">Bimaps + with user defined names</a></span></dt> +<dt><span class="section"><a href="the_tutorial/unconstrained_sets.html">Unconstrained + Sets</a></span></dt> +<dt><span class="section"><a href="the_tutorial/additional_information.html">Additional + information</a></span></dt> +<dt><span class="section"><a href="the_tutorial/complete_instantiation_scheme.html">Complete + instantiation scheme</a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.the_tutorial.roadmap"></a><a class="link" href="the_tutorial.html#boost_bimap.the_tutorial.roadmap" title="Roadmap">Roadmap</a> +</h3></div></div></div> +<div class="orderedlist"><ol class="orderedlist" type="1"> +<li class="listitem"> + Boost.Bimap is intuitive because it is based on the standard template + library. New concepts are however presented to extend the standard maps + to bidirectional maps. The first step is to gain a firm grasp of the + bimap framework. The first section (<a class="link" href="the_tutorial/discovering_the_bimap_framework.html" title="Discovering the bimap framework">Discovering + the bimap framework</a>) aims to explain this. + </li> +<li class="listitem"> + Boost.Bimap offers much more than just a one-to-one ordered unique bidirectional + map. It is possible to control the collection type of each side of the + relationship that the bimap represents, giving one-to-many containers, + hashed bidirectional containers and others that may be more suitable + to the the task at hand. The second section (<a class="link" href="the_tutorial/controlling_collection_types.html" title="Controlling collection types">Controlling + collection types</a>) explains how to instantiate a bimap with different + collection constraints. + </li> +<li class="listitem"> + The section (<a class="link" href="the_tutorial/the_collection_of_relations_type.html" title="The collection of relations type">The + "collection of relations" type</a>) explains how to create + new types of bidirectional maps using custom collection types. + </li> +<li class="listitem"> + In the section <a class="link" href="the_tutorial/differences_with_standard_maps.html" title="Differences with standard maps">Differences + with standard maps</a> we will learn about the subtle differences + between a bimap map view and a standard map. + </li> +<li class="listitem"> + The section <a class="link" href="the_tutorial/useful_functions.html" title="Useful functions">Useful + functions</a> provides information about functions of a bimap that + are not found in the STL. + </li> +<li class="listitem"> + The types of a bimap can be tagged so that each side is accessible by + something closer to the problem than left and right. This leads to more + readable, self-documenting code. The fourth section (<a class="link" href="the_tutorial/bimaps_with_user_defined_names.html" title="Bimaps with user defined names">Bimaps + with user defined names</a>) shows how to use this feature. + </li> +<li class="listitem"> + The bimap mapping framework allows to disable a view of a bimap, including + the standard mapping containers as a particular case. The section <a class="link" href="the_tutorial/unconstrained_sets.html" title="Unconstrained Sets">Unconstrained Sets</a> + explains how they work. + </li> +<li class="listitem"> + The section <a class="link" href="the_tutorial/additional_information.html" title="Additional information">Additional + information</a> explains how to attach information to each relation + of a bimap. + </li> +<li class="listitem"> + The final section (<a class="link" href="the_tutorial/complete_instantiation_scheme.html" title="Complete instantiation scheme">Complete + Instantiation Scheme</a>) summarizes bimap instantiation and explains + how change the allocator type to be used. + </li> +</ol></div> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="one_minute_tutorial.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="the_tutorial/discovering_the_bimap_framework.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/the_tutorial/additional_information.html b/libs/bimap/doc/html/boost_bimap/the_tutorial/additional_information.html new file mode 100644 index 0000000000..cbe33ef06c --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/the_tutorial/additional_information.html @@ -0,0 +1,220 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Additional information</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../the_tutorial.html" title="The tutorial"> +<link rel="prev" href="unconstrained_sets.html" title="Unconstrained Sets"> +<link rel="next" href="complete_instantiation_scheme.html" title="Complete instantiation scheme"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="unconstrained_sets.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="complete_instantiation_scheme.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.the_tutorial.additional_information"></a><a class="link" href="additional_information.html" title="Additional information">Additional + information</a> +</h3></div></div></div> +<p> + Bidirectional maps may have associated information about each relation. Suppose + we want to represent a books and author bidirectional map. + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> + + <span class="identifier">multiset_of</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">>,</span> <span class="comment">// author +</span> <span class="identifier">set_of</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">></span> <span class="comment">// title +</span> +<span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">book</span><span class="special">;</span> + +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">book</span><span class="special">(</span> <span class="string">"Bjarne Stroustrup"</span> <span class="special">,</span> <span class="string">"The C++ Programming Language"</span> <span class="special">)</span> <span class="special">);</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">book</span><span class="special">(</span> <span class="string">"Scott Meyers"</span> <span class="special">,</span> <span class="string">"Effective C++"</span> <span class="special">)</span> <span class="special">);</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">book</span><span class="special">(</span> <span class="string">"Andrei Alexandrescu"</span> <span class="special">,</span> <span class="string">"Modern C++ Design"</span> <span class="special">)</span> <span class="special">);</span> + +<span class="comment">// Print the author of Modern C++ +</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">at</span><span class="special">(</span> <span class="string">"Modern C++ Design"</span> <span class="special">);</span> +</pre> +<p> + </p> +<p> + Suppose now that we want to store abstract of each book. We have two options: + </p> +<div class="orderedlist"><ol class="orderedlist" type="1"> +<li class="listitem"> + Books name are unique identifiers, so we can create a separate <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span> <span class="identifier">string</span><span class="special">,</span> <span class="identifier">string</span> <span class="special">></span></code> + that relates books names with abstracts. + </li> +<li class="listitem"> + We can use <a href="http://www.boost.org/libs/multi_index/doc/index.html" target="_top"><span class="bold"><strong>Boost.MultiIndex</strong></span></a> for the new beast. + </li> +</ol></div> +<p> + Option 1 is the wrong approach, if we go this path we lost what bimap has + won us. We now have to maintain the logic of two interdependent containers, + there is an extra string stored for each book name, and the performance will + be worse. This is far away from being a good solution. + </p> +<p> + Option 2 is correct. We start thinking books as entries in a table. So it + makes sense to start using Boost.MultiIndex. We can then add the year of + publication, the price, etc... and we can index this new items too. So Boost.MultiIndex + is a sound solution for our problem. + </p> +<p> + The thing is that there are cases where we want to maintain bimap semantics + (use <code class="computeroutput"><span class="identifier">at</span><span class="special">()</span></code> + to find an author given a book name and the other way around) and add information + about the relations that we are sure we will not want to index later (like + the abstracts). Option 1 is not possible, option 2 neither. + </p> +<p> + Boost.Bimap provides support for this kind of situations by means of an embedded + information member. You can pass an extra parameter to a bimap: <code class="computeroutput"><span class="identifier">with_info</span><span class="special"><</span> + <span class="identifier">InfoType</span> <span class="special">></span></code> + and an <code class="computeroutput"><span class="identifier">info</span></code> member of type + <code class="computeroutput"><span class="identifier">InfoType</span></code> will appear in the + relation and bimap pairs. + </p> +<p> + <span class="inlinemediaobject"><img src="../../images/bimap/relation.and.pair.with.info.png" alt="relation.and.pair.with.info"></span> + </p> +<p> + Relations and bimap pairs constructors will take an extra argument. If only + two arguments are used, the information will be initialized with their default + constructor. + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> + + <span class="identifier">multiset_of</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">>,</span> <span class="comment">// author +</span> <span class="identifier">set_of</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">>,</span> <span class="comment">// title +</span> + <span class="identifier">with_info</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">></span> <span class="comment">// abstract +</span> +<span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">book</span><span class="special">;</span> + +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> + + <span class="identifier">book</span><span class="special">(</span> <span class="string">"Bjarne Stroustrup"</span> <span class="special">,</span> <span class="string">"The C++ Programming Language"</span><span class="special">,</span> + + <span class="string">"For C++ old-timers, the first edition of this book is"</span> + <span class="string">"the one that started it all—the font of our knowledge."</span> <span class="special">)</span> +<span class="special">);</span> + + +<span class="comment">// Print the author of the bible +</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">at</span><span class="special">(</span><span class="string">"The C++ Programming Language"</span><span class="special">);</span> + +<span class="comment">// Print the abstract of this book +</span><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_iterator</span> <span class="identifier">i</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="string">"Bjarne Stroustrup"</span><span class="special">);</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">info</span><span class="special">;</span> +</pre> +<p> + </p> +<p> + Contrary to the two key types, the information will be mutable using iterators. + </p> +<p> + +</p> +<pre class="programlisting"><span class="identifier">i</span><span class="special">-></span><span class="identifier">info</span> <span class="special">+=</span> <span class="string">"More details about this book"</span><span class="special">;</span> +</pre> +<p> + </p> +<p> + A new function is included in <span class="emphasis"><em>unique</em></span> map views: <code class="computeroutput"><span class="identifier">info_at</span><span class="special">(</span><span class="identifier">key</span><span class="special">)</span></code>, that + mimics the standard <code class="computeroutput"><span class="identifier">at</span><span class="special">(</span><span class="identifier">key</span><span class="special">)</span></code> function + but returned the associated information instead of the data. + </p> +<p> + +</p> +<pre class="programlisting"><span class="comment">// Print the new abstract +</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">info_at</span><span class="special">(</span><span class="string">"The C++ Programming Language"</span><span class="special">);</span> +</pre> +<p> + </p> +<p> + The info member can be tagged just as the left or the right member. The following + is a rewrite of the above example using user defined names: + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> + + <span class="identifier">multiset_of</span><span class="special"><</span> <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">author</span> <span class="special">></span> <span class="special">>,</span> + <span class="identifier">set_of</span><span class="special"><</span> <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">title</span> <span class="special">></span> <span class="special">>,</span> + + <span class="identifier">with_info</span><span class="special"><</span> <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">abstract</span> <span class="special">></span> <span class="special">></span> + +<span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">book</span><span class="special">;</span> + +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> + + <span class="identifier">book</span><span class="special">(</span> <span class="string">"Bjarne Stroustrup"</span> <span class="special">,</span> <span class="string">"The C++ Programming Language"</span><span class="special">,</span> + + <span class="string">"For C++ old-timers, the first edition of this book is"</span> + <span class="string">"the one that started it all—the font of our knowledge."</span> <span class="special">)</span> +<span class="special">);</span> + +<span class="comment">// Print the author of the bible +</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">title</span><span class="special">>().</span><span class="identifier">at</span><span class="special">(</span><span class="string">"The C++ Programming Language"</span><span class="special">);</span> + +<span class="comment">// Print the abstract of this book +</span><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">author</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">i</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">author</span><span class="special">>().</span><span class="identifier">find</span><span class="special">(</span><span class="string">"Bjarne Stroustrup"</span><span class="special">);</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">abstract</span><span class="special">>();</span> + +<span class="comment">// Contrary to the two key types, the information will be mutable +</span><span class="comment">// using iterators. +</span> +<span class="identifier">i</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">abstract</span><span class="special">>()</span> <span class="special">+=</span> <span class="string">"More details about this book"</span><span class="special">;</span> + +<span class="comment">// Print the new abstract +</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">title</span><span class="special">>().</span><span class="identifier">info_at</span><span class="special">(</span><span class="string">"The C++ Programming Language"</span><span class="special">);</span> +</pre> +<p> + </p> +<p> + <a href="../../../../example/tutorial_info_hook.cpp" target="_top">Go to source code</a> + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="unconstrained_sets.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="complete_instantiation_scheme.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/the_tutorial/bimaps_with_user_defined_names.html b/libs/bimap/doc/html/boost_bimap/the_tutorial/bimaps_with_user_defined_names.html new file mode 100644 index 0000000000..b9583b0cf9 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/the_tutorial/bimaps_with_user_defined_names.html @@ -0,0 +1,381 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Bimaps with user defined names</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../the_tutorial.html" title="The tutorial"> +<link rel="prev" href="useful_functions.html" title="Useful functions"> +<link rel="next" href="unconstrained_sets.html" title="Unconstrained Sets"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="useful_functions.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unconstrained_sets.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.the_tutorial.bimaps_with_user_defined_names"></a><a class="link" href="bimaps_with_user_defined_names.html" title="Bimaps with user defined names">Bimaps + with user defined names</a> +</h3></div></div></div> +<p> + In the following example, the library user inserted comments to guide future + programmers: + </p> +<p> + <a href="../../../../example/user_defined_names.cpp" target="_top">Go to source code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span> +<span class="special"><</span> + <span class="identifier">multiset_of</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">>,</span> + <span class="keyword">int</span> + +<span class="special">></span> <span class="identifier">People</span><span class="special">;</span> + +<span class="identifier">People</span> <span class="identifier">people</span><span class="special">;</span> + +<span class="comment">// ... +</span> +<span class="keyword">int</span> <span class="identifier">user_id</span><span class="special">;</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cin</span> <span class="special">>></span> <span class="identifier">user_id</span><span class="special">;</span> + +<span class="comment">// people.right : map<id,name> +</span> +<span class="identifier">People</span><span class="special">::</span><span class="identifier">right_const_iterator</span> <span class="identifier">id_iter</span> <span class="special">=</span> <span class="identifier">people</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">user_id</span><span class="special">);</span> +<span class="keyword">if</span><span class="special">(</span> <span class="identifier">id_iter</span> <span class="special">!=</span> <span class="identifier">people</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> +<span class="special">{</span> + <span class="comment">// first : id +</span> <span class="comment">// second : name +</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"name: "</span> <span class="special"><<</span> <span class="identifier">id_iter</span><span class="special">-></span><span class="identifier">second</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span> + <span class="special"><<</span> <span class="string">"id: "</span> <span class="special"><<</span> <span class="identifier">id_iter</span><span class="special">-></span><span class="identifier">first</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<span class="special">}</span> +<span class="keyword">else</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Unknown id, users are:"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + + <span class="comment">// people.left : map<name,id> +</span> + <span class="keyword">for</span><span class="special">(</span> <span class="identifier">People</span><span class="special">::</span><span class="identifier">left_const_iterator</span> + <span class="identifier">name_iter</span> <span class="special">=</span> <span class="identifier">people</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> + <span class="identifier">iend</span> <span class="special">=</span> <span class="identifier">people</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> + + <span class="identifier">name_iter</span> <span class="special">!=</span> <span class="identifier">iend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">name_iter</span> <span class="special">)</span> + <span class="special">{</span> + <span class="comment">// first : name +</span> <span class="comment">// second : id +</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"name: "</span> <span class="special"><<</span> <span class="identifier">name_iter</span><span class="special">-></span><span class="identifier">first</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span> + <span class="special"><<</span> <span class="string">"id: "</span> <span class="special"><<</span> <span class="identifier">name_iter</span><span class="special">-></span><span class="identifier">second</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + In Boost.Bimap there is a better way to document the code and in the meantime + helping you to write more mantainable and readable code. You can tag the + two collections of the bimap so they can be accessed by more descriptive + names. + </p> +<p> + <span class="inlinemediaobject"><img src="../../images/bimap/tagged.png" alt="tagged"></span> + </p> +<p> + A tagged type is a type that has been labelled using a tag. A tag is any + valid C++ type. In a bimap, the types are always tagged. If you do not specify + your own tag, the container uses <code class="computeroutput"><span class="identifier">member_at</span><span class="special">::</span><span class="identifier">left</span></code> + and <code class="computeroutput"><span class="identifier">member_at</span><span class="special">::</span><span class="identifier">right</span></code> to tag the left and right sides respectively. + In order to specify a custom tag, the type of each side has to be tagged. + Tagging a type is very simple: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">tagged</span><span class="special"><</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">a_tag</span> <span class="special">></span> <span class="identifier">tagged_int</span><span class="special">;</span> +</pre> +<p> + Now we can rewrite the example: + </p> +<p> + <a href="../../../../example/user_defined_names.cpp" target="_top">Go to source code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">id</span> <span class="special">{};</span> <span class="comment">// Tag for the identification number +</span><span class="keyword">struct</span> <span class="identifier">name</span> <span class="special">{};</span> <span class="comment">// Tag for the name of the person +</span> +<span class="keyword">typedef</span> <span class="identifier">bimap</span> +<span class="special"><</span> + <span class="identifier">tagged</span><span class="special"><</span> <span class="keyword">int</span> <span class="special">,</span> <span class="identifier">id</span> <span class="special">></span> <span class="special">,</span> + <span class="identifier">multiset_of</span><span class="special"><</span> <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">name</span> <span class="special">></span> <span class="special">></span> + +<span class="special">></span> <span class="identifier">People</span><span class="special">;</span> + +<span class="identifier">People</span> <span class="identifier">people</span><span class="special">;</span> + +<span class="comment">// ... +</span> +<span class="keyword">int</span> <span class="identifier">user_id</span><span class="special">;</span> +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cin</span> <span class="special">>></span> <span class="identifier">user_id</span><span class="special">;</span> + +<span class="identifier">People</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">id</span><span class="special">>::</span><span class="identifier">const_iterator</span> <span class="identifier">id_iter</span> <span class="special">=</span> <span class="identifier">people</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">id</span><span class="special">>().</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">user_id</span><span class="special">);</span> +<span class="keyword">if</span><span class="special">(</span> <span class="identifier">id_iter</span> <span class="special">!=</span> <span class="identifier">people</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">id</span><span class="special">>().</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"name: "</span> <span class="special"><<</span> <span class="identifier">id_iter</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">name</span><span class="special">>()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span> + <span class="special"><<</span> <span class="string">"id: "</span> <span class="special"><<</span> <span class="identifier">id_iter</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">id</span><span class="special">>()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<span class="special">}</span> +<span class="keyword">else</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Unknown id, users are:"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + + <span class="keyword">for</span><span class="special">(</span> <span class="identifier">People</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">name</span><span class="special">>::</span><span class="identifier">const_iterator</span> + <span class="identifier">name_iter</span> <span class="special">=</span> <span class="identifier">people</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">name</span><span class="special">>().</span><span class="identifier">begin</span><span class="special">(),</span> + <span class="identifier">iend</span> <span class="special">=</span> <span class="identifier">people</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">name</span><span class="special">>().</span><span class="identifier">end</span><span class="special">();</span> + + <span class="identifier">name_iter</span> <span class="special">!=</span> <span class="identifier">iend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">name_iter</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"name: "</span> <span class="special"><<</span> <span class="identifier">name_iter</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">name</span><span class="special">>()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span> + <span class="special"><<</span> <span class="string">"id: "</span> <span class="special"><<</span> <span class="identifier">name_iter</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">id</span><span class="special">>()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + Here is a list of common structures in both tagged and untagged versions. + Remember that when the bimap has user defined tags you can still use the + untagged version structures. + </p> +<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">Left</span> <span class="special">{};</span> +<span class="keyword">struct</span> <span class="identifier">Right</span> <span class="special">{};</span> +<span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> + <span class="identifier">multiset_of</span><span class="special"><</span> <span class="identifier">tagged</span><span class="special"><</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">Left</span> <span class="special">></span> <span class="special">>,</span> + <span class="identifier">unordered_set_of</span><span class="special"><</span> <span class="identifier">tagged</span><span class="special"><</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">Right</span> <span class="special">></span> <span class="special">></span> +<span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> + +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> + +<span class="comment">//... +</span> +<span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">iter</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> +<span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_iterator</span> <span class="identifier">left_iter</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> +<span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">right_iterator</span> <span class="identifier">right_iter</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> +</pre> +<div class="table"> +<a name="id792238"></a><p class="title"><b>Table 1.3. Equivalence of expresions using user defined names</b></p> +<div class="table-contents"><table class="table" summary="Equivalence of expresions using user defined names"> +<colgroup> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Untagged version + </p> + </th> +<th> + <p> + Tagged version + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">Left</span><span class="special">>()</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">Right</span><span class="special">>()</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_map</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Left</span><span class="special">>::</span><span class="identifier">type</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">right_value_type</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Right</span><span class="special">>::</span><span class="identifier">value_type</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_iterator</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Left</span><span class="special">>::</span><span class="identifier">iterator</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">right_const_iterator</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">Right</span><span class="special">>::</span><span class="identifier">const_iterator</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">iter</span><span class="special">-></span><span class="identifier">left</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">iter</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">Left</span><span class="special">>()</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">iter</span><span class="special">-></span><span class="identifier">right</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">iter</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">Right</span><span class="special">>()</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">left_iter</span><span class="special">-></span><span class="identifier">first</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">left_iter</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">Left</span><span class="special">>()</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">left_iter</span><span class="special">-></span><span class="identifier">second</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">left_iter</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">Right</span><span class="special">>()</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">right_iter</span><span class="special">-></span><span class="identifier">first</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">right_iter</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">Right</span><span class="special">>()</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">right_iter</span><span class="special">-></span><span class="identifier">second</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">right_iter</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">Left</span><span class="special">>()</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">project_left</span><span class="special">(</span><span class="identifier">iter</span><span class="special">)</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">project</span><span class="special"><</span><span class="identifier">Left</span><span class="special">>(</span><span class="identifier">iter</span><span class="special">)</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">project_right</span><span class="special">(</span><span class="identifier">iter</span><span class="special">)</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">project</span><span class="special"><</span><span class="identifier">Right</span><span class="special">>(</span><span class="identifier">iter</span><span class="special">)</span></code> + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="useful_functions.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unconstrained_sets.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/the_tutorial/complete_instantiation_scheme.html b/libs/bimap/doc/html/boost_bimap/the_tutorial/complete_instantiation_scheme.html new file mode 100644 index 0000000000..5c13a74ad0 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/the_tutorial/complete_instantiation_scheme.html @@ -0,0 +1,240 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Complete instantiation scheme</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../the_tutorial.html" title="The tutorial"> +<link rel="prev" href="additional_information.html" title="Additional information"> +<link rel="next" href="../bimap_and_boost.html" title="Bimap and Boost"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="additional_information.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../bimap_and_boost.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.the_tutorial.complete_instantiation_scheme"></a><a class="link" href="complete_instantiation_scheme.html" title="Complete instantiation scheme">Complete + instantiation scheme</a> +</h3></div></div></div> +<p> + To summarize, this is the complete instantiation scheme. + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span> +<span class="special"><</span> + <span class="identifier">LeftCollectionType</span><span class="special">,</span> <span class="identifier">RightCollectionType</span> + + <span class="special">[</span> <span class="special">,</span> <span class="identifier">SetTypeOfRelation</span> <span class="special">]</span> <span class="comment">// Default to left_based +</span> <span class="special">[</span> <span class="special">,</span> <span class="identifier">with_info</span><span class="special"><</span> <span class="identifier">Info</span> <span class="special">></span> <span class="special">]</span> <span class="comment">// Default to no info +</span> <span class="special">[</span> <span class="special">,</span> <span class="identifier">Allocator</span> <span class="special">]</span> <span class="comment">// Default to std::allocator<> +</span> +<span class="special">></span> <span class="identifier">bm</span><span class="special">;</span> +</pre> +<p> + <code class="computeroutput"><span class="special">{</span><span class="identifier">Side</span><span class="special">}</span><span class="identifier">CollectionType</span></code> + can directly be a type. This defaults to <code class="computeroutput"><span class="identifier">set_of</span><span class="special"><</span><span class="identifier">Type</span><span class="special">></span></code>, or can be a <code class="computeroutput"><span class="special">{</span><span class="identifier">CollectionType</span><span class="special">}</span><span class="identifier">_of</span><span class="special"><</span><span class="identifier">Type</span><span class="special">></span></code> + specification. Additionally, the type of this two parameters can be tagged + to specify user defined names instead of the usual <code class="computeroutput"><span class="identifier">member_at</span><span class="special">::-</span><span class="identifier">Side</span><span class="special">-</span></code> tags. + </p> +<p> + The possibles way to use the first parameter are: + </p> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">Type</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">></span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Left type: <code class="computeroutput"><span class="identifier">Type</span></code> + </li> +<li class="listitem"> + Left collection type: <code class="computeroutput"><span class="identifier">set_of</span><span class="special"><</span> <span class="identifier">Type</span> + <span class="special">></span></code> + </li> +<li class="listitem"> + Left tag: <code class="computeroutput"><span class="identifier">member_at</span><span class="special">::</span><span class="identifier">left</span></code> + </li> +</ul></div> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span> <span class="special">{</span><span class="identifier">CollectionType</span><span class="special">}</span><span class="identifier">_of</span><span class="special"><</span> <span class="identifier">Type</span> <span class="special">>,</span> <span class="identifier">R</span> <span class="special">></span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Left type: <code class="computeroutput"><span class="identifier">Type</span></code> + </li> +<li class="listitem"> + Left collection type: <code class="computeroutput"><span class="special">{</span><span class="identifier">CollectionType</span><span class="special">}</span><span class="identifier">_of</span><span class="special"><</span> <span class="identifier">LeftType</span> <span class="special">></span></code> + </li> +<li class="listitem"> + Left tag: <code class="computeroutput"><span class="identifier">member_at</span><span class="special">::</span><span class="identifier">left</span></code> + </li> +</ul></div> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">Type</span><span class="special">,</span> <span class="identifier">Tag</span> <span class="special">>,</span> <span class="identifier">R</span> <span class="special">></span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Left type: <code class="computeroutput"><span class="identifier">Type</span></code> + </li> +<li class="listitem"> + Left collection type: <code class="computeroutput"><span class="identifier">set_of</span><span class="special"><</span> <span class="identifier">LeftType</span> + <span class="special">></span></code> + </li> +<li class="listitem"> + Left tag: <code class="computeroutput"><span class="identifier">Tag</span></code> + </li> +</ul></div> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span> <span class="special">{</span><span class="identifier">CollectionType</span><span class="special">}</span><span class="identifier">_of</span><span class="special"><</span> <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">Type</span><span class="special">,</span> <span class="identifier">Tag</span> <span class="special">></span> <span class="special">>,</span> <span class="identifier">R</span> <span class="special">></span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Left type: <code class="computeroutput"><span class="identifier">Type</span></code> + </li> +<li class="listitem"> + Left collection type: <code class="computeroutput"><span class="special">{</span><span class="identifier">CollectionType</span><span class="special">}</span><span class="identifier">_of</span><span class="special"><</span> <span class="identifier">LeftType</span> <span class="special">></span></code> + </li> +<li class="listitem"> + Left tag: <code class="computeroutput"><span class="identifier">Tag</span></code> + </li> +</ul></div> +<p> + The same options are available for the second parameter. + </p> +<p> + The last three parameters are used to specify the collection type of the + relation, the information member and the allocator type. + </p> +<p> + If you want to specify a custom allocator type while relying on the default + value of CollectionTypeOfRelation, you can do so by simply writing <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span><span class="identifier">LeftKeyType</span><span class="special">,</span> + <span class="identifier">RightKeyType</span><span class="special">,</span> + <span class="identifier">Allocator</span><span class="special">></span></code>. + Boost.Bimap's internal machinery detects that the third parameter in this + case does not refer to the relation type but rather to an allocator. + </p> +<p> + The following are the possible ways of instantiating the last three parameters + of a bimap. You can ignore some of the parameter but the order must be respected. + </p> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">></span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + set_of_relation_type: based on the left key type + </li> +<li class="listitem"> + info: no info + </li> +<li class="listitem"> + allocator: std::allocator + </li> +</ul></div> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">,</span><span class="identifier">SetOfRelationType</span><span class="special">></span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + set_of_relation_type: SetOfRelationType + </li> +<li class="listitem"> + info: no info + </li> +<li class="listitem"> + allocator: std::allocator + </li> +</ul></div> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">,</span> <span class="identifier">SetOfRelationType</span><span class="special">,</span> <span class="identifier">with_info</span><span class="special"><</span><span class="identifier">Info</span><span class="special">></span> <span class="special">></span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + set_of_relation_type: SetOfRelationType + </li> +<li class="listitem"> + info: Info + </li> +<li class="listitem"> + allocator: std::allocator + </li> +</ul></div> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">,</span> <span class="identifier">SetOfRelationType</span><span class="special">,</span> <span class="identifier">with_info</span><span class="special"><</span><span class="identifier">Info</span><span class="special">>,</span> <span class="identifier">Allocator</span><span class="special">></span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + set_of_relation_type: SetOfRelationType + </li> +<li class="listitem"> + info: Info + </li> +<li class="listitem"> + allocator: Allocator + </li> +</ul></div> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">,</span> <span class="identifier">SetOfRelationType</span><span class="special">,</span> <span class="identifier">Allocator</span><span class="special">></span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + set_of_relation_type: SetOfRelationType + </li> +<li class="listitem"> + info: no info + </li> +<li class="listitem"> + allocator: Allocator + </li> +</ul></div> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">,</span> <span class="identifier">with_info</span><span class="special"><</span><span class="identifier">Info</span><span class="special">></span> <span class="special">></span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + set_of_relation_type: based on the left key type + </li> +<li class="listitem"> + info: Info + </li> +<li class="listitem"> + allocator: std::allocator + </li> +</ul></div> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">,</span> <span class="identifier">with_info</span><span class="special"><</span><span class="identifier">Info</span><span class="special">>,</span> <span class="identifier">Allocator</span><span class="special">></span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + set_of_relation_type: based on the left key type + </li> +<li class="listitem"> + allocator: Allocator + </li> +</ul></div> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">,</span> <span class="identifier">Allocator</span><span class="special">></span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + set_of_relation_type: based on the left key type + </li> +<li class="listitem"> + info: no info + </li> +<li class="listitem"> + allocator: Allocator + </li> +</ul></div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="additional_information.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../bimap_and_boost.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/the_tutorial/controlling_collection_types.html b/libs/bimap/doc/html/boost_bimap/the_tutorial/controlling_collection_types.html new file mode 100644 index 0000000000..83056573d0 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/the_tutorial/controlling_collection_types.html @@ -0,0 +1,540 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Controlling collection types</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../the_tutorial.html" title="The tutorial"> +<link rel="prev" href="discovering_the_bimap_framework.html" title="Discovering the bimap framework"> +<link rel="next" href="the_collection_of_relations_type.html" title="The collection of relations type"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="discovering_the_bimap_framework.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="the_collection_of_relations_type.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.the_tutorial.controlling_collection_types"></a><a class="link" href="controlling_collection_types.html" title="Controlling collection types">Controlling + collection types</a> +</h3></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="controlling_collection_types.html#boost_bimap.the_tutorial.controlling_collection_types.freedom_of_choice">Freedom + of choice</a></span></dt> +<dt><span class="section"><a href="controlling_collection_types.html#boost_bimap.the_tutorial.controlling_collection_types.configuration_parameters">Configuration + parameters</a></span></dt> +<dt><span class="section"><a href="controlling_collection_types.html#boost_bimap.the_tutorial.controlling_collection_types.examples">Examples</a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.controlling_collection_types.freedom_of_choice"></a><a class="link" href="controlling_collection_types.html#boost_bimap.the_tutorial.controlling_collection_types.freedom_of_choice" title="Freedom of choice">Freedom + of choice</a> +</h4></div></div></div> +<p> + As has already been said, in STL maps, you can only control the constraints + from one of the collections, namely the one that you are viewing. In Boost.Bimap, + you can control both and it is as easy as using the STL. + </p> +<p> + <span class="inlinemediaobject"><img src="../../images/bimap/extended.mapping.framework.png" alt="extended.mapping.framework"></span> + </p> +<p> + The idea is to use the same constraint names that are used in the standard. + If you don't specify the collection type, Boost.Bimap assumes that the + collection is a set. The instantiation of a bimap with custom collection + types looks like this: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="bold"><strong>CollectionType</strong></span><span class="identifier">_of</span><span class="special"><</span><span class="identifier">A</span><span class="special">>,</span> <span class="bold"><strong>CollectionType</strong></span><span class="identifier">_of</span><span class="special"><</span><span class="identifier">B</span><span class="special">></span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +</pre> +<p> + The following is the list of all supported collection types. + </p> +<div class="table"> +<a name="id776404"></a><p class="title"><b>Table 1.2. Collection of Key Types</b></p> +<div class="table-contents"><table class="table" summary="Collection of Key Types"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + name + </p> + </th> +<th> + <p> + Features + </p> + </th> +<th> + <p> + map view type + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">set_of</span></code> + </p> + </td> +<td> + <p> + <span class="emphasis"><em>ordered, unique</em></span> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">map</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">multiset_of</span></code> + </p> + </td> +<td> + <p> + <span class="emphasis"><em>ordered </em></span> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">multimap</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_set_of</span></code> + </p> + </td> +<td> + <p> + <span class="emphasis"><em>hashed, unique </em></span> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_map</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_multiset_of</span></code> + </p> + </td> +<td> + <p> + <span class="emphasis"><em>hashed </em></span> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_multimap</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">list_of</span></code> + </p> + </td> +<td> + <p> + <span class="emphasis"><em>sequenced </em></span> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">list_map</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">vector_of</span></code> + </p> + </td> +<td> + <p> + <span class="emphasis"><em>random access </em></span> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">vector_map</span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">unconstrained_set_of</span></code> + </p> + </td> +<td> + <p> + <span class="emphasis"><em>unconstrained </em></span> + </p> + </td> +<td> + <p> + <span class="emphasis"><em>can not be viewed</em></span> + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><p> + <code class="computeroutput"><span class="identifier">list_of</span></code> and <code class="computeroutput"><span class="identifier">vector_of</span></code> map views are not associated + with any existing STL associative containers. They are two examples of + unsorted associative containers. <code class="computeroutput"><span class="identifier">unconstrained_set_of</span></code> + allow the user to ignore a view. This will be explained later. + </p> +<p> + <span class="inlinemediaobject"><img src="../../images/bimap/bimap.structures.png" alt="bimap.structures"></span> + </p> +<p> + The selection of the collection type affects the possible operations that + you can perform with each side of the bimap and the time it takes to do + each. If we have: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="bold"><strong>CollectionType</strong></span><span class="identifier">_of</span><span class="special"><</span><span class="identifier">A</span><span class="special">>,</span> <span class="bold"><strong>CollectionType</strong></span><span class="identifier">_of</span><span class="special"><</span><span class="identifier">B</span><span class="special">></span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> +</pre> +<p> + The following now describes the resulting map views of the bidirectional + map. + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span></code> is signature-compatible with + <span class="bold"><strong>LeftMapType</strong></span><code class="computeroutput"><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span></code> is signature-compatible with + <span class="bold"><strong>RightMapType</strong></span><code class="computeroutput"><span class="special"><</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">A</span><span class="special">></span></code> + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.controlling_collection_types.configuration_parameters"></a><a class="link" href="controlling_collection_types.html#boost_bimap.the_tutorial.controlling_collection_types.configuration_parameters" title="Configuration parameters">Configuration + parameters</a> +</h4></div></div></div> +<p> + Each collection type template has different parameters to control its behaviour. + For example, in <code class="computeroutput"><span class="identifier">set_of</span></code> + specification, you can pass a Functor type that compares two types. All + of these parameters are exactly the same as those of the standard library + container, except for the allocator type. You will learn later how to change + the allocator for a bimap. + </p> +<p> + The following table lists the meanings of each collection type's parameters. + </p> +<div class="informaltable"><table class="table"> +<colgroup> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + name + </p> + </th> +<th> + <p> + Additional Parameters + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">set_of</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span><span class="identifier">KeyComp</span><span class="special">></span></code> + </p> + <p> + <code class="computeroutput"><span class="identifier">multiset_of</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span><span class="identifier">KeyComp</span><span class="special">></span></code> + </p> + </td> +<td> + <p> + <span class="bold"><strong>KeyComp </strong></span> is a Functor that compares + two types using a less-than operator. By default, this is <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code>. + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_set_of</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span><span class="identifier">HashFunctor</span><span class="special">,</span><span class="identifier">EqualKey</span><span class="special">></span></code> + </p> + <p> + <code class="computeroutput"><span class="identifier">unordered_multiset_of</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span><span class="identifier">HashFunctor</span><span class="special">,</span><span class="identifier">EqualKey</span><span class="special">></span></code> + </p> + </td> +<td> + <p> + <span class="bold"><strong>HashFunctor </strong></span> converts a <code class="computeroutput"><span class="identifier">T</span></code> object into an <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code> value. By default it + is <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">hash</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code>. + </p> + <p> + <span class="bold"><strong>EqualKey </strong></span> is a Functor that + tests two types for equality. By default, the equality operator + is <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">equal_to</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code>. + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">list_of</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code> + </p> + </td> +<td> + <p> + No additional parameters. + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">vector_of</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code> + </p> + </td> +<td> + <p> + No additional parameters. + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">unconstrained_set_of</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code> + </p> + </td> +<td> + <p> + No additional parameters. + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.controlling_collection_types.examples"></a><a class="link" href="controlling_collection_types.html#boost_bimap.the_tutorial.controlling_collection_types.examples" title="Examples">Examples</a> +</h4></div></div></div> +<a name="boost_bimap.the_tutorial.controlling_collection_types.examples.countries_populations"></a><h6> +<a name="id777500"></a> + <a class="link" href="controlling_collection_types.html#boost_bimap.the_tutorial.controlling_collection_types.examples.countries_populations">Countries + Populations</a> + </h6> +<p> + We want to store countries populations. The requeriments are: + </p> +<div class="orderedlist"><ol class="orderedlist" type="1"> +<li class="listitem"> + Get a list of countries in decresing order of their populations. + </li> +<li class="listitem"> + Given a countrie, get their population. + </li> +</ol></div> +<p> + Lets create the appropiate bimap. + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> + + <span class="identifier">unordered_set_of</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">>,</span> + <span class="identifier">multiset_of</span><span class="special"><</span> <span class="keyword">long</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special"><</span><span class="keyword">long</span><span class="special">></span> <span class="special">></span> + +<span class="special">></span> <span class="identifier">populations_bimap</span><span class="special">;</span> +</pre> +<p> + First of all countries names are unique identifiers, while two countries + may have the same population. This is why we choose <span class="bold"><strong>multi</strong></span><code class="computeroutput"><span class="identifier">set_of</span></code> for populations. + </p> +<p> + Using a <code class="computeroutput"><span class="identifier">multiset_of</span></code> for + population allow us to iterate over the data. Since listing countries ordered + by their names is not a requisite, we can use an <code class="computeroutput"><span class="identifier">unordered_set_of</span></code> + that allows constant order look up. + </p> +<p> + And now lets use it in a complete example + </p> +<p> + <a href="../../../../example/population_bimap.cpp" target="_top">Go to source code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> + + <span class="identifier">unordered_set_of</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">>,</span> + <span class="identifier">multiset_of</span><span class="special"><</span> <span class="keyword">long</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special"><</span><span class="keyword">long</span><span class="special">></span> <span class="special">></span> + +<span class="special">></span> <span class="identifier">population_bimap</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">population_bimap</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">population</span><span class="special">;</span> + +<span class="identifier">population_bimap</span> <span class="identifier">pop</span><span class="special">;</span> +<span class="identifier">pop</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">population</span><span class="special">(</span><span class="string">"China"</span><span class="special">,</span> <span class="number">1321000000</span><span class="special">)</span> <span class="special">);</span> +<span class="identifier">pop</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">population</span><span class="special">(</span><span class="string">"India"</span><span class="special">,</span> <span class="number">1129000000</span><span class="special">)</span> <span class="special">);</span> +<span class="identifier">pop</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">population</span><span class="special">(</span><span class="string">"United States"</span><span class="special">,</span> <span class="number">301950000</span><span class="special">)</span> <span class="special">);</span> +<span class="identifier">pop</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">population</span><span class="special">(</span><span class="string">"Indonesia"</span><span class="special">,</span> <span class="number">234950000</span><span class="special">)</span> <span class="special">);</span> +<span class="identifier">pop</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">population</span><span class="special">(</span><span class="string">"Brazil"</span><span class="special">,</span> <span class="number">186500000</span><span class="special">)</span> <span class="special">);</span> +<span class="identifier">pop</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">population</span><span class="special">(</span><span class="string">"Pakistan"</span><span class="special">,</span> <span class="number">163630000</span><span class="special">)</span> <span class="special">);</span> + +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Countries by their population:"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + +<span class="comment">// First requirement +</span><a class="co" name="boost_bimap4co" href="controlling_collection_types.html#boost_bimap4"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a><span class="keyword">for</span><span class="special">(</span> <span class="identifier">population_bimap</span><span class="special">::</span><span class="identifier">right_const_iterator</span> + <span class="identifier">i</span> <span class="special">=</span> <span class="identifier">pop</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">iend</span> <span class="special">=</span> <span class="identifier">pop</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> + <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">iend</span> <span class="special">;</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">)</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">second</span> <span class="special"><<</span> <span class="string">" with "</span> <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">first</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<span class="special">}</span> + +<span class="comment">// Second requirement +</span><a class="co" name="boost_bimap5co" href="controlling_collection_types.html#boost_bimap5"><img src="../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Population of China: "</span> <span class="special"><<</span> <span class="identifier">pop</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">at</span><span class="special">(</span><span class="string">"China"</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +</pre> +<p> + </p> +<div class="calloutlist"><table border="0" summary="Callout list"> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap4"></a><a href="#boost_bimap4co"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> +<td valign="top" align="left"><p> + The right map view works like a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">multimap</span><span class="special"><</span> <span class="keyword">long</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special"><</span><span class="keyword">long</span><span class="special">></span> <span class="special">></span></code>, + We can iterate over it to print the results in the required order. + </p></td> +</tr> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap5"></a><a href="#boost_bimap5co"><img src="../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> </p></td> +<td valign="top" align="left"><p> + The left map view works like a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">unordered_map</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">long</span> <span class="special">></span></code>, given the name of the country + we can use it to search for the population in constant time + </p></td> +</tr> +</table></div> +<a name="boost_bimap.the_tutorial.controlling_collection_types.examples.repetitions_counter"></a><h6> +<a name="id778674"></a> + <a class="link" href="controlling_collection_types.html#boost_bimap.the_tutorial.controlling_collection_types.examples.repetitions_counter">Repetitions + counter</a> + </h6> +<p> + We want to count the repetitions for each word in a text and print them + in order of appearance. + </p> +<p> + <a href="../../../../example/repetitions_counter.cpp" target="_top">Go to source code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span> +<span class="special"><</span> + <span class="identifier">unordered_set_of</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">>,</span> + <span class="identifier">list_of</span><span class="special"><</span> <span class="identifier">counter</span> <span class="special">></span> <a class="co" name="boost_bimap6co" href="controlling_collection_types.html#boost_bimap6"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> + +<span class="special">></span> <span class="identifier">word_counter</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">tokenizer</span><span class="special"><</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">char_separator</span><span class="special"><</span><span class="keyword">char</span><span class="special">></span> <span class="special">></span> <span class="identifier">text_tokenizer</span><span class="special">;</span> + +<span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">text</span><span class="special">=</span> + <span class="string">"Relations between data in the STL are represented with maps."</span> + <span class="string">"A map is a directed relation, by using it you are representing "</span> + <span class="string">"a mapping. In this directed relation, the first type is related to "</span> + <span class="string">"the second type but it is not true that the inverse relationship "</span> + <span class="string">"holds. This is useful in a lot of situations, but there are some "</span> + <span class="string">"relationships that are bidirectional by nature."</span><span class="special">;</span> + +<span class="comment">// feed the text into the container +</span><span class="identifier">word_counter</span> <span class="identifier">wc</span><span class="special">;</span> +<span class="identifier">text_tokenizer</span> <span class="identifier">tok</span><span class="special">(</span><span class="identifier">text</span><span class="special">,</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">char_separator</span><span class="special"><</span><span class="keyword">char</span><span class="special">>(</span><span class="string">" \t\n.,;:!?'\"-"</span><span class="special">));</span> + +<span class="keyword">for</span><span class="special">(</span> <span class="identifier">text_tokenizer</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">tok</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">it_end</span> <span class="special">=</span> <span class="identifier">tok</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> + <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">it_end</span> <span class="special">;</span> <span class="special">++</span><span class="identifier">it</span> <span class="special">)</span> +<span class="special">{</span> + <a class="co" name="boost_bimap7co" href="controlling_collection_types.html#boost_bimap7"><img src="../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a><span class="special">++</span> <span class="identifier">wc</span><span class="special">.</span><span class="identifier">left</span><span class="special">[*</span><span class="identifier">it</span><span class="special">];</span> +<span class="special">}</span> + +<span class="comment">// list words with counters by order of appearance +</span><a class="co" name="boost_bimap8co" href="controlling_collection_types.html#boost_bimap8"><img src="../../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a><span class="keyword">for</span><span class="special">(</span> <span class="identifier">word_counter</span><span class="special">::</span><span class="identifier">right_const_iterator</span> + <span class="identifier">wit</span> <span class="special">=</span> <span class="identifier">wc</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">wit_end</span> <span class="special">=</span> <span class="identifier">wc</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> + + <span class="identifier">wit</span> <span class="special">!=</span> <span class="identifier">wit_end</span><span class="special">;</span> <span class="special">++</span><span class="identifier">wit</span> <span class="special">)</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">wit</span><span class="special">-></span><span class="identifier">second</span> <span class="special"><<</span> <span class="string">": "</span> <span class="special"><<</span> <span class="identifier">wit</span><span class="special">-></span><span class="identifier">first</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<div class="calloutlist"><table border="0" summary="Callout list"> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap6"></a><a href="#boost_bimap6co"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> +<td valign="top" align="left"><p> + <code class="computeroutput"><span class="identifier">counter</span></code> is an integer + that is initialized in zero in the constructor + </p></td> +</tr> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap7"></a><a href="#boost_bimap7co"><img src="../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> </p></td> +<td valign="top" align="left"><p> + Because the right collection type is <code class="computeroutput"><span class="identifier">list_of</span></code>, + the right data is not used a key and can be modified in the same way + as with standard maps. + </p></td> +</tr> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap8"></a><a href="#boost_bimap8co"><img src="../../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a> </p></td> +<td valign="top" align="left"><p> + When we insert the elements using the left map view, the element is + inserted at the end of the list. + </p></td> +</tr> +</table></div> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="discovering_the_bimap_framework.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="the_collection_of_relations_type.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/the_tutorial/differences_with_standard_maps.html b/libs/bimap/doc/html/boost_bimap/the_tutorial/differences_with_standard_maps.html new file mode 100644 index 0000000000..3a9538f86e --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/the_tutorial/differences_with_standard_maps.html @@ -0,0 +1,449 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Differences with standard maps</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../the_tutorial.html" title="The tutorial"> +<link rel="prev" href="the_collection_of_relations_type.html" title="The collection of relations type"> +<link rel="next" href="useful_functions.html" title="Useful functions"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="the_collection_of_relations_type.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="useful_functions.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.the_tutorial.differences_with_standard_maps"></a><a class="link" href="differences_with_standard_maps.html" title="Differences with standard maps">Differences + with standard maps</a> +</h3></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="differences_with_standard_maps.html#boost_bimap.the_tutorial.differences_with_standard_maps.insertion">Insertion</a></span></dt> +<dt><span class="section"><a href="differences_with_standard_maps.html#boost_bimap.the_tutorial.differences_with_standard_maps.iterator__value_type">iterator::value_type</a></span></dt> +<dt><span class="section"><a href="differences_with_standard_maps.html#boost_bimap.the_tutorial.differences_with_standard_maps.operator_____and_at__">operator[] + and at()</a></span></dt> +<dt><span class="section"><a href="differences_with_standard_maps.html#boost_bimap.the_tutorial.differences_with_standard_maps.complexity_of_operations">Complexity + of operations</a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.differences_with_standard_maps.insertion"></a><a class="link" href="differences_with_standard_maps.html#boost_bimap.the_tutorial.differences_with_standard_maps.insertion" title="Insertion">Insertion</a> +</h4></div></div></div> +<p> + Remember that a map can be interpreted as a relation between two collections. + In bimaps we have the freedom to change both collection types, imposing + constrains in each of them. Some insertions that we give for granted to + success in standard maps fails with bimaps. For example: + </p> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">></span> <span class="identifier">bm</span><span class="special">;</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="string">"orange"</span><span class="special">);</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="number">2</span><span class="special">,</span><span class="string">"orange"</span><span class="special">);</span> <span class="comment">// No effect! returns make_pair(iter,false) +</span></pre> +<p> + The insertion will only succeed if it is allowed by all views of the <code class="computeroutput"><span class="identifier">bimap</span></code>. In the next snippet we define + the right collection as a multiset, when we try to insert the same two + elements the second insertion is allowed by the left map view because both + values are different and it is allowed by the right map view because it + is a non-unique collection type. + </p> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">multiset_of</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">></span> <span class="special">></span> <span class="identifier">bm</span><span class="special">;</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="string">"orange"</span><span class="special">);</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="number">2</span><span class="special">,</span><span class="string">"orange"</span><span class="special">);</span> <span class="comment">// Insertion succeed! +</span></pre> +<p> + If we use a custom collection of relation type, the insertion has to be + allowed by it too. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.differences_with_standard_maps.iterator__value_type"></a><a class="link" href="differences_with_standard_maps.html#boost_bimap.the_tutorial.differences_with_standard_maps.iterator__value_type" title="iterator::value_type">iterator::value_type</a> +</h4></div></div></div> +<p> + The relations stored in the Bimap will not be in most cases modifiable + directly by iterators because both sides are used as keys of <span class="emphasis"><em>key-based</em></span> + sets. When a <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span></code> left view iterator is dereferenced + the return type is <span class="emphasis"><em>signature-compatible</em></span> with a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span> <span class="keyword">const</span> <span class="identifier">A</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">B</span> <span class="special">></span></code>. + However there are some collection types that are not <span class="emphasis"><em>key_based</em></span>, + for example list_of. If a Bimap uses one of these collection types there + is no problem with modifying the data of that side. The following code + is valid: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">list_of</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">></span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">relation</span><span class="special">(</span> <span class="number">1</span><span class="special">,</span> <span class="string">"one"</span> <span class="special">)</span> <span class="special">);</span> +<span class="special">...</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="number">1</span><span class="special">)-></span><span class="identifier">second</span> <span class="special">=</span> <span class="string">"1"</span><span class="special">;</span> <span class="comment">// Valid +</span></pre> +<p> + In this case, when the iterator is dereferenced the return type is <span class="emphasis"><em>signature-compatible</em></span> + with a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="keyword">const</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">></span></code>. + </p> +<p> + The following table shows the constness of the dereferenced data of each + collection type of: + </p> +<div class="informaltable"><table class="table"> +<colgroup> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Side collection type + </p> + </th> +<th> + <p> + Dereferenced data + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">set_of</span></code> + </p> + </td> +<td> + <p> + <span class="emphasis"><em>constant</em></span> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">multiset_of</span></code> + </p> + </td> +<td> + <p> + <span class="emphasis"><em>constant</em></span> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_set_of</span></code> + </p> + </td> +<td> + <p> + <span class="emphasis"><em>constant</em></span> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_multiset_of</span></code> + </p> + </td> +<td> + <p> + <span class="emphasis"><em>constant</em></span> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">list_of</span></code> + </p> + </td> +<td> + <p> + <span class="emphasis"><em>mutable</em></span> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">vector_of</span></code> + </p> + </td> +<td> + <p> + <span class="emphasis"><em>mutable</em></span> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">unconstrained_set_of</span></code> + </p> + </td> +<td> + <p> + <span class="emphasis"><em>mutable</em></span> + </p> + </td> +</tr> +</tbody> +</table></div> +<p> + Here are some examples. When dereferenced the iterators returns a type + that is <span class="emphasis"><em>signature-compatible</em></span> with these types. + </p> +<div class="informaltable"><table class="table"> +<colgroup> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Bimap type + </p> + </th> +<th> + <p> + Signature-compatible types + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">iterator</span> </code> <span class="bold"><strong>-></strong></span> <code class="computeroutput"><span class="identifier">relation</span><span class="special"><</span><span class="keyword">const</span> + <span class="identifier">A</span><span class="special">,</span><span class="keyword">const</span> <span class="identifier">B</span><span class="special">></span></code> + </p> + <p> + <code class="computeroutput"><span class="identifier">left_iterator</span> </code> + <span class="bold"><strong>-></strong></span> <code class="computeroutput"><span class="identifier">pair</span><span class="special"><</span><span class="keyword">const</span> + <span class="identifier">A</span><span class="special">,</span><span class="keyword">const</span> <span class="identifier">B</span><span class="special">></span></code> + </p> + <p> + <code class="computeroutput"><span class="identifier">right_iterator</span></code> + <span class="bold"><strong>-></strong></span> <code class="computeroutput"><span class="identifier">pair</span><span class="special"><</span><span class="keyword">const</span> + <span class="identifier">B</span><span class="special">,</span><span class="keyword">const</span> <span class="identifier">A</span><span class="special">></span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span><span class="identifier">multiset_of</span><span class="special"><</span><span class="identifier">A</span><span class="special">>,</span><span class="identifier">unordered_set_of</span><span class="special"><</span><span class="identifier">B</span><span class="special">></span> + <span class="special">></span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">iterator</span> </code> <span class="bold"><strong>-></strong></span> <code class="computeroutput"><span class="identifier">relation</span><span class="special"><</span><span class="keyword">const</span> + <span class="identifier">A</span><span class="special">,</span><span class="keyword">const</span> <span class="identifier">B</span><span class="special">></span></code> + </p> + <p> + <code class="computeroutput"><span class="identifier">left_iterator</span> </code> + <span class="bold"><strong>-></strong></span> <code class="computeroutput"><span class="identifier">pair</span><span class="special"><</span><span class="keyword">const</span> + <span class="identifier">A</span><span class="special">,</span><span class="keyword">const</span> <span class="identifier">B</span><span class="special">></span></code> + </p> + <p> + <code class="computeroutput"><span class="identifier">right_iterator</span></code> + <span class="bold"><strong>-></strong></span> <code class="computeroutput"><span class="identifier">pair</span><span class="special"><</span><span class="keyword">const</span> + <span class="identifier">B</span><span class="special">,</span><span class="keyword">const</span> <span class="identifier">A</span><span class="special">></span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span><span class="identifier">set_of</span><span class="special"><</span><span class="identifier">A</span><span class="special">>,</span><span class="identifier">list_of</span><span class="special"><</span><span class="identifier">B</span><span class="special">></span> + <span class="special">></span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">iterator</span> </code> <span class="bold"><strong>-></strong></span> <code class="computeroutput"><span class="identifier">relation</span><span class="special"><</span><span class="keyword">const</span> + <span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span></code> + </p> + <p> + <code class="computeroutput"><span class="identifier">left_iterator</span> </code> + <span class="bold"><strong>-></strong></span> <code class="computeroutput"><span class="identifier">pair</span><span class="special"><</span><span class="keyword">const</span> + <span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span></code> + </p> + <p> + <code class="computeroutput"><span class="identifier">right_iterator</span></code> + <span class="bold"><strong>-></strong></span> <code class="computeroutput"><span class="identifier">pair</span><span class="special"><</span><span class="identifier">B</span><span class="special">,</span><span class="keyword">const</span> + <span class="identifier">A</span><span class="special">></span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span><span class="identifier">vector_of</span><span class="special"><</span><span class="identifier">A</span><span class="special">>,</span><span class="identifier">set_of</span><span class="special"><</span><span class="identifier">B</span><span class="special">></span> + <span class="special">></span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">iterator</span> </code> <span class="bold"><strong>-></strong></span> <code class="computeroutput"><span class="identifier">relation</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="keyword">const</span> + <span class="identifier">B</span><span class="special">></span></code> + </p> + <p> + <code class="computeroutput"><span class="identifier">left_iterator</span> </code> + <span class="bold"><strong>-></strong></span> <code class="computeroutput"><span class="identifier">pair</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="keyword">const</span> + <span class="identifier">B</span><span class="special">></span></code> + </p> + <p> + <code class="computeroutput"><span class="identifier">right_iterator</span></code> + <span class="bold"><strong>-></strong></span> <code class="computeroutput"><span class="identifier">pair</span><span class="special"><</span><span class="keyword">const</span> + <span class="identifier">B</span><span class="special">,</span><span class="identifier">A</span><span class="special">></span></code> + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span><span class="identifier">list_of</span><span class="special"><</span><span class="identifier">A</span><span class="special">>,</span><span class="identifier">unconstrained_set_of</span><span class="special"><</span><span class="identifier">B</span><span class="special">></span> + <span class="special">></span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">iterator</span> </code> <span class="bold"><strong>-></strong></span> <code class="computeroutput"><span class="identifier">relation</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span></code> + </p> + <p> + <code class="computeroutput"><span class="identifier">left_iterator</span> </code> + <span class="bold"><strong>-></strong></span> <code class="computeroutput"><span class="identifier">pair</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">></span></code> + </p> + <p> + <code class="computeroutput"><span class="identifier">right_iterator</span></code> + <span class="bold"><strong>-></strong></span> <code class="computeroutput"><span class="identifier">pair</span><span class="special"><</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">A</span><span class="special">></span></code> + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.differences_with_standard_maps.operator_____and_at__"></a><a class="link" href="differences_with_standard_maps.html#boost_bimap.the_tutorial.differences_with_standard_maps.operator_____and_at__" title="operator[] and at()">operator[] + and at()</a> +</h4></div></div></div> +<p> + <code class="computeroutput"><span class="identifier">set_of</span></code> and <code class="computeroutput"><span class="identifier">unordered_set_of</span></code> map views overload + <code class="computeroutput"><span class="keyword">operator</span><span class="special">[]</span></code> + to retrieve the associated data of a given key only when the other collection + type is a mutable one. In these cases it works in the same way as the standard. + </p> +<pre class="programlisting"><span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">unorderd_set_of</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">>,</span> <span class="identifier">list_of</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span> <span class="special">></span> <span class="identifier">bm</span><span class="special">;</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">[</span><span class="string">"one"</span><span class="special">]</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span> <span class="comment">// Ok +</span></pre> +<p> + The standard defines an access function for <code class="computeroutput"><span class="identifier">map</span></code> + and <code class="computeroutput"><span class="identifier">unordered_map</span></code>: + </p> +<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">data_type</span> <span class="special">&</span> <span class="identifier">at</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">key_type</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> + <span class="identifier">data_type</span> <span class="special">&</span> <span class="identifier">at</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">key_type</span> <span class="special">&</span> <span class="identifier">k</span><span class="special">);</span> +</pre> +<p> + These functions look for a key and returns the associated data value, but + throws a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">out_of_range</span></code> exception if the key is + not found. + </p> +<p> + In bimaps the constant version of these functions is given for <code class="computeroutput"><span class="identifier">set_of</span></code> and <code class="computeroutput"><span class="identifier">unorderd_set_of</span></code> + map views independently of the other collection type. The mutable version + is only provided when the other collection type is mutable. + </p> +<p> + The following examples shows the behaviour of <code class="computeroutput"><span class="identifier">at</span><span class="special">(</span><span class="identifier">key</span><span class="special">)</span></code> + </p> +<p> + <a href="../../../../example/at_function_examples.cpp" target="_top">Go to source code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">set_of</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">>,</span> <span class="identifier">list_of</span><span class="special"><</span> <span class="keyword">int</span> <span class="special">></span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> + +<span class="keyword">try</span> +<span class="special">{</span> + <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">at</span><span class="special">(</span><span class="string">"one"</span><span class="special">)</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span> <span class="comment">// throws std::out_of_range +</span><span class="special">}</span> +<span class="keyword">catch</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">out_of_range</span> <span class="special">&</span> <span class="identifier">e</span> <span class="special">)</span> <span class="special">{}</span> + +<span class="identifier">assert</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">empty</span><span class="special">()</span> <span class="special">);</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">[</span><span class="string">"one"</span><span class="special">]</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span> <span class="comment">// Ok +</span> +<span class="identifier">assert</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">at</span><span class="special">(</span><span class="string">"one"</span><span class="special">)</span> <span class="special">==</span> <span class="number">1</span> <span class="special">);</span> <span class="comment">// Ok +</span></pre> +<p> + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">multiset_of</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">>,</span> <span class="identifier">unordered_set_of</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">=</span> <span class="string">"one"</span><span class="special">;</span> <span class="comment">// compilation error +</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">right_value_type</span><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="string">"one"</span><span class="special">)</span> <span class="special">);</span> + +<span class="identifier">assert</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">at</span><span class="special">(</span><span class="number">1</span><span class="special">)</span> <span class="special">==</span> <span class="string">"one"</span> <span class="special">);</span> <span class="comment">// Ok +</span> +<span class="keyword">try</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">at</span><span class="special">(</span><span class="number">2</span><span class="special">);</span> <span class="comment">// throws std::out_of_range +</span><span class="special">}</span> +<span class="keyword">catch</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">out_of_range</span> <span class="special">&</span> <span class="identifier">e</span> <span class="special">)</span> <span class="special">{}</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">at</span><span class="special">(</span><span class="number">1</span><span class="special">)</span> <span class="special">=</span> <span class="string">"1"</span><span class="special">;</span> <span class="comment">// compilation error +</span> +</pre> +<p> + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.differences_with_standard_maps.complexity_of_operations"></a><a class="link" href="differences_with_standard_maps.html#boost_bimap.the_tutorial.differences_with_standard_maps.complexity_of_operations" title="Complexity of operations">Complexity + of operations</a> +</h4></div></div></div> +<p> + The complexity of some operations is different in bimaps. Read <a class="link" href="../reference/bimap_reference.html#complexity_signature_explanation">the + reference</a> to find the complexity of each function. + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="the_collection_of_relations_type.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="useful_functions.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/the_tutorial/discovering_the_bimap_framework.html b/libs/bimap/doc/html/boost_bimap/the_tutorial/discovering_the_bimap_framework.html new file mode 100644 index 0000000000..ff2efba116 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/the_tutorial/discovering_the_bimap_framework.html @@ -0,0 +1,321 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Discovering the bimap framework</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../the_tutorial.html" title="The tutorial"> +<link rel="prev" href="../the_tutorial.html" title="The tutorial"> +<link rel="next" href="controlling_collection_types.html" title="Controlling collection types"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="controlling_collection_types.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.the_tutorial.discovering_the_bimap_framework"></a><a class="link" href="discovering_the_bimap_framework.html" title="Discovering the bimap framework">Discovering + the bimap framework</a> +</h3></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="discovering_the_bimap_framework.html#boost_bimap.the_tutorial.discovering_the_bimap_framework.interpreting_bidirectional_maps">Interpreting + bidirectional maps</a></span></dt> +<dt><span class="section"><a href="discovering_the_bimap_framework.html#boost_bimap.the_tutorial.discovering_the_bimap_framework.standard_mapping_framework">Standard + mapping framework</a></span></dt> +<dt><span class="section"><a href="discovering_the_bimap_framework.html#boost_bimap.the_tutorial.discovering_the_bimap_framework.bimap_mapping_framework">Bimap + mapping framework</a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.discovering_the_bimap_framework.interpreting_bidirectional_maps"></a><a class="link" href="discovering_the_bimap_framework.html#boost_bimap.the_tutorial.discovering_the_bimap_framework.interpreting_bidirectional_maps" title="Interpreting bidirectional maps">Interpreting + bidirectional maps</a> +</h4></div></div></div> +<p> + One way to interpret bidirectional maps is as a function between two collections + of data, lets call them the left and the right collection. An element in + this bimap is a relation between an element from the left collection and + an element from the right collection. The types of both collections defines + the bimap behaviour. We can view the stored data from the left side, as + a mapping between keys from the left collection and data from the right + one, or from the right side, as a mapping between keys from the right collection + and data from the left collection. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.discovering_the_bimap_framework.standard_mapping_framework"></a><a class="link" href="discovering_the_bimap_framework.html#boost_bimap.the_tutorial.discovering_the_bimap_framework.standard_mapping_framework" title="Standard mapping framework">Standard + mapping framework</a> +</h4></div></div></div> +<p> + Relationships between data in the STL are represented by maps. A standard + map is a directed relation of keys from a left collection and data from + a right unconstrained collection. The following diagram shows the relationship + represented and the user's viewpoint. + </p> +<p> + <span class="inlinemediaobject"><img src="../../images/bimap/standard.mapping.framework.png" alt="standard.mapping.framework"></span> + </p> +<p> + The left collection type depends on the selected map type. For example + if the the map type is <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">multimap</span></code> + the collection type of X is a <code class="computeroutput"><span class="identifier">multiset_of</span></code>. + The following table shows the equivalent types for the std associative + containers. + </p> +<div class="table"> +<a name="id774525"></a><p class="title"><b>Table 1.1. std associative containers</b></p> +<div class="table-contents"><table class="table" summary="std associative containers"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + container + </p> + </th> +<th> + <p> + left collection type + </p> + </th> +<th> + <p> + right collection type + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">map</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">set_of</span></code> + </p> + </td> +<td> + <p> + no constraints + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">multimap</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">multiset_of</span></code> + </p> + </td> +<td> + <p> + no constraints + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_map</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_set_of</span></code> + </p> + </td> +<td> + <p> + no constraints + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_multimap</span></code> + </p> + </td> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_multiset_of</span></code> + </p> + </td> +<td> + <p> + no constraints + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.discovering_the_bimap_framework.bimap_mapping_framework"></a><a class="link" href="discovering_the_bimap_framework.html#boost_bimap.the_tutorial.discovering_the_bimap_framework.bimap_mapping_framework" title="Bimap mapping framework">Bimap + mapping framework</a> +</h4></div></div></div> +<p> + Boost.Bimap design is based on the STL, and extends the framework in a + natural way. The following diagram represents the new situation. + </p> +<p> + <span class="inlinemediaobject"><img src="../../images/bimap/extended.mapping.framework.png" alt="extended.mapping.framework"></span> + </p> +<p> + Notice that now the <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">maps</span></code> + are a particular case of a Boost.Bimap container, where you can view only + one side of the relationship and can control the constraints of only one + of the collections. Boost.Bimap allows the user to view the relationship + from three viewpoints. You can view it from one side, obtaining a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span></code> compatible container, or you can + work directly with the whole relation. + </p> +<p> + The next diagram shows the layout of the relation and pairs of a bimap. + It is the one from the <span class="emphasis"><em>one minute tutorial</em></span> + </p> +<p> + <span class="inlinemediaobject"><img src="../../images/bimap/relation.and.pair.png" alt="relation.and.pair"></span> + </p> +<p> + Bimap pairs are signature-compatible with standard pairs but are different + from them. As you will see in other sections they can be tagged with user + defined names and additional information can be attached to them. You can + convert from <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pairs</span></code> to bimap pairs directly but the + reverse conversion is not provided. This mean that you can insert elements + in a bimap using algorithms like <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">copy</span></code> + from containers <code class="computeroutput"><span class="identifier">like</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span></code>, + or use <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">make_pair</span></code> to add new elements. However + it is best to use <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_value_type</span><span class="special">(</span><span class="identifier">f</span><span class="special">,</span><span class="identifier">s</span><span class="special">)</span> <span class="special">)</span></code> instead + of <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">make_pair</span><span class="special">(</span><span class="identifier">f</span><span class="special">,</span><span class="identifier">s</span><span class="special">)</span> <span class="special">)</span></code> to avoid + an extra call to the copy constructor of each type. + </p> +<p> + The following code snippet shows the relation between a bimap and standard + maps. + </p> +<div class="note"><table border="0" summary="Note"> +<tr> +<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td> +<th align="left">Note</th> +</tr> +<tr><td align="left" valign="top"> +<p> + You have to used references to views, and not directly views object. + Views cannot be constructed as separate objects from the container they + belong to, so the following: +</p> +<pre class="programlisting"><span class="comment">// Wrong: we forgot the & after bm_type::left_type +</span><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_map</span> <span class="identifier">lm</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">;</span> +</pre> +<p> + does not compile, since it is trying to construct the view object <code class="computeroutput"><span class="identifier">lm</span></code>. This is a common source of errors + in user code. + </p> +</td></tr> +</table></div> +<p> + <a href="../../../../example/standard_map_comparison.cpp" target="_top">Go to source code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Map</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">CompatibleKey</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">CompatibleData</span> <span class="special">></span> +<span class="keyword">void</span> <span class="identifier">use_it</span><span class="special">(</span> <span class="identifier">Map</span> <span class="special">&</span> <span class="identifier">m</span><span class="special">,</span> + <span class="keyword">const</span> <span class="identifier">CompatibleKey</span> <span class="special">&</span> <span class="identifier">key</span><span class="special">,</span> + <span class="keyword">const</span> <span class="identifier">CompatibleData</span> <span class="special">&</span> <span class="identifier">data</span> <span class="special">)</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">Map</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">value_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">Map</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">const_iterator</span><span class="special">;</span> + + <span class="identifier">m</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">value_type</span><span class="special">(</span><span class="identifier">key</span><span class="special">,</span><span class="identifier">data</span><span class="special">)</span> <span class="special">);</span> + <span class="identifier">const_iterator</span> <span class="identifier">iter</span> <span class="special">=</span> <span class="identifier">m</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">key</span><span class="special">);</span> + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">iter</span> <span class="special">!=</span> <span class="identifier">m</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">iter</span><span class="special">-></span><span class="identifier">first</span> <span class="special">==</span> <span class="identifier">key</span> <span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">iter</span><span class="special">-></span><span class="identifier">second</span> <span class="special">==</span> <span class="identifier">data</span> <span class="special">);</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">iter</span><span class="special">-></span><span class="identifier">first</span> <span class="special"><<</span> <span class="string">" --> "</span> <span class="special"><<</span> <span class="identifier">iter</span><span class="special">-></span><span class="identifier">second</span><span class="special">;</span> + <span class="special">}</span> + <span class="identifier">m</span><span class="special">.</span><span class="identifier">erase</span><span class="special">(</span><span class="identifier">key</span><span class="special">);</span> +<span class="special">}</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">set_of</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">>,</span> <span class="identifier">set_of</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span> <span class="special">></span> <span class="identifier">bimap_type</span><span class="special">;</span> + <span class="identifier">bimap_type</span> <span class="identifier">bm</span><span class="special">;</span> + + <span class="comment">// Standard map +</span> <span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">></span> <span class="identifier">map_type</span><span class="special">;</span> + <span class="identifier">map_type</span> <span class="identifier">m</span><span class="special">;</span> + + <span class="identifier">use_it</span><span class="special">(</span> <span class="identifier">m</span><span class="special">,</span> <span class="string">"one"</span><span class="special">,</span> <span class="number">1</span> <span class="special">);</span> + <span class="special">}</span> + + <span class="comment">// Left map view +</span> <span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">bimap_type</span><span class="special">::</span><span class="identifier">left_map</span> <span class="identifier">map_type</span><span class="special">;</span> + <span class="identifier">map_type</span> <span class="special">&</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">;</span> + + <span class="identifier">use_it</span><span class="special">(</span> <span class="identifier">m</span><span class="special">,</span> <span class="string">"one"</span><span class="special">,</span> <span class="number">1</span> <span class="special">);</span> + <span class="special">}</span> + + <span class="comment">// Reverse standard map +</span> <span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">></span> <span class="identifier">reverse_map_type</span><span class="special">;</span> + <span class="identifier">reverse_map_type</span> <span class="identifier">rm</span><span class="special">;</span> + + <span class="identifier">use_it</span><span class="special">(</span> <span class="identifier">rm</span><span class="special">,</span> <span class="number">1</span><span class="special">,</span> <span class="string">"one"</span> <span class="special">);</span> + <span class="special">}</span> + + <span class="comment">// Right map view +</span> <span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">bimap_type</span><span class="special">::</span><span class="identifier">right_map</span> <span class="identifier">reverse_map_type</span><span class="special">;</span> + <span class="identifier">reverse_map_type</span> <span class="special">&</span> <span class="identifier">rm</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">;</span> + + <span class="identifier">use_it</span><span class="special">(</span> <span class="identifier">rm</span><span class="special">,</span> <span class="number">1</span><span class="special">,</span> <span class="string">"one"</span> <span class="special">);</span> + <span class="special">}</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="controlling_collection_types.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/the_tutorial/the_collection_of_relations_type.html b/libs/bimap/doc/html/boost_bimap/the_tutorial/the_collection_of_relations_type.html new file mode 100644 index 0000000000..e2f1971d39 --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/the_tutorial/the_collection_of_relations_type.html @@ -0,0 +1,408 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>The collection of relations type</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../the_tutorial.html" title="The tutorial"> +<link rel="prev" href="controlling_collection_types.html" title="Controlling collection types"> +<link rel="next" href="differences_with_standard_maps.html" title="Differences with standard maps"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="controlling_collection_types.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="differences_with_standard_maps.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.the_tutorial.the_collection_of_relations_type"></a><a class="link" href="the_collection_of_relations_type.html" title="The collection of relations type">The + collection of relations type</a> +</h3></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="the_collection_of_relations_type.html#boost_bimap.the_tutorial.the_collection_of_relations_type.a_new_point_of_view">A + new point of view</a></span></dt> +<dt><span class="section"><a href="the_collection_of_relations_type.html#boost_bimap.the_tutorial.the_collection_of_relations_type.configuration_parameters">Configuration + parameters</a></span></dt> +<dt><span class="section"><a href="the_collection_of_relations_type.html#boost_bimap.the_tutorial.the_collection_of_relations_type.examples">Examples</a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.the_collection_of_relations_type.a_new_point_of_view"></a><a class="link" href="the_collection_of_relations_type.html#boost_bimap.the_tutorial.the_collection_of_relations_type.a_new_point_of_view" title="A new point of view">A + new point of view</a> +</h4></div></div></div> +<p> + Being able to change the collection type of the bimap relation view is + another very important feature. Remember that this view allows the user + to see the container as a group of the stored relations. This view has + set semantics instead of map semantics. + </p> +<p> + <span class="inlinemediaobject"><img src="../../images/bimap/collection.type.of.relation.png" alt="collection.type.of.relation"></span> + </p> +<p> + By default, Boost.Bimap will base the collection type of the relation on + the type of the left collection. If the left collection type is a set, + then the collection type of the relation will be a set with the same order + as the left view. + </p> +<p> + In general, Boost.Bimap users will base the collection type of a relation + on the type of the collection on one of the two sides. However there are + times where it is useful to give this collection other constraints or simply + to order it differently. The user is allowed to choose between: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + left_based + </li> +<li class="listitem"> + right_based + </li> +<li class="listitem"> + set_of_relation<> + </li> +<li class="listitem"> + multiset_of_relation<> + </li> +<li class="listitem"> + unordered_set_of_relation<> + </li> +<li class="listitem"> + unordered_multiset_of_relation<> + </li> +<li class="listitem"> + list_of_relation + </li> +<li class="listitem"> + vector_of_relation + </li> +<li class="listitem"> + unconstrained_set_of_relation + </li> +</ul></div> +<div class="tip"><table border="0" summary="Tip"> +<tr> +<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../../doc/src/images/tip.png"></td> +<th align="left">Tip</th> +</tr> +<tr><td align="left" valign="top"><p> + The first two options and the last produce faster bimaps, so prefer these + where possible. + </p></td></tr> +</table></div> +<p> + <span class="inlinemediaobject"><img src="../../images/bimap/more.bimap.structures.png" alt="more.bimap.structures"></span> + </p> +<p> + The collection type of relation can be used to create powerful containers. + For example, if you need to maximize search speed, then the best bidirectional + map possible is one that relates elements from an <code class="computeroutput"><span class="identifier">unordered_set</span></code> + to another <code class="computeroutput"><span class="identifier">unordered_set</span></code>. + The problem is that this container cannot be iterated. If you need to know + the list of relations inside the container, you need another collection + type of relation. In this case, a <code class="computeroutput"><span class="identifier">list_of_relation</span></code> + is a good choice. The resulting container trades insertion and deletion + time against fast search capabilities and the possibility of bidirectional + iteration. + </p> +<p> + <a href="../../../../example/mighty_bimap.cpp" target="_top">Go to source code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">string</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">list_of</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">unordered_set_of</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">struct</span> <span class="identifier">english</span> <span class="special">{};</span> +<span class="keyword">struct</span> <span class="identifier">spanish</span> <span class="special">{};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bimaps</span><span class="special">;</span> + + <span class="keyword">typedef</span> <span class="identifier">bimap</span> + <span class="special"><</span> + <span class="identifier">unordered_set_of</span><span class="special"><</span> <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">spanish</span> <span class="special">></span> <span class="special">>,</span> + <span class="identifier">unordered_set_of</span><span class="special"><</span> <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">english</span> <span class="special">></span> <span class="special">>,</span> + <span class="identifier">list_of_relation</span> + + <span class="special">></span> <span class="identifier">translator</span><span class="special">;</span> + + <span class="identifier">translator</span> <span class="identifier">trans</span><span class="special">;</span> + + <span class="comment">// We have to use `push_back` because the collection of relations is +</span> <span class="comment">// a `list_of_relation` +</span> + <span class="identifier">trans</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span> <span class="identifier">translator</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"hola"</span> <span class="special">,</span><span class="string">"hello"</span> <span class="special">)</span> <span class="special">);</span> + <span class="identifier">trans</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span> <span class="identifier">translator</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"adios"</span> <span class="special">,</span><span class="string">"goodbye"</span> <span class="special">)</span> <span class="special">);</span> + <span class="identifier">trans</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span> <span class="identifier">translator</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"rosa"</span> <span class="special">,</span><span class="string">"rose"</span> <span class="special">)</span> <span class="special">);</span> + <span class="identifier">trans</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span> <span class="identifier">translator</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"mesa"</span> <span class="special">,</span><span class="string">"table"</span> <span class="special">)</span> <span class="special">);</span> + + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"enter a word"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">word</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">getline</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cin</span><span class="special">,</span><span class="identifier">word</span><span class="special">);</span> + + <span class="comment">// Search the queried word on the from index (Spanish) +</span> + <span class="identifier">translator</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">spanish</span><span class="special">>::</span><span class="identifier">const_iterator</span> <span class="identifier">is</span> + <span class="special">=</span> <span class="identifier">trans</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">spanish</span><span class="special">>().</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">word</span><span class="special">);</span> + + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">is</span> <span class="special">!=</span> <span class="identifier">trans</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">spanish</span><span class="special">>().</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">word</span> <span class="special"><<</span> <span class="string">" is said "</span> + <span class="special"><<</span> <span class="identifier">is</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">english</span><span class="special">>()</span> + <span class="special"><<</span> <span class="string">" in English"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + <span class="keyword">else</span> + <span class="special">{</span> + <span class="comment">// Word not found in Spanish, try our luck in English +</span> + <span class="identifier">translator</span><span class="special">::</span><span class="identifier">map_by</span><span class="special"><</span><span class="identifier">english</span><span class="special">>::</span><span class="identifier">const_iterator</span> <span class="identifier">ie</span> + <span class="special">=</span> <span class="identifier">trans</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">english</span><span class="special">>().</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">word</span><span class="special">);</span> + + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">ie</span> <span class="special">!=</span> <span class="identifier">trans</span><span class="special">.</span><span class="identifier">by</span><span class="special"><</span><span class="identifier">english</span><span class="special">>().</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">word</span> <span class="special"><<</span> <span class="string">" is said "</span> + <span class="special"><<</span> <span class="identifier">ie</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">spanish</span><span class="special">>()</span> + <span class="special"><<</span> <span class="string">" in Spanish"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + <span class="keyword">else</span> + <span class="special">{</span> + <span class="comment">// Word not found, show the possible translations +</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"No such word in the dictionary"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"These are the possible translations"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + + <span class="keyword">for</span><span class="special">(</span> <span class="identifier">translator</span><span class="special">::</span><span class="identifier">const_iterator</span> + <span class="identifier">i</span> <span class="special">=</span> <span class="identifier">trans</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> + <span class="identifier">i_end</span> <span class="special">=</span> <span class="identifier">trans</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> + + <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">i_end</span> <span class="special">;</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">spanish</span><span class="special">>()</span> + <span class="special"><<</span> <span class="string">" <---> "</span> + <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">get</span><span class="special"><</span><span class="identifier">english</span><span class="special">>()</span> + <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="special">}</span> + <span class="special">}</span> + <span class="special">}</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.the_collection_of_relations_type.configuration_parameters"></a><a class="link" href="the_collection_of_relations_type.html#boost_bimap.the_tutorial.the_collection_of_relations_type.configuration_parameters" title="Configuration parameters">Configuration + parameters</a> +</h4></div></div></div> +<p> + Each collection type of relation has different parameters to control its + behaviour. For example, in the <code class="computeroutput"><span class="identifier">set_of_relation</span></code> + specification, you can pass a Functor type that compares two types. All + of the parameters are exactly as in the standard library containers, except + for the type, which is set to the bimap relation and the allocator type. + To help users in the creation of each functor, the collection type of relation + templates takes an mpl lambda expression where the relation type will be + evaluated later. A placeholder named <code class="computeroutput"><span class="identifier">_relation</span></code> + is available to bimap users. + </p> +<p> + The following table lists the meaning of the parameters for each collection + type of relations. + </p> +<div class="informaltable"><table class="table"> +<colgroup> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + name + </p> + </th> +<th> + <p> + Additional Parameters + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">left_based</span></code> + </p> + </td> +<td> + <p> + Not a template. + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">right_based</span></code> + </p> + </td> +<td> + <p> + Not a template. + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">set_of_relation</span><span class="special"><</span><span class="identifier">KeyComp</span><span class="special">></span></code> + </p> + <p> + <code class="computeroutput"><span class="identifier">multiset_of_relation</span><span class="special"><</span><span class="identifier">KeyComp</span><span class="special">></span></code> + </p> + </td> +<td> + <p> + <span class="bold"><strong>KeyComp </strong></span> is a Functor that compares + two types using less than. By default, the less-than operator + is <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">_relation</span><span class="special">></span></code>. + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">unordered_set_of_relation</span><span class="special"><</span><span class="identifier">HashFunctor</span><span class="special">,</span><span class="identifier">EqualKey</span><span class="special">></span></code> + </p> + <p> + <code class="computeroutput"><span class="identifier">unordered_multiset_of_relation</span><span class="special"><</span><span class="identifier">HashFunctor</span><span class="special">,</span><span class="identifier">EqualKey</span><span class="special">></span></code> + </p> + </td> +<td> + <p> + <span class="bold"><strong>HashFunctor </strong></span> converts the <code class="computeroutput"><span class="identifier">relation</span></code> into an <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code> value. By default it + is <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">hash</span><span class="special"><</span><span class="identifier">_relation</span><span class="special">></span></code>. + </p> + <p> + <span class="bold"><strong>EqualKey </strong></span> is a Functor that + tests two relations for equality. By default, the equality operator + is <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">equal_to</span><span class="special"><</span><span class="identifier">_relation</span><span class="special">></span></code>. + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">list_of_relation</span></code> + </p> + </td> +<td> + <p> + Not a template. + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">vector_of_relation</span></code> + </p> + </td> +<td> + <p> + Not a template. + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">unconstrained_set_of_relation</span></code> + </p> + </td> +<td> + <p> + Not a template. + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.the_collection_of_relations_type.examples"></a><a class="link" href="the_collection_of_relations_type.html#boost_bimap.the_tutorial.the_collection_of_relations_type.examples" title="Examples">Examples</a> +</h4></div></div></div> +<p> + Consider this example: + </p> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">class</span> <span class="identifier">Rel</span> <span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">RelOrder</span> +<span class="special">{</span> + <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">Rel</span> <span class="identifier">ra</span><span class="special">,</span> <span class="identifier">Rel</span> <span class="identifier">rb</span><span class="special">)</span> <span class="keyword">const</span> + <span class="special">{</span> + <span class="keyword">return</span> <span class="special">(</span><span class="identifier">ra</span><span class="special">.</span><span class="identifier">left</span><span class="special">+</span><span class="identifier">ra</span><span class="special">.</span><span class="identifier">right</span><span class="special">)</span> <span class="special"><</span> <span class="special">(</span><span class="identifier">rb</span><span class="special">.</span><span class="identifier">left</span><span class="special">+</span><span class="identifier">rb</span><span class="special">.</span><span class="identifier">right</span><span class="special">);</span> + <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">typedef</span> <span class="identifier">bimap</span> +<span class="special"><</span> + <span class="identifier">multiset_of</span><span class="special"><</span> <span class="keyword">int</span> <span class="special">>,</span> + <span class="identifier">multiset_of</span><span class="special"><</span> <span class="keyword">int</span> <span class="special">>,</span> + <span class="identifier">set_of_relation</span><span class="special"><</span> <span class="identifier">RelOrder</span><span class="special"><</span><span class="identifier">_relation</span><span class="special">></span> <span class="special">></span> + +<span class="special">></span> <span class="identifier">bimap_type</span><span class="special">;</span> +</pre> +<p> + Here the bimap relation view is ordered using the information of both sides. + This container will only allow unique relations because <code class="computeroutput"><span class="identifier">set_of_relation</span></code> + has been used but the elements in each side of the bimap can be repeated. + </p> +<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">name</span> <span class="special">{};</span> +<span class="keyword">struct</span> <span class="identifier">phone_number</span> <span class="special">{};</span> + +<span class="keyword">typedef</span> <span class="identifier">bimap</span> +<span class="special"><</span> + <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">unordered_multiset_of</span><span class="special"><</span> <span class="identifier">string</span> <span class="special">>,</span> <span class="identifier">name</span> <span class="special">>,</span> + <span class="identifier">tagged</span><span class="special"><</span> <span class="identifier">unordered_set_of</span> <span class="special"><</span> <span class="keyword">int</span> <span class="special">>,</span> <span class="identifier">phone_number</span> <span class="special">>,</span> + <span class="identifier">set_of_relation</span><span class="special"><></span> + +<span class="special">></span> <span class="identifier">bimap_type</span><span class="special">;</span> +</pre> +<p> + In this other case the bimap will relate names to phone numbers. Names + can be repeated and phone numbers are unique. You can perform quick searches + by name or phone number and the container can be viewed ordered using the + relation view. + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="controlling_collection_types.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="differences_with_standard_maps.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/the_tutorial/unconstrained_sets.html b/libs/bimap/doc/html/boost_bimap/the_tutorial/unconstrained_sets.html new file mode 100644 index 0000000000..355561366b --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/the_tutorial/unconstrained_sets.html @@ -0,0 +1,149 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Unconstrained Sets</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../the_tutorial.html" title="The tutorial"> +<link rel="prev" href="bimaps_with_user_defined_names.html" title="Bimaps with user defined names"> +<link rel="next" href="additional_information.html" title="Additional information"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="bimaps_with_user_defined_names.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="additional_information.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.the_tutorial.unconstrained_sets"></a><a class="link" href="unconstrained_sets.html" title="Unconstrained Sets">Unconstrained + Sets</a> +</h3></div></div></div> +<p> + Unconstrained sets allow the user to disable one of the views of a bimap. + Doing so makes the bimap operations execute faster and reduces memory consumption. + This completes the bidirectional mapping framework by including unidirectional + mappings as a particular case. + </p> +<p> + Unconstrained sets are useful for the following reasons: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + A bimap type has stronger guarantees than its standard equivalent, and + includes some useful functions (replace, modify) that the standard does + not have. + </li> +<li class="listitem"> + You can view the mapping as a collection of relations. + </li> +<li class="listitem"> + Using this kind of map makes the code very extensible. If, at any moment + of the development, the need to perform searches from the right side + of the mapping arises, the only necessary change is to the <code class="computeroutput"><span class="keyword">typedef</span></code>. + </li> +</ul></div> +<p> + Given this bimap instance, + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">unconstrained_set_of</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_map</span> <span class="identifier">map_type</span><span class="special">;</span> + +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> +<span class="identifier">map_type</span> <span class="special">&</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">;</span> +</pre> +<p> + </p> +<p> + or this standard map one + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">></span> <span class="identifier">map_type</span><span class="special">;</span> + +<span class="identifier">map_type</span> <span class="identifier">m</span><span class="special">;</span> +</pre> +<p> + </p> +<p> + The following code snippet is valid + </p> +<p> + +</p> +<pre class="programlisting"><span class="identifier">m</span><span class="special">[</span><span class="string">"one"</span><span class="special">]</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span> + +<span class="identifier">assert</span><span class="special">(</span> <span class="identifier">m</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="string">"one"</span><span class="special">)</span> <span class="special">!=</span> <span class="identifier">m</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">);</span> + +<span class="keyword">for</span><span class="special">(</span> <span class="identifier">map_type</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">i</span> <span class="special">=</span> <span class="identifier">m</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">iend</span> <span class="special">=</span> <span class="identifier">m</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">iend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">)</span> +<span class="special">{</span> + <a class="co" name="boost_bimap14co" href="unconstrained_sets.html#boost_bimap14"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a><span class="special">++(</span><span class="identifier">i</span><span class="special">-></span><span class="identifier">second</span><span class="special">);</span> +<span class="special">}</span> + +<span class="identifier">m</span><span class="special">.</span><span class="identifier">erase</span><span class="special">(</span><span class="string">"one"</span><span class="special">);</span> +</pre> +<p> + </p> +<div class="calloutlist"><table border="0" summary="Callout list"><tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap14"></a><a href="#boost_bimap14co"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> +<td valign="top" align="left"><p> + The right collection of the bimap is mutable so its elements can be modified + using iterators. + </p></td> +</tr></table></div> +<p> + But using a bimap has some benefits + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">map_type</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">const_iterator</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">const_iterator</span><span class="special">,</span><span class="identifier">const_iterator</span><span class="special">></span> <span class="identifier">const_range</span><span class="special">;</span> + +<a class="co" name="boost_bimap15co" href="unconstrained_sets.html#boost_bimap15"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a><span class="identifier">const_range</span> <span class="identifier">r</span> <span class="special">=</span> <span class="identifier">m</span><span class="special">.</span><span class="identifier">range</span><span class="special">(</span> <span class="string">"one"</span> <span class="special"><=</span> <span class="identifier">_key</span><span class="special">,</span> <span class="identifier">_key</span> <span class="special"><=</span> <span class="string">"two"</span> <span class="special">);</span> +<span class="keyword">for</span><span class="special">(</span> <span class="identifier">const_iterator</span> <span class="identifier">i</span> <span class="special">=</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">first</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">second</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">)</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">first</span> <span class="special"><<</span> <span class="string">"-->"</span> <span class="special"><<</span> <span class="identifier">i</span><span class="special">-></span><span class="identifier">second</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> +<span class="special">}</span> + +<span class="identifier">m</span><span class="special">.</span><span class="identifier">modify_key</span><span class="special">(</span> <span class="identifier">m</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">_key</span> <span class="special">=</span> <span class="string">"1"</span> <span class="special">);</span> +</pre> +<p> + </p> +<div class="calloutlist"><table border="0" summary="Callout list"><tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap15"></a><a href="#boost_bimap15co"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> +<td valign="top" align="left"><p> + This range is a model of BidirectionalRange, read the docs of Boost.Range + for more information. + </p></td> +</tr></table></div> +<p> + <a href="../../../../example/unconstrained_collection.cpp" target="_top">Go to source code</a> + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="bimaps_with_user_defined_names.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="additional_information.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boost_bimap/the_tutorial/useful_functions.html b/libs/bimap/doc/html/boost_bimap/the_tutorial/useful_functions.html new file mode 100644 index 0000000000..9589eeda5f --- /dev/null +++ b/libs/bimap/doc/html/boost_bimap/the_tutorial/useful_functions.html @@ -0,0 +1,375 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Useful functions</title> +<link rel="stylesheet" href="../../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap"> +<link rel="up" href="../the_tutorial.html" title="The tutorial"> +<link rel="prev" href="differences_with_standard_maps.html" title="Differences with standard maps"> +<link rel="next" href="bimaps_with_user_defined_names.html" title="Bimaps with user defined names"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="differences_with_standard_maps.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bimaps_with_user_defined_names.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="boost_bimap.the_tutorial.useful_functions"></a><a class="link" href="useful_functions.html" title="Useful functions">Useful functions</a> +</h3></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="useful_functions.html#boost_bimap.the_tutorial.useful_functions.projection_of_iterators">Projection + of iterators</a></span></dt> +<dt><span class="section"><a href="useful_functions.html#boost_bimap.the_tutorial.useful_functions.replace_and_modify">replace + and modify</a></span></dt> +<dt><span class="section"><a href="useful_functions.html#boost_bimap.the_tutorial.useful_functions.retrieval_of_ranges">Retrieval + of ranges</a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.useful_functions.projection_of_iterators"></a><a class="link" href="useful_functions.html#boost_bimap.the_tutorial.useful_functions.projection_of_iterators" title="Projection of iterators">Projection + of iterators</a> +</h4></div></div></div> +<p> + Iterators can be projected to any of the three views of the bimap. A bimap + provides three member functions to cope with projection: <code class="computeroutput"><span class="identifier">project_left</span></code>, <code class="computeroutput"><span class="identifier">project_right</span></code> + and <code class="computeroutput"><span class="identifier">project_up</span></code>, with projects + iterators to the <span class="emphasis"><em>left map view</em></span>, the <span class="emphasis"><em>right + map view</em></span> and the <span class="emphasis"><em>collection of relations view</em></span>. + These functions take any iterator from the bimap and retrieve an iterator + over the projected view pointing to the same element. + </p> +<p> + Here is an example that uses projection: + </p> +<p> + <a href="../../../../example/projection.cpp" target="_top">Go to source code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span><span class="identifier">multiset_of</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span> <span class="special">></span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> + +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"John"</span> <span class="special">,</span><span class="number">34</span><span class="special">)</span> <span class="special">);</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"Peter"</span><span class="special">,</span><span class="number">24</span><span class="special">)</span> <span class="special">);</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="string">"Mary"</span> <span class="special">,</span><span class="number">12</span><span class="special">)</span> <span class="special">);</span> + +<span class="comment">// Find the name of the next younger person after Peter +</span> +<span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_const_iterator</span> <span class="identifier">name_iter</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="string">"Peter"</span><span class="special">);</span> + +<span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">right_const_iterator</span> <span class="identifier">years_iter</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">project_right</span><span class="special">(</span><span class="identifier">name_iter</span><span class="special">);</span> + +<span class="special">++</span><span class="identifier">years_iter</span><span class="special">;</span> + +<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"The next younger person after Peter is "</span> <span class="special"><<</span> <span class="identifier">years_iter</span><span class="special">-></span><span class="identifier">second</span><span class="special">;</span> +</pre> +<p> + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.useful_functions.replace_and_modify"></a><a class="link" href="useful_functions.html#boost_bimap.the_tutorial.useful_functions.replace_and_modify" title="replace and modify">replace + and modify</a> +</h4></div></div></div> +<p> + These functions are members of the views of a bimap that are not founded + in their standard counterparts. + </p> +<p> + The <code class="computeroutput"><span class="identifier">replace</span></code> family member + functions performs in-place replacement of a given element as the following + example shows: + </p> +<p> + <a href="../../../../example/tutorial_modify_and_replace.cpp" target="_top">Go to source + code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="string">"one"</span><span class="special">)</span> <span class="special">);</span> + +<span class="comment">// Replace (1,"one") with (1,"1") using the right map view +</span><span class="special">{</span> + <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">right_iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="string">"one"</span><span class="special">);</span> + + <span class="keyword">bool</span> <span class="identifier">successful_replace</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">replace_key</span><span class="special">(</span> <span class="identifier">it</span><span class="special">,</span> <span class="string">"1"</span> <span class="special">);</span> + + <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">successful_replace</span> <span class="special">);</span> +<span class="special">}</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="number">2</span><span class="special">,</span><span class="string">"two"</span><span class="special">)</span> <span class="special">);</span> + +<span class="comment">// Fail to replace (1,"1") with (1,"two") using the left map view +</span><span class="special">{</span> + <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special">==</span> <span class="number">2</span> <span class="special">);</span> + + <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="number">1</span><span class="special">);</span> + + <span class="keyword">bool</span> <span class="identifier">successful_replace</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">replace_data</span><span class="special">(</span> <span class="identifier">it</span><span class="special">,</span> <span class="string">"two"</span> <span class="special">);</span> + + <a class="co" name="boost_bimap9co" href="useful_functions.html#boost_bimap9"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a><span class="identifier">assert</span><span class="special">(</span> <span class="special">!</span> <span class="identifier">successful_replace</span> <span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special">==</span> <span class="number">2</span> <span class="special">);</span> +<span class="special">}</span> +</pre> +<p> + </p> +<div class="calloutlist"><table border="0" summary="Callout list"><tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap9"></a><a href="#boost_bimap9co"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> +<td valign="top" align="left"><p> + <code class="computeroutput"><span class="identifier">it</span></code> is still valid here, + and the bimap was left unchanged + </p></td> +</tr></table></div> +<p> + <code class="computeroutput"><span class="identifier">replace</span></code> functions performs + this substitution in such a manner that: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + The complexity is constant time if the changed element retains its + original order with respect to all views; it is logarithmic otherwise. + </li> +<li class="listitem"> + Iterator and reference validity are preserved. + </li> +<li class="listitem"> + The operation is strongly exception-safe, i.e. the <code class="computeroutput"><span class="identifier">bimap</span></code> + remains unchanged if some exception (originated by the system or the + user's data types) is thrown. + </li> +</ul></div> +<p> + <code class="computeroutput"><span class="identifier">replace</span></code> functions are powerful + operations not provided by standard STL containers, and one that is specially + handy when strong exception-safety is required. + </p> +<p> + The observant reader might have noticed that the convenience of replace + comes at a cost: namely the whole element has to be copied <span class="emphasis"><em>twice</em></span> + to do the updating (when retrieving it and inside <code class="computeroutput"><span class="identifier">replace</span></code>). + If elements are expensive to copy, this may be quite a computational cost + for the modification of just a tiny part of the object. To cope with this + situation, Boost.Bimap provides an alternative updating mechanism: <code class="computeroutput"><span class="identifier">modify</span></code> functions. + </p> +<p> + <code class="computeroutput"><span class="identifier">modify</span></code> functions accepts + a functor (or pointer to function) taking a reference to the data to be + changed, thus eliminating the need for spurious copies. Like <code class="computeroutput"><span class="identifier">replace</span></code> functions, <code class="computeroutput"><span class="identifier">modify</span></code> + functions does preserve the internal orderings of all the indices of the + <code class="computeroutput"><span class="identifier">bimap</span></code>. However, the semantics + of modify functions are not entirely equivalent to replace functions. Consider + what happens if a collision occurs as a result of modifying the element, + i.e. the modified element clashes with another with respect to some unique + view. In the case of <code class="computeroutput"><span class="identifier">replace</span></code> + functions, the original value is kept and the method returns without altering + the container, but <code class="computeroutput"><span class="identifier">modify</span></code> + functions cannot afford such an approach, since the modifying functor leaves + no trace of the previous value of the element. Integrity constraints thus + lead to the following policy: when a collision happens in the process of + calling a modify functions, the element is erased and the method returns + false. This difference in behavior between <code class="computeroutput"><span class="identifier">replace</span></code> + and <code class="computeroutput"><span class="identifier">modify</span></code> functions has + to be considered by the programmer on a case-by-case basis. + </p> +<p> + Boost.Bimap defines new placeholders named <code class="computeroutput"><span class="identifier">_key</span></code> + and <code class="computeroutput"><span class="identifier">_data</span></code> to allow a sounder + solution. You have to include <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">support</span><span class="special">/</span><span class="identifier">lambda</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> + to use them. + </p> +<p> + <a href="../../../../example/tutorial_modify_and_replace.cpp" target="_top">Go to source + code</a> + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="string">"one"</span><span class="special">)</span> <span class="special">);</span> + +<span class="comment">// Modify (1,"one") to (1,"1") using the right map view +</span><span class="special">{</span> + <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">right_iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="string">"one"</span><span class="special">);</span> + + <span class="keyword">bool</span> <span class="identifier">successful_modify</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">modify_key</span><span class="special">(</span> <span class="identifier">it</span> <span class="special">,</span> <span class="identifier">_key</span> <span class="special">=</span> <span class="string">"1"</span> <span class="special">);</span> + + <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">successful_modify</span> <span class="special">);</span> +<span class="special">}</span> + +<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="number">2</span><span class="special">,</span><span class="string">"two"</span><span class="special">)</span> <span class="special">);</span> + +<span class="comment">// Fail to modify (1,"1") to (1,"two") using the left map view +</span><span class="special">{</span> + <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special">==</span> <span class="number">2</span> <span class="special">);</span> + + <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="number">1</span><span class="special">);</span> + + <span class="keyword">bool</span> <span class="identifier">successful_modify</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">modify_data</span><span class="special">(</span> <span class="identifier">it</span><span class="special">,</span> <span class="identifier">_data</span> <span class="special">=</span> <span class="string">"two"</span> <span class="special">);</span> + + <a class="co" name="boost_bimap10co" href="useful_functions.html#boost_bimap10"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a><span class="identifier">assert</span><span class="special">(</span> <span class="special">!</span> <span class="identifier">successful_modify</span> <span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special">==</span> <span class="number">1</span> <span class="special">);</span> +<span class="special">}</span> +</pre> +<p> + </p> +<div class="calloutlist"><table border="0" summary="Callout list"><tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap10"></a><a href="#boost_bimap10co"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> +<td valign="top" align="left"><p> + <code class="computeroutput"><span class="identifier">it</span></code> is not longer valid + and <code class="computeroutput"><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="string">"1"</span><span class="special">)</span></code> is removed from the bimap + </p></td> +</tr></table></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="boost_bimap.the_tutorial.useful_functions.retrieval_of_ranges"></a><a class="link" href="useful_functions.html#boost_bimap.the_tutorial.useful_functions.retrieval_of_ranges" title="Retrieval of ranges">Retrieval + of ranges</a> +</h4></div></div></div> +<p> + Standard <code class="computeroutput"><span class="identifier">lower_bound</span></code> and + <code class="computeroutput"><span class="identifier">upper_bound</span></code> functions can + be used to lookup for all the elements in a given range. + </p> +<p> + Suppose we want to retrieve the elements from a <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">></span></code> where the left value is in the range + <code class="computeroutput"><span class="special">[</span><span class="number">20</span><span class="special">,</span><span class="number">50</span><span class="special">]</span></code> + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> + +<span class="comment">// ... +</span> +<span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_iterator</span> <span class="identifier">iter_first</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">lower_bound</span><span class="special">(</span><span class="number">20</span><span class="special">);</span> +<span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_iterator</span> <span class="identifier">iter_second</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">upper_bound</span><span class="special">(</span><span class="number">50</span><span class="special">);</span> + +<span class="comment">// range [iter_first,iter_second) contains the elements in [20,50] +</span></pre> +<p> + </p> +<p> + Subtle changes to the code are required when strict inequalities are considered. + To retrieve the elements greater than 20 and less than 50, the code has + to be rewritten as + </p> +<p> + +</p> +<pre class="programlisting"><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_iterator</span> <span class="identifier">iter_first</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">upper_bound</span><span class="special">(</span><span class="number">20</span><span class="special">);</span> +<span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_iterator</span> <span class="identifier">iter_second</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">lower_bound</span><span class="special">(</span><span class="number">50</span><span class="special">);</span> + +<span class="comment">// range [iter_first,iter_second) contains the elements in (20,50) +</span></pre> +<p> + </p> +<p> + To add to this complexity, the careful programmer has to take into account + that the lower and upper bounds of the interval searched be compatible: + for instance, if the lower bound is 50 and the upper bound is 20, the iterators + <code class="computeroutput"><span class="identifier">iter_first</span></code> and <code class="computeroutput"><span class="identifier">iter_second</span></code> produced by the code above + will be in reverse order, with possibly catastrophic results if a traversal + from <code class="computeroutput"><span class="identifier">iter_first</span></code> to <code class="computeroutput"><span class="identifier">iter_second</span></code> is tried. All these details + make range searching a tedious and error prone task. + </p> +<p> + The range member function, often in combination with lambda expressions, + can greatly help alleviate this situation: + </p> +<p> + +</p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">></span> <span class="identifier">bm_type</span><span class="special">;</span> +<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span> + +<span class="comment">// ... +</span> +<a class="co" name="boost_bimap11co" href="useful_functions.html#boost_bimap11"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_range_type</span> <span class="identifier">r</span><span class="special">;</span> + +<a class="co" name="boost_bimap12co" href="useful_functions.html#boost_bimap12"><img src="../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a><span class="identifier">r</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">range</span><span class="special">(</span> <span class="number">20</span> <span class="special"><=</span> <span class="identifier">_key</span><span class="special">,</span> <span class="identifier">_key</span> <span class="special"><=</span> <span class="number">50</span> <span class="special">);</span> <span class="comment">// [20,50] +</span> +<span class="identifier">r</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">range</span><span class="special">(</span> <span class="number">20</span> <span class="special"><</span> <span class="identifier">_key</span><span class="special">,</span> <span class="identifier">_key</span> <span class="special"><</span> <span class="number">50</span> <span class="special">);</span> <span class="comment">// (20,50) +</span> +<span class="identifier">r</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">range</span><span class="special">(</span> <span class="number">20</span> <span class="special"><=</span> <span class="identifier">_key</span><span class="special">,</span> <span class="identifier">_key</span> <span class="special"><</span> <span class="number">50</span> <span class="special">);</span> <span class="comment">// [20,50) +</span></pre> +<p> + </p> +<div class="calloutlist"><table border="0" summary="Callout list"> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap11"></a><a href="#boost_bimap11co"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> +<td valign="top" align="left"><p> + <code class="computeroutput"><span class="identifier">range_type</span></code> is a handy + typedef equal to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="identifier">iterator</span><span class="special">></span></code>. <code class="computeroutput"><span class="identifier">const_range_type</span></code> + is provided too, and it is equal to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">const_iterator</span><span class="special">,</span><span class="identifier">const_iterator</span><span class="special">></span></code> + </p></td> +</tr> +<tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap12"></a><a href="#boost_bimap12co"><img src="../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> </p></td> +<td valign="top" align="left"><p> + _key is a Boost.Lambda placeholder. To use it you have to include + <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bimap</span><span class="special">/</span><span class="identifier">support</span><span class="special">/</span><span class="identifier">lambda</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> + </p></td> +</tr> +</table></div> +<p> + <code class="computeroutput"><span class="identifier">range</span></code> simply accepts predicates + specifying the lower and upper bounds of the interval searched. Please + consult the reference for a detailed explanation of the permissible predicates + passed to range. + </p> +<p> + One or both bounds can be omitted with the special unbounded marker: + </p> +<p> + +</p> +<pre class="programlisting"><span class="identifier">r</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">range</span><span class="special">(</span> <span class="number">20</span> <span class="special"><=</span> <span class="identifier">_key</span><span class="special">,</span> <span class="identifier">unbounded</span> <span class="special">);</span> <span class="comment">// [20,inf) +</span> +<span class="identifier">r</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">range</span><span class="special">(</span> <span class="identifier">unbounded</span> <span class="special">,</span> <span class="identifier">_key</span> <span class="special"><</span> <span class="number">50</span> <span class="special">);</span> <span class="comment">// (-inf,50) +</span> +<a class="co" name="boost_bimap13co" href="useful_functions.html#boost_bimap13"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a><span class="identifier">r</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">range</span><span class="special">(</span> <span class="identifier">unbounded</span> <span class="special">,</span> <span class="identifier">unbounded</span> <span class="special">);</span> <span class="comment">// (-inf,inf) +</span></pre> +<p> + </p> +<div class="calloutlist"><table border="0" summary="Callout list"><tr> +<td width="5%" valign="top" align="left"><p><a name="boost_bimap13"></a><a href="#boost_bimap13co"><img src="../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> +<td valign="top" align="left"><p> + This is equivalent to std::make_pair(s.begin(),s.end()) + </p></td> +</tr></table></div> +<p> + <a href="../../../../example/tutorial_range.cpp" target="_top">Go to source code</a> + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006 -2007 Matias Capeletto<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="differences_with_standard_maps.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bimaps_with_user_defined_names.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/libs/bimap/doc/html/boostbook.css b/libs/bimap/doc/html/boostbook.css new file mode 100644 index 0000000000..e5d7bb5060 --- /dev/null +++ b/libs/bimap/doc/html/boostbook.css @@ -0,0 +1,582 @@ +/*============================================================================= + Copyright (c) 2004 Joel de Guzman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +/*============================================================================= + Body defaults +=============================================================================*/ + + body + { + margin: 1em; + font-family: sans-serif; + } + +/*============================================================================= + Paragraphs +=============================================================================*/ + + p + { + text-align: left; + font-size: 10pt; + line-height: 1.15; + } + +/*============================================================================= + Program listings +=============================================================================*/ + + /* Code on paragraphs */ + p tt.computeroutput + { + font-size: 10pt; + } + + pre.synopsis + { + font-size: 10pt; + margin: 1pc 4% 0pc 4%; + padding: 0.5pc 0.5pc 0.5pc 0.5pc; + } + + .programlisting, + .screen + { + font-size: 10pt; + display: block; + margin: 1pc 4% 0pc 4%; + padding: 0.5pc 0.5pc 0.5pc 0.5pc; + } + + /* Program listings in tables don't get borders */ + td .programlisting, + td .screen + { + margin: 0pc 0pc 0pc 0pc; + padding: 0pc 0pc 0pc 0pc; + } + +/*============================================================================= + Headings +=============================================================================*/ + + h1, h2, h3, h4, h5, h6 + { + text-align: left; + margin: 1em 0em 0.5em 0em; + font-weight: bold; + } + + h1 { font: 140% } + h2 { font: bold 140% } + h3 { font: bold 130% } + h4 { font: bold 120% } + h5 { font: italic 110% } + h6 { font: italic 100% } + + /* Top page titles */ + title, + h1.title, + h2.title + h3.title, + h4.title, + h5.title, + h6.title, + .refentrytitle + { + font-weight: bold; + margin-bottom: 1pc; + } + + h1.title { font-size: 140% } + h2.title { font-size: 140% } + h3.title { font-size: 130% } + h4.title { font-size: 120% } + h5.title { font-size: 110% } + h6.title { font-size: 100% } + + .section h1 + { + margin: 0em 0em 0.5em 0em; + font-size: 140%; + } + + .section h2 { font-size: 140% } + .section h3 { font-size: 130% } + .section h4 { font-size: 120% } + .section h5 { font-size: 110% } + .section h6 { font-size: 100% } + + /* Code on titles */ + h1 tt.computeroutput { font-size: 140% } + h2 tt.computeroutput { font-size: 140% } + h3 tt.computeroutput { font-size: 130% } + h4 tt.computeroutput { font-size: 120% } + h5 tt.computeroutput { font-size: 110% } + h6 tt.computeroutput { font-size: 100% } + +/*============================================================================= + Author +=============================================================================*/ + + h3.author + { + font-size: 100% + } + +/*============================================================================= + Lists +=============================================================================*/ + + li + { + font-size: 10pt; + line-height: 1.3; + } + + /* Unordered lists */ + ul + { + text-align: left; + } + + /* Ordered lists */ + ol + { + text-align: left; + } + +/*============================================================================= + Links +=============================================================================*/ + + a + { + text-decoration: none; /* no underline */ + } + + a:hover + { + text-decoration: underline; + } + +/*============================================================================= + Spirit style navigation +=============================================================================*/ + + .spirit-nav + { + text-align: right; + } + + .spirit-nav a + { + color: white; + padding-left: 0.5em; + } + + .spirit-nav img + { + border-width: 0px; + } + +/*============================================================================= + Table of contents +=============================================================================*/ + + .toc + { + margin: 1pc 4% 0pc 4%; + padding: 0.1pc 1pc 0.1pc 1pc; + font-size: 10pt; + line-height: 1.15; + } + + .toc-main + { + text-align: center; + margin: 3pc 16% 3pc 16%; + padding: 3pc 1pc 3pc 1pc; + line-height: 0.1; + } + + .boost-toc + { + float: right; + padding: 0.5pc; + } + +/*============================================================================= + Tables +=============================================================================*/ + + .table-title, + div.table p.title + { + margin-left: 4%; + padding-right: 0.5em; + padding-left: 0.5em; + } + + .informaltable table, + .table table + { + width: 92%; + margin-left: 4%; + margin-right: 4%; + } + + div.informaltable table, + div.table table + { + padding: 4px; + } + + /* Table Cells */ + div.informaltable table tr td, + div.table table tr td + { + padding: 0.5em; + text-align: left; + } + + div.informaltable table tr th, + div.table table tr th + { + padding: 0.5em 0.5em 0.5em 0.5em; + border: 1pt solid white; + font-size: 120%; + } + +/*============================================================================= + Blurbs +=============================================================================*/ + + div.note, + div.tip, + div.important, + div.caution, + div.warning, + div.sidebar + { + font-size: 10pt; + line-height: 1.2; + display: block; + margin: 1pc 4% 0pc 4%; + padding: 0.5pc 0.5pc 0.5pc 0.5pc; + } + + div.sidebar img + { + padding: 1pt; + } + + + +/*============================================================================= + Callouts +=============================================================================*/ + .line_callout_bug img + { + float: left; + position:relative; + left: 4px; + top: -12px; + clear: left; + margin-left:-22px; + } + + .callout_bug img + { + } + + + +/*============================================================================= + Variable Lists +=============================================================================*/ + + /* Make the terms in definition lists bold */ + div.variablelist dl dt, + span.term + { + font-weight: bold; + font-size: 10pt; + } + + div.variablelist table tbody tr td + { + text-align: left; + vertical-align: top; + padding: 0em 2em 0em 0em; + font-size: 10pt; + margin: 0em 0em 0.5em 0em; + line-height: 1; + } + + /* Make the terms in definition lists bold */ + div.variablelist dl dt + { + margin-bottom: 0.2em; + } + + div.variablelist dl dd + { + margin: 0em 0em 0.5em 2em; + font-size: 10pt; + } + + div.variablelist table tbody tr td p + div.variablelist dl dd p + { + margin: 0em 0em 0.5em 0em; + line-height: 1; + } + +/*============================================================================= + Misc +=============================================================================*/ + + /* Title of books and articles in bibliographies */ + span.title + { + font-style: italic; + } + + span.underline + { + text-decoration: underline; + } + + span.strikethrough + { + text-decoration: line-through; + } + + /* Copyright, Legal Notice */ + div div.legalnotice p + { + text-align: left + } + +/*============================================================================= + Colors +=============================================================================*/ + + @media screen + { + /* Links */ + a + { + color: #0C7445; + } + + a:visited + { + color: #663974; + } + + h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, + h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover, + h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited + { + text-decoration: none; /* no underline */ + color: #000000; + } + + /* Syntax Highlighting */ + .keyword { color: #0000AA; } + .identifier { color: #000000; } + .special { color: #707070; } + .preprocessor { color: #402080; } + .char { color: teal; } + .comment { color: #800000; } + .string { color: teal; } + .number { color: teal; } + .white_bkd { background-color: #E8FBE9; } + .dk_grey_bkd { background-color: #A0DAAC; } + + /* Copyright, Legal Notice */ + .copyright + { + color: #666666; + font-size: small; + } + + div div.legalnotice p + { + color: #666666; + } + + /* Program listing */ + pre.synopsis + { + border: 1px solid #DCDCDC; + border-bottom: 3px solid #9D9D9D; + border-right: 3px solid #9D9D9D; + background-color: #FAFFFB; + } + + .programlisting, + .screen + { + border: 1px solid #DCDCDC; + border-bottom: 3px solid #9D9D9D; + border-right: 3px solid #9D9D9D; + background-color: #FAFFFB; + } + + td .programlisting, + td .screen + { + border: 0px solid #DCDCDC; + } + + /* Blurbs */ + div.note, + div.tip, + div.important, + div.caution, + div.warning, + div.sidebar + { + border: 1px solid #DCDCDC; + border-bottom: 3px solid #9D9D9D; + border-right: 3px solid #9D9D9D; + background-color: #FAFFFB; + } + + /* Table of contents */ + .toc + { + border: 1px solid #DCDCDC; + border-bottom: 3px solid #9D9D9D; + border-right: 3px solid #9D9D9D; + background-color: #FAFFFB; + } + + /* Table of contents */ + .toc-main + { + border: 1px solid #DCDCDC; + border-bottom: 3px solid #9D9D9D; + border-right: 3px solid #9D9D9D; + background-color: #FAFFFB; + } + + + /* Tables */ + div.informaltable table tr td, + div.table table tr td + { + border: 1px solid #DCDCDC; + background-color: #FAFFFB; + } + + div.informaltable table tr th, + div.table table tr th + { + background-color: #E3F9E4; + border: 1px solid #DCDCDC; + } + + /* Misc */ + span.highlight + { + color: #00A000; + } + } + + @media print + { + /* Links */ + a + { + color: black; + } + + a:visited + { + color: black; + } + + .spirit-nav + { + display: none; + } + + /* Program listing */ + pre.synopsis + { + border: 1px solid gray; + background-color: #FAFFFB; + } + + .programlisting, + .screen + { + border: 1px solid gray; + background-color: #FAFFFB; + } + + td .programlisting, + td .screen + { + border: 0px solid #DCDCDC; + } + + /* Table of contents */ + .toc + { + border: 1px solid #DCDCDC; + border-bottom: 3px solid #9D9D9D; + border-right: 3px solid #9D9D9D; + background-color: #FAFFFB; + } + + /* Table of contents */ + .toc-main + { + border: 1px solid #DCDCDC; + border-bottom: 3px solid #9D9D9D; + border-right: 3px solid #9D9D9D; + background-color: #FAFFFB; + } + + .informaltable table, + .table table + { + border: 1px solid #DCDCDC; + border-bottom: 3px solid #9D9D9D; + border-right: 3px solid #9D9D9D; + border-collapse: collapse; + background-color: #FAFFFB; + } + + /* Tables */ + div.informaltable table tr td, + div.table table tr td + { + border: 1px solid #DCDCDC; + background-color: #FAFFFB; + } + + div.informaltable table tr th, + div.table table tr th + { + border: 1px solid #DCDCDC; + background-color: #FAFFFB; + } + + /* Misc */ + span.highlight + { + font-weight: bold; + } + } diff --git a/libs/bimap/doc/html/images/bimap/bimap.structures.png b/libs/bimap/doc/html/images/bimap/bimap.structures.png Binary files differnew file mode 100644 index 0000000000..7ff63e47b8 --- /dev/null +++ b/libs/bimap/doc/html/images/bimap/bimap.structures.png diff --git a/libs/bimap/doc/html/images/bimap/boost.bimap.header.png b/libs/bimap/doc/html/images/bimap/boost.bimap.header.png Binary files differnew file mode 100644 index 0000000000..1dcdd506b4 --- /dev/null +++ b/libs/bimap/doc/html/images/bimap/boost.bimap.header.png diff --git a/libs/bimap/doc/html/images/bimap/boost.bimap.logo.png b/libs/bimap/doc/html/images/bimap/boost.bimap.logo.png Binary files differnew file mode 100644 index 0000000000..7452ce65d6 --- /dev/null +++ b/libs/bimap/doc/html/images/bimap/boost.bimap.logo.png diff --git a/libs/bimap/doc/html/images/bimap/collection.type.of.relation.png b/libs/bimap/doc/html/images/bimap/collection.type.of.relation.png Binary files differnew file mode 100644 index 0000000000..b2790ccca6 --- /dev/null +++ b/libs/bimap/doc/html/images/bimap/collection.type.of.relation.png diff --git a/libs/bimap/doc/html/images/bimap/extended.mapping.framework.png b/libs/bimap/doc/html/images/bimap/extended.mapping.framework.png Binary files differnew file mode 100644 index 0000000000..b5e21c3e44 --- /dev/null +++ b/libs/bimap/doc/html/images/bimap/extended.mapping.framework.png diff --git a/libs/bimap/doc/html/images/bimap/miBimapFramework.png b/libs/bimap/doc/html/images/bimap/miBimapFramework.png Binary files differnew file mode 100644 index 0000000000..c392aa1f00 --- /dev/null +++ b/libs/bimap/doc/html/images/bimap/miBimapFramework.png diff --git a/libs/bimap/doc/html/images/bimap/more.bimap.structures.png b/libs/bimap/doc/html/images/bimap/more.bimap.structures.png Binary files differnew file mode 100644 index 0000000000..93ec73e129 --- /dev/null +++ b/libs/bimap/doc/html/images/bimap/more.bimap.structures.png diff --git a/libs/bimap/doc/html/images/bimap/relation.and.pair.png b/libs/bimap/doc/html/images/bimap/relation.and.pair.png Binary files differnew file mode 100644 index 0000000000..5c1e498348 --- /dev/null +++ b/libs/bimap/doc/html/images/bimap/relation.and.pair.png diff --git a/libs/bimap/doc/html/images/bimap/relation.and.pair.with.info.png b/libs/bimap/doc/html/images/bimap/relation.and.pair.with.info.png Binary files differnew file mode 100644 index 0000000000..56319b6afb --- /dev/null +++ b/libs/bimap/doc/html/images/bimap/relation.and.pair.with.info.png diff --git a/libs/bimap/doc/html/images/bimap/relation.png b/libs/bimap/doc/html/images/bimap/relation.png Binary files differnew file mode 100644 index 0000000000..e3d0584d49 --- /dev/null +++ b/libs/bimap/doc/html/images/bimap/relation.png diff --git a/libs/bimap/doc/html/images/bimap/simple.bimap.png b/libs/bimap/doc/html/images/bimap/simple.bimap.png Binary files differnew file mode 100644 index 0000000000..fd32dd41c0 --- /dev/null +++ b/libs/bimap/doc/html/images/bimap/simple.bimap.png diff --git a/libs/bimap/doc/html/images/bimap/standard.mapping.framework.png b/libs/bimap/doc/html/images/bimap/standard.mapping.framework.png Binary files differnew file mode 100644 index 0000000000..4985daf59f --- /dev/null +++ b/libs/bimap/doc/html/images/bimap/standard.mapping.framework.png diff --git a/libs/bimap/doc/html/images/bimap/tagged.png b/libs/bimap/doc/html/images/bimap/tagged.png Binary files differnew file mode 100644 index 0000000000..fab67181c5 --- /dev/null +++ b/libs/bimap/doc/html/images/bimap/tagged.png diff --git a/libs/bimap/doc/html/images/callouts/1.png b/libs/bimap/doc/html/images/callouts/1.png Binary files differnew file mode 100644 index 0000000000..6003ad3af4 --- /dev/null +++ b/libs/bimap/doc/html/images/callouts/1.png diff --git a/libs/bimap/doc/html/images/callouts/10.png b/libs/bimap/doc/html/images/callouts/10.png Binary files differnew file mode 100644 index 0000000000..0426f516a4 --- /dev/null +++ b/libs/bimap/doc/html/images/callouts/10.png diff --git a/libs/bimap/doc/html/images/callouts/11.png b/libs/bimap/doc/html/images/callouts/11.png Binary files differnew file mode 100644 index 0000000000..821afc4fa8 --- /dev/null +++ b/libs/bimap/doc/html/images/callouts/11.png diff --git a/libs/bimap/doc/html/images/callouts/12.png b/libs/bimap/doc/html/images/callouts/12.png Binary files differnew file mode 100644 index 0000000000..7cec72720f --- /dev/null +++ b/libs/bimap/doc/html/images/callouts/12.png diff --git a/libs/bimap/doc/html/images/callouts/13.png b/libs/bimap/doc/html/images/callouts/13.png Binary files differnew file mode 100644 index 0000000000..5b41e02a67 --- /dev/null +++ b/libs/bimap/doc/html/images/callouts/13.png diff --git a/libs/bimap/doc/html/images/callouts/14.png b/libs/bimap/doc/html/images/callouts/14.png Binary files differnew file mode 100644 index 0000000000..de5bdbd3eb --- /dev/null +++ b/libs/bimap/doc/html/images/callouts/14.png diff --git a/libs/bimap/doc/html/images/callouts/15.png b/libs/bimap/doc/html/images/callouts/15.png Binary files differnew file mode 100644 index 0000000000..3fd6ac3860 --- /dev/null +++ b/libs/bimap/doc/html/images/callouts/15.png diff --git a/libs/bimap/doc/html/images/callouts/2.png b/libs/bimap/doc/html/images/callouts/2.png Binary files differnew file mode 100644 index 0000000000..f7c1578846 --- /dev/null +++ b/libs/bimap/doc/html/images/callouts/2.png diff --git a/libs/bimap/doc/html/images/callouts/3.png b/libs/bimap/doc/html/images/callouts/3.png Binary files differnew file mode 100644 index 0000000000..3ff0a93931 --- /dev/null +++ b/libs/bimap/doc/html/images/callouts/3.png diff --git a/libs/bimap/doc/html/images/callouts/4.png b/libs/bimap/doc/html/images/callouts/4.png Binary files differnew file mode 100644 index 0000000000..6aa29fc0b4 --- /dev/null +++ b/libs/bimap/doc/html/images/callouts/4.png diff --git a/libs/bimap/doc/html/images/callouts/5.png b/libs/bimap/doc/html/images/callouts/5.png Binary files differnew file mode 100644 index 0000000000..36e785867a --- /dev/null +++ b/libs/bimap/doc/html/images/callouts/5.png diff --git a/libs/bimap/doc/html/images/callouts/6.png b/libs/bimap/doc/html/images/callouts/6.png Binary files differnew file mode 100644 index 0000000000..c943676bea --- /dev/null +++ b/libs/bimap/doc/html/images/callouts/6.png diff --git a/libs/bimap/doc/html/images/callouts/7.png b/libs/bimap/doc/html/images/callouts/7.png Binary files differnew file mode 100644 index 0000000000..20940de30d --- /dev/null +++ b/libs/bimap/doc/html/images/callouts/7.png diff --git a/libs/bimap/doc/html/images/callouts/8.png b/libs/bimap/doc/html/images/callouts/8.png Binary files differnew file mode 100644 index 0000000000..d8e34d4a09 --- /dev/null +++ b/libs/bimap/doc/html/images/callouts/8.png diff --git a/libs/bimap/doc/html/images/callouts/9.png b/libs/bimap/doc/html/images/callouts/9.png Binary files differnew file mode 100644 index 0000000000..abe636072b --- /dev/null +++ b/libs/bimap/doc/html/images/callouts/9.png diff --git a/libs/bimap/doc/html/images/extern/googlesoc.png b/libs/bimap/doc/html/images/extern/googlesoc.png Binary files differnew file mode 100644 index 0000000000..5621b678a7 --- /dev/null +++ b/libs/bimap/doc/html/images/extern/googlesoc.png diff --git a/libs/bimap/doc/html/images/people/hector.png b/libs/bimap/doc/html/images/people/hector.png Binary files differnew file mode 100644 index 0000000000..40f52da6fd --- /dev/null +++ b/libs/bimap/doc/html/images/people/hector.png diff --git a/libs/bimap/doc/html/images/people/joaquin.png b/libs/bimap/doc/html/images/people/joaquin.png Binary files differnew file mode 100644 index 0000000000..f0b1a253b7 --- /dev/null +++ b/libs/bimap/doc/html/images/people/joaquin.png diff --git a/libs/bimap/doc/html/images/people/mafalda.png b/libs/bimap/doc/html/images/people/mafalda.png Binary files differnew file mode 100644 index 0000000000..00781df3c7 --- /dev/null +++ b/libs/bimap/doc/html/images/people/mafalda.png diff --git a/libs/bimap/doc/html/images/people/matias.png b/libs/bimap/doc/html/images/people/matias.png Binary files differnew file mode 100644 index 0000000000..3fb32c7a0a --- /dev/null +++ b/libs/bimap/doc/html/images/people/matias.png diff --git a/libs/bimap/doc/html/images/space.png b/libs/bimap/doc/html/images/space.png Binary files differnew file mode 100644 index 0000000000..8109f30876 --- /dev/null +++ b/libs/bimap/doc/html/images/space.png diff --git a/libs/bimap/doc/html/index.html b/libs/bimap/doc/html/index.html new file mode 100644 index 0000000000..c8b1081228 --- /dev/null +++ b/libs/bimap/doc/html/index.html @@ -0,0 +1,158 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Chapter 1. Boost.Bimap</title> +<link rel="stylesheet" href="boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="index.html" title="Chapter 1. Boost.Bimap"> +<link rel="next" href="boost_bimap/introduction.html" title="Introduction"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td> +<td align="center"><a href="../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"><a accesskey="n" href="boost_bimap/introduction.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div> +<div class="chapter"> +<div class="titlepage"><div> +<div><h2 class="title"> +<a name="bimap"></a>Chapter 1. Boost.Bimap</h2></div> +<div><div class="author"><h3 class="author"> +<span class="firstname">Matias</span> <span class="surname">Capeletto</span> +</h3></div></div> +<div><p class="copyright">Copyright © 2006 -2007 Matias Capeletto</p></div> +<div><div class="legalnotice"> +<a name="id768625"></a><p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></div> +</div></div> +<div class="toc"> +<p><b>Table of Contents</b></p> +<dl> +<dt><span class="section"><a href="index.html#bimap.preface">Preface</a></span></dt> +<dt><span class="section"><a href="boost_bimap/introduction.html">Introduction</a></span></dt> +<dt><span class="section"><a href="boost_bimap/one_minute_tutorial.html">One minute tutorial</a></span></dt> +<dt><span class="section"><a href="boost_bimap/the_tutorial.html">The tutorial</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="boost_bimap/the_tutorial.html#boost_bimap.the_tutorial.roadmap">Roadmap</a></span></dt> +<dt><span class="section"><a href="boost_bimap/the_tutorial/discovering_the_bimap_framework.html">Discovering + the bimap framework</a></span></dt> +<dt><span class="section"><a href="boost_bimap/the_tutorial/controlling_collection_types.html">Controlling + collection types</a></span></dt> +<dt><span class="section"><a href="boost_bimap/the_tutorial/the_collection_of_relations_type.html">The + collection of relations type</a></span></dt> +<dt><span class="section"><a href="boost_bimap/the_tutorial/differences_with_standard_maps.html">Differences + with standard maps</a></span></dt> +<dt><span class="section"><a href="boost_bimap/the_tutorial/useful_functions.html">Useful functions</a></span></dt> +<dt><span class="section"><a href="boost_bimap/the_tutorial/bimaps_with_user_defined_names.html">Bimaps + with user defined names</a></span></dt> +<dt><span class="section"><a href="boost_bimap/the_tutorial/unconstrained_sets.html">Unconstrained + Sets</a></span></dt> +<dt><span class="section"><a href="boost_bimap/the_tutorial/additional_information.html">Additional + information</a></span></dt> +<dt><span class="section"><a href="boost_bimap/the_tutorial/complete_instantiation_scheme.html">Complete + instantiation scheme</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="boost_bimap/bimap_and_boost.html">Bimap and Boost</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="boost_bimap/bimap_and_boost.html#boost_bimap.bimap_and_boost.bimap_and_multiindex">Bimap + and MultiIndex</a></span></dt> +<dt><span class="section"><a href="boost_bimap/bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html">Boost + Libraries that work well with Boost.Bimap</a></span></dt> +<dt><span class="section"><a href="boost_bimap/bimap_and_boost/dependencies.html">Dependencies</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="boost_bimap/reference.html">Reference</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="boost_bimap/reference.html#boost_bimap.reference.headers">Headers</a></span></dt> +<dt><span class="section"><a href="boost_bimap/reference/bimap_reference.html">Bimap Reference</a></span></dt> +<dt><span class="section"><a href="boost_bimap/reference/set_of_reference.html">set_of Reference</a></span></dt> +<dt><span class="section"><a href="boost_bimap/reference/unordered_set_of_reference.html">unordered_set_of + Reference</a></span></dt> +<dt><span class="section"><a href="boost_bimap/reference/list_of_reference.html">list_of Reference</a></span></dt> +<dt><span class="section"><a href="boost_bimap/reference/vector_of_reference.html">vector_of + Reference</a></span></dt> +<dt><span class="section"><a href="boost_bimap/reference/unconstrained_set_of_reference.html">unconstrained_set_of + Reference</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="boost_bimap/compiler_specifics.html">Compiler specifics</a></span></dt> +<dt><span class="section"><a href="boost_bimap/performance.html">Performance</a></span></dt> +<dt><span class="section"><a href="boost_bimap/examples.html">Examples</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="boost_bimap/examples.html#boost_bimap.examples.examples_list">Examples list</a></span></dt> +<dt><span class="section"><a href="boost_bimap/examples/simple_bimap.html">Simple Bimap</a></span></dt> +<dt><span class="section"><a href="boost_bimap/examples/mighty_bimap.html">Mighty Bimap</a></span></dt> +<dt><span class="section"><a href="boost_bimap/examples/multiindex_to_bimap_path___bidirectional_map.html">MultiIndex + to Bimap Path - Bidirectional Map</a></span></dt> +<dt><span class="section"><a href="boost_bimap/examples/multiindex_to_bimap_path___hashed_indices.html">MultiIndex + to Bimap Path - Hashed indices</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="boost_bimap/test_suite.html">Test suite</a></span></dt> +<dt><span class="section"><a href="boost_bimap/future_work.html">Future work</a></span></dt> +<dt><span class="section"><a href="boost_bimap/release_notes.html">Release notes</a></span></dt> +<dt><span class="section"><a href="boost_bimap/rationale.html">Rationale</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="boost_bimap/rationale.html#boost_bimap.rationale.general_design">General Design</a></span></dt> +<dt><span class="section"><a href="boost_bimap/rationale/additional_features.html">Additional + Features</a></span></dt> +<dt><span class="section"><a href="boost_bimap/rationale/code.html">Code</a></span></dt> +<dt><span class="section"><a href="boost_bimap/rationale/the_student_and_the_mentor.html">The + student and the mentor</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="boost_bimap/history.html">History</a></span></dt> +<dd><dl> +<dt><span class="section"><a href="boost_bimap/history.html#boost_bimap.history.the_long_path_from_code_project_to_boost">The + long path from Code Project to Boost</a></span></dt> +<dt><span class="section"><a href="boost_bimap/history/multiindex_and_bimap.html">MultiIndex + and Bimap</a></span></dt> +</dl></dd> +<dt><span class="section"><a href="boost_bimap/acknowledgements.html">Acknowledgements</a></span></dt> +</dl> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="bimap.preface"></a><a class="link" href="index.html#bimap.preface" title="Preface">Preface</a> +</h2></div></div></div> +<a name="bimap.preface.description"></a><h4> +<a name="id768655"></a> + <a class="link" href="index.html#bimap.preface.description">Description</a> + </h4> +<p> + <span class="inlinemediaobject"><img src="images/bimap/boost.bimap.logo.png" alt="boost.bimap.logo"></span> + </p> +<p> + Boost.Bimap is a bidirectional maps library for C++. With Boost.Bimap you can + create associative containers in which both types can be used as key. A <code class="computeroutput"><span class="identifier">bimap</span><span class="special"><</span><span class="identifier">X</span><span class="special">,</span><span class="identifier">Y</span><span class="special">></span></code> can be thought of as a combination of a + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="identifier">X</span><span class="special">,</span><span class="identifier">Y</span><span class="special">></span></code> + and a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="identifier">Y</span><span class="special">,</span><span class="identifier">X</span><span class="special">></span></code>. + The learning curve of bimap is almost flat if you know how to use standard + containers. A great deal of effort has been put into mapping the naming scheme + of the STL in Boost.Bimap. The library is designed to match the common STL + containers. + </p> +<a name="bimap.preface.influences_and_related_work"></a><h4> +<a name="id769071"></a> + <a class="link" href="index.html#bimap.preface.influences_and_related_work">Influences and Related + Work</a> + </h4> +<p> + The design of Boost.Bimap interface follows the standard template library. + It has been strongly influenced by Joaquin Lopez Muñoz's Boost.MultiIndex + library (the heart of bimaps) and codeproject::bimap library. + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"><p><small>Last revised: February 27, 2011 at 11:45:22 GMT</small></p></td> +<td align="right"><div class="copyright-footer"></div></td> +</tr></table> +<hr> +<div class="spirit-nav"><a accesskey="n" href="boost_bimap/introduction.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div> +</body> +</html> diff --git a/libs/bimap/doc/introduction.qbk b/libs/bimap/doc/introduction.qbk new file mode 100644 index 0000000000..25c1fa3faa --- /dev/null +++ b/libs/bimap/doc/introduction.qbk @@ -0,0 +1,99 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + + +[/ QuickBook Document version 1.4 ] + +[section Introduction] + +[heading How to use this document] + +This documentation contains a large amount of information. Whereas it +may be worth reading it all, this documentation is intended for +programmers with various motives: + +[variablelist +[[I have to finished this today, I just want a bidirectional map!][ +If your boss will kill you if the project is not finished by the end of +the day, just read the [link boost_bimap.one_minute_tutorial One-minute tutorial]. +If you have a background in STL, you can be testing a bimap within ten minutes. +]] +[[I am a serious programmer and want to learn Boost.Bimap][ +Boost.Bimap has a lot to offer if you are prepared to spend some time +reading this documentation. You will need to read [link boost_bimap.the_tutorial The tutorial] +and skim through some of the [link boost_bimap.examples Examples]. +The best way to read this documentation is in the order given here. +Just click on the arrow at the right bottom corner as you finish each page. +You may skip the reference section, and return to it later to look up a function +signature or to find a specific metafunction. +]] +[[I just love C++, I want to see the inner workings of Boost.Bimap.][ +If you are a library developer, this documentation is the best place to +learn how Boost.Bimap is implemented. It is strongly recommended that +you first learn to use the library as if you were the second type of +programmer above. This library was developed in the Google SoC 2006, and +the mentor and student generated a great deal of documentation in the +building process. The rationale section is very large and contains a lot +of information. There is a history section for those who might find it +useful. Finally, in the reference section, each entity of the library is +documented and its source code is presented. +]] +] + +[note +If anything in the documentation is unclear, please email me at ['matias +{dot} capeletto {at} gmail {dot} com], telling me which of the three +types of programmer above you are and which section needs improvement. +Please use the following notation for the subject: ['\[boost\]\[bimap\] Your +problem] as this will help me to identify it more easily. If appropriate, +I will act on your advice to improve the documentation. Thanks and enjoy! +] + +[important +If you should find a bug or would like to see an additional feature in +the library, please use the standard Boost methods of dealing with this +kind of issue rather than emailing me directly. Boost has a very good +system to [@http://www.boost.org/more/bugs.htm track bugs] and +[@http://www.boost.org/more/requesting_new_features.htm features requests], +and using it is the best way of dealing with them as soon as possible. +] + +[heading Navigation] + +Used in combination with the configured browser key (usually Alt), the +following keys act as handy shortcuts for common navigation tasks. + +* [*General] + + * [^[*p]] - Previous page + * [^[*n]] - Next page + * [^[*h]] - home + * [^[*u]] - Up + +* [*Main TOC] + + * [^[*i]] - Introduction + * [^[*o]] - One minute tutorial + * [^[*t]] - The tutorial + * [^[*b]] - Bimap and Boost + * [^[*r]] - Reference + * [^[*c]] - Compiler specifics + * [^[*v]] - Performance + * [^[*e]] - Examples + * [^[*s]] - Test Suite + * [^[*f]] - Future work + * [^[*m]] - Release notes + * [^[*w]] - Rationale + * [^[*y]] - History + * [^[*a]] - Acknowledgements + +[endsect]
\ No newline at end of file diff --git a/libs/bimap/doc/jamfile.v2 b/libs/bimap/doc/jamfile.v2 new file mode 100644 index 0000000000..290c209132 --- /dev/null +++ b/libs/bimap/doc/jamfile.v2 @@ -0,0 +1,42 @@ +# Boost.Bimap +# +# Copyright (c) 2006-2007 Matias Capeletto +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + + +# Quickbook +# ----------------------------------------------------------------------------- + +import quickbook ; + +xml bimap + : + bimap.qbk + ; + +path-constant images_location : html ; + +boostbook standalone + : + bimap + : + <xsl:param>boost.root=../../../.. + <xsl:param>html.stylesheet=boostbook.css + <xsl:param>toc.max.depth=2 + <xsl:param>toc.section.depth=4 + <xsl:param>chunk.section.depth=2 + <format>pdf:<xsl:param>img.src.path=$(images_location)/ + <format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/bimap/doc/html + ; + + +# Doxygen +# ----------------------------------------------------------------------------- +# This generate the doxydocs and write "bimap.hdt". +# Delete this file if you want to regenerate the doxydocs again +# import directdoxygen ; +# html-doxydocs bimap.hdt : bimap.hdf ; + diff --git a/libs/bimap/doc/performance.qbk b/libs/bimap/doc/performance.qbk new file mode 100644 index 0000000000..34335796c3 --- /dev/null +++ b/libs/bimap/doc/performance.qbk @@ -0,0 +1,19 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section Performance] + +Section under construction. + +[endsect]
\ No newline at end of file diff --git a/libs/bimap/doc/quick_tutorial.qbk b/libs/bimap/doc/quick_tutorial.qbk new file mode 100644 index 0000000000..bc14fcd2ed --- /dev/null +++ b/libs/bimap/doc/quick_tutorial.qbk @@ -0,0 +1,182 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section One minute tutorial] + +[heading What is a bimap?] + +A Bimap is a data structure that represents bidirectional relations between +elements of two collections. The container is designed to work as two opposed STL maps. A bimap between a collection `X` and a collection `Y` can be viewed as a map from `X` to `Y` (this view will be called the ['left map view]) or as a map from `Y` to `X` (known as the ['right map view]). Additionally, the bimap can also be viewed as a set of relations between `X` and `Y` (named the ['collection of relations view]). + +The following code creates an empty bimap container: + + typedef bimap<X,Y> bm_type; + bm_type bm; + +Given this code, the following is the complete description of the resulting bimap. +[footnote A type is ['signature-compatible] with other type if it has the same +signature for functions and metadata. Preconditions, postconditions and the order +of operations need not be the same. +] + +* `bm.left` is signature-compatible with `std::map<X,Y>` +* `bm.right` is signature-compatible with `std::map<Y,X>` +* `bm` is signature-compatible with `std::set< relation<X,Y> >` + +__SIMPLE_BIMAP__ + +You can see how a bimap container offers three views over the same collection of bidirectional relations. + +If we have any generic function that work with maps + + template< class MapType > + void print_map(const MapType & m) + { + typedef typename MapType::const_iterator const_iterator; + for( const_iterator iter = m.begin(), iend = m.end(); iter != iend; ++iter ) + { + std::cout << iter->first << "-->" << iter->second << std::endl; + } + } + +We can use the ['left map view] and the ['right map view] with it + + bimap< int, std::string > bm; + ... + print_map( bm.left ); + print_map( bm.right ); + +And the output will be + +[pre +[^1 --> one] +[^2 --> two] +... +[^one --> 1] +[^two --> 2] +... +] + +[heading Layout of the relation and the pairs of a bimap] + +The `relation` class represents two related elements. The two values are +named left and right to express the symmetry of this type. +The bimap pair classes are signature-compatible with `std::pairs`. + +__RELATION_AND_PAIR__ + +[heading Step by step] + +[import ../example/step_by_step.cpp] + +A convinience header is avaiable in the boost directory: + + #include <boost/bimap.hpp> + +Lets define a bidirectional map between integers and strings: + +[code_step_by_step_definition] + +[heading The collection of relations view] + +Remember that `bm` alone can be used as a set of relations. +We can insert elements or iterate over them using this view. + +[code_step_by_step_set_of_relations_view] + +[heading The left map view] + +`bm.left` works like a `std::map< int, std::string >`. We use it +in the same way we will use a standard map. + +[code_step_by_step_left_map_view] + +[heading The right map view] + +`bm.right` works like a `std::map< std::string, int >`. It is +important to note that the key is the first type and the data +is the second one, exactly as with standard maps. + +[code_step_by_step_right_map_view] + +[heading Differences with std::map] + +The main difference between bimap views and their standard containers counterparts +is that, because of the bidirectional nature of a bimap, the values stored in +it can not be modified directly using iterators. +For example, when a `std::map<X,Y>` iterator is dereferenced the return type is +`std::pair<const X, Y>`, so the following code is valid: +`m.begin()->second = new_value;`. +However dereferencing a `bimap<X,Y>::left_iterator` returns a type that is +['signature-compatible] with a `std::pair<const X, const Y>` + + bm.left.find(1)->second = "1"; // Compilation error + +If you insert `(1,"one")` and `(1,"1")` in a `std::map<int,std::string>` the second insertion will have no effect. In a `bimap<X,Y>` both keys have to remain unique. The insertion may fail in other situtions too. Lets see an example + + bm.clear(); + + bm.insert( bm_type::value_type( 1, "one" ) ); + + bm.insert( bm_type::value_type( 1, "1" ) ); // No effect! + bm.insert( bm_type::value_type( 2, "one" ) ); // No effect! + + assert( bm.size() == 1 ); + +[heading A simple example] + +Look how you can reuse code that is intend to be used with std::maps, like the +print_map function in this example. + +[@../../example/simple_bimap.cpp Go to source code] + +[code_simple_bimap] + +The output of this program will be the following: +[pre +[^The number of countries is 4] + +[^The winner is Argentina] + +[^Countries names ordered by their final position:] +[^1) Argentina] +[^2) Spain] +[^3) Germany] +[^4) France] + +[^Countries names ordered alphabetically along with their final position:] +[^Argentina ends in position 1] +[^France ends in position 4] +[^Germany ends in position 3] +[^Spain ends in position 2] +] + + +[heading Continuing the journey] + +For information on function signatures, see any standard library +documentation or read the [link boost_bimap.reference reference] section of +this documentation. + +[caution +Be aware that a bidirectional map is only signature-compatible with standard +containers. Some functions may give different results, such as in the case of +inserting a pair into the left map where the second value conflicts with a +stored relation in the container. The functions may be slower in a bimap +because of the duplicated constraints. It is strongly recommended that +you read [link boost_bimap.the_tutorial The full tutorial] if you intend to +use a bimap in a serious project. +] + +[endsect] diff --git a/libs/bimap/doc/rationale.qbk b/libs/bimap/doc/rationale.qbk new file mode 100644 index 0000000000..4a5028c049 --- /dev/null +++ b/libs/bimap/doc/rationale.qbk @@ -0,0 +1,914 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section Rationale] + +This section assumes that you have read all other sections, the most of +important of which being ['tutorial], ['std::set theory] and the ['reference], +and that you have tested the library. A lot of effort was invested in +making the interface as intuitive and clean as possible. If you +understand, and hopefully like, the interface of this library, it will +be a lot easier to read this rationale. The following section is little +more than a rationale. This library was coded in the context of the +Google SoC 2006 and the student and mentor were in different continents. +A great deal of email flowed between Joaquin and Matias. The juiciest +parts of the conversations where extracted and rearranged here. + +[note To browse the code, you can use the [@doxydoc/index.html ['Bimap Complete Reference]], a +doxygen-powered document targeted at developers. +] + +[section General Design] + +The initial explanation includes few features. This section aims to +describe the general design of the library and excludes details of those +features that are of lesser importance; these features will be +introduced later. + +The design of the library is divided into two parts. The first is the +construction of a [^relation] class. This will be the object stored and +managed by the [^multi_index_container] core. The idea is to make this +class as easy as possible to use, while making it efficient in terms of +memory and access time. This is a cornerstone in the design of +[*Boost.Bimap] and, as you will see in this rationale, the rest of the +design follows easily. + +The following interface is necessary for the [^relation] class: + + typedef -unspecified- TA; typedef -unspecified- TB; + + TA a, ai; TB b, bi; + + typedef relation< TA, TB > rel; + STATIC_ASSERT( is_same< rel::left_type , TA >::value ); + STATIC_ASSERT( is_same< rel::right_type, TB >::value ); + + rel r(ai,bi); + assert( r.left == ai && r.right == bi ); + + r.left = a; r.right = b; + assert( r.left == a && r.right == b ); + + typedef pair_type_by< member_at::left , rel >::type pba_type; + STATIC_ASSERT( is_same< pba_type::first_type , TA >::value ); + STATIC_ASSERT( is_same< pba_type::second_type, TB >::value ); + + typedef pair_type_by< member_at::right, rel >::type pbb_type; + STATIC_ASSERT( is_same< pbb_type::first_type , TB >::value ); + STATIC_ASSERT( is_same< pbb_type::second_type, TA >::value ); + + pba_type pba = pair_by< member_at::left >(r); + assert( pba.first == r.left && pba.second == r.right ); + + pbb_type pbb = pair_by< member_at::right >(r); + assert( pbb.first == r.right && pbb.second == r.left ); + + +__RELATION__ + +Although this seems straightforward, as will be seen later, it is the +most difficult code hack of the library. It is indeed very easy if we +relax some of the efficiency constraints. For example, it is trivial if +we allow a relation to have greater size than the the sum of those of +its components. It is equally simple if access speed is not important. +One of the first decisions made about [*Boost.Bimap] was, however, that, in +order to be useful, it had to achieve zero overhead over the wrapped +[*Boost.MultiIndex] container. Finally, there is another constraint that +can be relaxed: conformance to C++ standards, but this is quite +unacceptable. Let us now suppose that we have coded this class, and it +conforms to what was required. + +The second part is based on this [^relation] class. We can now view the +data in any of three ways: `pair<A,B>`, `relation<A,B>` and `pair<B,A>`. +Suppose that our bimap supports only one-to-one relations. (Other +relation types are considered additional features in this design.) +The proposed interface is very simple, and it is based heavily on the +concepts of the STL. Given a `bimap<A,B> bm`: + +# `bm.left` is signature-compatible with a `std::map<A,B>` +# `bm.right` is signature-compatible with a `std::map<B,A>` +# `bm` is signature-compatible with a `std::set<relation<A,B> >` + +__SIMPLE_BIMAP__ + +This interface is easily learned by users who have a STL background, as +well as being simple and powerful. This is the general design. + +[heading Relation Implementation] + +This section explains the details of the actual [^relation] class implementation. + +The first thing that we can imagine is the use of an [^union]. Regrettably, +the current C++ standard only allows unions of POD types. For the views, +we can try a wrapper around a `relation<A,B>` that has two references +named first and second that bind to `A` and `B`, or to `B` and `A`. + + relation<TA,TB> r; + + const_reference_pair<A,B> pba(r); + const_reference_pair<B,A> pbb(r); + +It is not difficult to code the relation class using this, but two +references are initialized at every access and using of `pba.first` will +be slower in most compilers than using `r.left` directly . There is +another hidden drawback of using this scheme: it is not +iterator-friendly, since the map views iterators must be degraded to +['Read Write] instead of ['LValue]. This will be explained later. + +At first, this seems to be the best we can do with the current C++ +standard. However there is a solution to this problem that does not +conform very well to C++ standards but does achieve zero overhead in +terms of access time and memory, and additionally allows the view +iterators to be upgraded to ['LValue] again. + +In order to use this, the compiler must conform to a +layout-compatibility clause that is not currently in the standard but is +very natural. The additional clause imposes that if we have two classes: + + struct class_a_b + { + Type1 name_a; + Type2 name_b; + }; + + struct class_b_a + { + Type1 name_b; + Type2 name_a; + }; + +then the storage layout of [^class_a_b] is equal to the storage layout of +[^class_b_a]. If you are surprised to learn that this does not hold in a +standards-compliant C++ compiler, welcome to the club. It is the natural +way to implement it from the point of view of the compiler's vendor and +is very useful for the developer. Maybe it will be included in the +standard some day. Every current compiler conforms to this. + +If we are able to count on this, then we can implement an idiom called +[^mutant]. The idea is to provide a secure wrapper around [^reinterpret_cast]. +A class can declare that it can be viewed using different view classes +that are storage-compatible with it. Then we use the free function +[^mutate<view>(mutant)] to get the view. The `mutate` function checks at +compile time that the requested view is declared in the mutant views list. +We implement a class name `structured_pair` that is signature-compatible +with a `std::pair`, while the storage layout is configured with a third +template parameter. Two instances of this template class will provide +the views of the relation. + +The thing is that if we want to be standards-compliant, we cannot use +this approach. It is very annoying not to be able to use something that +we know will work with every compiler and that is far better than +alternatives. So -- and this is an important decision -- we have to find +a way to use it and still make the library standards-compliant. + +The idea is very simple. We code both approaches: the +const_reference_pair-based and the mutant-based, and use the mutant +approach if the compiler is compliant with our new layout-compatible +clause. If the compiler really messes things up, we degrade the +performance of the bimap a little. The only drawback here is that, while +the mutant approach allows to make ['LValue] iterators, we have to degrade +them to ['Read Write] in both cases, because we require that the same code +be compilable by any standards-compliant compiler. + +[note +Testing this approach in all the supported compilers indicated that the +mutant idiom was always supported. The strictly compliant version was +removed from the code because it was never used. +] + + +[heading Bimap Implementation] + +The core of bimap will be obviously a `multi_index_container`. The basic +idea to tackle the implementation of the bimap class is to use +[^iterator_adaptor] to convert the iterators from Boost.MultiIndex to the +`std::map` and `std::set` behaviour. The `map_view` and the `set_view` can be +implemented directly using this new transformed iterators and a wrapper +around each index of the core container. However, there is a hidden +idiom here, that, once coded, will be very useful for other parts of +this library and for Boost.MRU library. Following the ideas from +`iterator_adaptor`, Boost.Bimap views are implemented using a +[^container_adaptor]. There are several template classes (for example +`map_adaptor` and `set_adaptor`) that take a `std::map` signature-conformant +class and new iterators, and adapt the container so it now uses this +iterators instead of the originals. For example, if you have a +`std::set<int*>`, you can build other container that behaves exactly as a +`std::set<int>` using `set_adaptor` and [^iterator_adaptor]. The combined use +of this two tools is very powerful. A [^container_adaptor] can take classes +that do not fulfil all the requirements of the adapted container. The +new container must define these missing functions. + +[endsect] + +[section Additional Features] + +[heading N-1, N-N, hashed maps] + +This is a very interesting point of the design. The framework introduced +in ['std::set theory] permits the management of the different constraints +with a very simple and conceptual approach. It is easy both to remember +and to learn. The idea here is to allow the user to specify the collection type +of each key directly. In order to implement this feature, we have to +solve two problems: + +* The index types of the `multi_index_container` core now depends on +the collection type used for each key. +* The map views now change their semantics according to the collection type +chosen. + +Boost.Bimap relies heavily on Boost.MPL to implement all of the +metaprogramming necessary to make this framework work. By default, if +the user does not specify the kind of the set, a `std::set` type is used. + +__BIMAP_STRUCTURES__ + +[heading Collection type of relation constraints] + +The constraints of the bimap set view are another very important +feature. In general, Boost.Bimap users will base the set view type on +one of the two collection types of their keys. It may be useful however to give +this set other constraints or simply to order it differently. By +default, Boost.Bimap bases the collection type of relations on the left collection +type, but the user may choose between: + +* left_based +* right_based +* set_of_relation<> +* multiset_of_relation<> +* unordered_set_of_relation<> +* unordered_multiset_of_relation<> +* list_of +* vector_of + +In the first two cases, there are only two indices in the +`multi_index_core`, and for this reason, these are the preferred options. +The implementation uses further metaprogramming to define a new index if +necessary. + +[/ +[heading Hooking Data] + +This is one of the things that makes Boost.Bimap very appealing in +tackling a problem. In general, programmers use maps to access +information quickly. Boost.Bimap allows the user to hook data inside the +bimap so that it is not necessary to maintain another map. The +implementation is based heavily on metaprogramming. +] + +[heading Tagged] + +The idea of using tags instead of the [^member_at::side] idiom is very +appealing since code that uses it is more readable. The only cost is +compile time. ['boost/bimap/tagged] is the implementation of a non-invasive +tagged idiom. The [^relation] class is built in such a way that even when +the user uses tags, the [^member_at::side] idiom continues to work. This is +good since an user can start tagging even before completing the coding +of the algorithm, and the untagged code continues to work. The +development becomes a little more complicated when user-defined tags are +included, but there are many handy metafunctions defined in the [^tagged] +idiom that help to keep things simple enough. + +__TAGGED__ + +[endsect] + +[section Code] + +You can browse the code using the [@doxydoc/index.html [*Boost.Bimap doxygen docs]]. + +The code follows the [@http://www.boost.org/more/lib_guide.htm Boost Library Requirement and Guidelines] as +closely as possible. + +[table folders in boost/bimap +[[name][what is inside?]] +[[/ ][user level header files ]] +[[tagged/ ][tagged idiom ]] +[[relation/ ][the bimap data ]] +[[container_adaptor/ ][easy way of adapting containers ]] +[[views/ ][bimap views ]] +[[property_map/ ][support for property map concept ]] +] + +[table folders in each folder +[[name][what is inside?]] +[[ ][class definitions]] +[[support/ ][optional metafunctions and free functions]] +[[detail/ ][things not intended for the user's eyes]] +] + +[endsect] + +[section The student and the mentor] + +[tip It is a good idea to read the original +[@http://h1.ripway.com/mcape/boost/libs/misc/ Boost.Misc SoC proposal] first.] + +[:[^- The discussion starts with Joaquin trying to strip out the "misc" name out of the library -]] + +__JOAQUIN_PHOTO__ + +[*Joaquin] +[:[' +Thinking about it, the unifying principle of MISC containers is perhaps +misleading: certainly all miscs use multi-indexing internally, but this does +not reflect much in the external interface (as it should be, OTOH). So, from +the user's point of view, miscs are entirely heterogeneous beasts. Moreover, +there isn't in your proposal any kind of global facility common to all miscs. +What about dropping the misc principle and working on each container as a +separate library, then? You'd have boost::bimap, boost::mru, etc, and no common +intro to them. This also opens up the possibility to add other containers to +the suite which aren't based on B.MI. What's your stance on this? Do you see a +value in keeping miscs conceptually together? +]] + +__MATIAS_PHOTO__ + +[*Matias] +[:[' +As the original proposal states only two containers (bimap and mru set) both +based in B.MI, it was straight forward to group them together. When I was +writing the SoC proposal I experienced a similar feeling when the two families +begin to grow. As you say, the only common denominator is their internal +implementation. I thought a bit about a more general framework to join this two +families (and other internally related ones) and finally came up with an idea: +Boost.MultiIndex! So I think that it is not a good idea to try to unify the two +families and I voted in favor of get rid of the misc part of boost::misc::bimap +and boost::misc::mru. Anyway, for my SoC application it seems OK to put the +two families in the same project because although from the outside they are +completely unrelated, the work I will have to do in order to build the libraries +will be consistent and what I will learn coding the bimap family will be used +when I start to code the mru family. When the mru family is in place, I will +surely have learnt other things to improve the bimap group. +]] +[:[' +On the other hand, I think it will be useful for the general user to +have at least some document linked in the B.MI documentation that +enumerates the most common cases of uses (a bimap and an mru set for +example) and points where to find clean implementation for this useful +containers. For now, a link to boost::bimap and other one to boost::mru +will suffice. If you think about the title of such a document, +you will probably come up with something like: Common Multi Index +Specialized Containers, and we are back to our misc proposal. +So, to order some ideas: +]] +[:['- A new family of containers that can be accessed by both key will +be created. (boost::bimap)]] +[:['- A new family of time aware containers will see the light. +(boost::mru)]] +[:['- A page can be added to B.MI documentation, titled misc that links +this new libraries.]] +[:[' +This is a clearer framework for the user. They can use a mru container +without hearing about Boost.MultiIndex at all. +And B.MI users will get some of their common containers already +implemented with an STL friendly interface in other libraries. +And as you stated this is more extensible because opens the door to use +other libraries in bimap and mru families than just Boost.MultiIndex +without compromising the more general boost framework. +The word "misc" it is going to disappear from the code and +the documentation of bimap and mru. From now on the only use for it will be to +identify our SoC project. I am thinking in a name for the bimap library. +What about Boost.BidirectionalMap? Ideas? +]] + +[*Joaquin] +[:[' +Yes, Boost.Bimap. In my opinion, bimap is a well known name +in the Boost and even in the C++ community. It sounds and is short. Why not to +vindicate yourself as the owner of this name? +]] + +[^- Then after a week of work -] + +[*Matias] +[:[' +Now that Boost.Bimap is getting some shape, I see that as +you have told me, we must offer a "one_to_many_map" and a "multi_bimap" +as part of the library. The framework I am actually working allowed to +construct this kind of bidirectional maps and it is easy to understand from +the user side. +]] + +[*Joaquin] +[:[' +OK, I am glad we agree on this point. +]] + +[*Matias] +[:[' +With respect to the symmetry of the key access names, I have to +agree that there is not much a difference between the following ones: +]] +[:['- to - from]] +[:['- to - b]] +[:['- 0 - 1]] +[:['- left - right]] +[:[' +In my opinion it is a matter of taste, but left/right sounds more symmetrical than +the others. +]] + +[*Joaquin] +[:[' +I like very much the left/right notation, it is very simple to +remember and it is a lot more symmetrical than to/from. +]] + +[*Matias] +[:[' +At first my idea was to obtain ease of use hiding the B.MI +core, making it more STL-intuitive. Nevertheless I have realized +that B.MI is a lot more coherent and easy to use that I had imagined. This +makes me think again in the problem. In the design that I am coding now, bimap +*is-a* multi_index_container specializes with a data type very comfortable +called bipair, that can be seen like any of the two maps that integrates it +using map views. This scheme has great benefits for users: +]] +[:[' +- If the user already knows B.MI, he can take advantage of the tools that +it provides and that are not present in the STL containers. In addition, in some +cases the use to indices to see the data can be very useful. +]] +[:[' +- If the user does not know anything about B.MI but have an STL framework, +the learning curve is reduced to understand the bimap instantiation and how a +is obtained the desired map view. +]] +[:[' +Another very important benefit holds: All the algorithms done for +B.MI continues to work with Boost.Bimap and if B.MI continues growing, bimap +grow automatically. +]] + +[*Joaquin] +[:[' +Umm... This is an interesting design decision, but +controversial in my opinion. Basically you decide to expose the +implementation of bimap; that has advantages, as you stated, but also +a nonsmall disadvantage: once *you have documented* the implementation, +it is not possible to change it anymore. It is a marriage with B.MI without +the chance of divorce. The other possibility, to hide the implementation and +to duplicate and document the provided functionality, explicitly or +implicitly due to the same characteristics of the implementation, is +of course heavier to maintain, but it gives a degree of freedom to change +the guts of your software if you need to. Do not take this like a frontal +objection, but I think that it is quite important design decision, not only +in the context of bimap but in general. +]] + +[*Matias] +[:[' +You are quite right here. I think we have to choose the hardest +path and hide the B.MI core from the user. I am sending you the first draft of +bimap along with some documentation. +]] + +[^- This completes the second week, the documentation was basically the first +section of this rationale -] + +[*Joaquin] +[:[' +I must confess that I am beginning to like what I see. +I am mathematical by vocation, and when I see symmetry in a formulation +I believe that it is in the right track. +]] + +[*Matias] +[:[' +We are two mathematicians by vocation then. +]] + +[*Joaquin] +[:[' +I think that the part of std::set theory is very clear. +To me, it turns out to me somewhat strange to consider the rank of a map +(values X) like a std::set, but of course the formulation is consistent. +]] + +[*Matias] +[:[' +I like it very much, it can be a little odd at first, but +now that I have get used to it, it is very easy to express in the code my +contrains on the data, and I believe that if somebody reads the code and +sees the bimap instantiation he is not going to have problems understanding +it. Perhaps it is easier to understand it if we use your notation: +ordered_nonunique, unordered_unique, but this goes against our STL facade. +In my opinion the user that comes from STL must have to learn as less as possible. +]] + +[*Joaquin] +[:[' +Considering a relation like a `struct {left, right}` +is clean and clear. If I understand it well, one relation has views of type +`pair{first, second}`, is this correct? +]] + +[*Matias] +[:[' +Yes, I believe that the left/right notation to express symmetry +is great. I believe that to people is going to love it. +]] + +[*Joaquin] +[:[' +OK, perfect. I likes this very much: +]] +[:['- bm.left is compatible with std::map<A,B>]] +[:['- bm.right is compatible with std::map<B,A>]] +[:['- bm is compatible with std::set<relation<A,B>>]] +[:[' +It is elegant and symmetric. I feel good vibrations here. +]] + +[*Matias] +[:[' +Great! +]] + +[*Joaquin] +[:[' +Moving on, the support for N-1, N-N, and hashed index is very easy +to grasp, and it fits well in framework. +However I do not finish to understand very well the "set<relation> constraints" section. +Will you came up with some examples of which is the meaning of the different +cases that you enumerate? +]] + +[*Matias - ] +[:[' +Yes, I mean: +]] +[:['- based on the left]] +[:['- based on the right]] +[:[' +The bimap core must be based on some index of multi index. If the index +of the left is of the type hash, then in fact the main view is going +to be an unordered_set< relation<A,B> >. Perhaps this is not what the user +prefers and he wants to base its main view on the right index. +]] +[:['- set_of_relation ]] +[:['- multiset_of_relation ]] +[:['- unordered_set_of_relation ]] +[:['- unordered_multiset_of_relation ]] +[:[' +However, if both of them are hash indexes, the user may want the main view +to be ordered. As we have a B.MI core this is very easy to support, we just have +to add another index to it. +]] + +[*Joaquin] +[:[' +I understand it now. OK, I do not know if we have to include this +in the first version, is going to be a functionality avalanche! +]] + +[*Matias] +[:[' +The user is not affected by the addition of this functionality, +because by default it will be based on the left index that is a very natural +behaviour. I do not think that this is functionality bloat, but I agree with +you that it is a functionality avalanche. +]] + +[*Joaquin] +[:[' +There are restrictions between the left and right set types +and the possible main view set types. For example if some of the index is +of unique type, then the main view cannot be of type multiset_of_relation. +To the inverse one, if the main view is of type set_of_relation the left and +the right index cannot be of type multi_set. All this subject of the unicity +constrictions and the resulting interactions between indexes is one of the subtle +subjects of B.MI. +]] + +[*Matias] +[:[' +This can be checked at compile time and informed as an error +in compile time. +]] + +[*Joaquin] +[:[' +It can be interesting. +]] + +[^- And right when everything seems to be perfect... - ] + +[*Joaquin] +[:[' +I have some worse news with respect to mutant, it is very a +well designed and manageable class, unfortunately, C++ does not guarantee +layout-compatibility almost in any case. For example, the C++ standard does +not guarantee that the classes `struct{T1 a; T2 b;}` and `struct{T1 b; T2 a;}` +are layout-compatible, and therefore the trick of reinterpret_cast is an +undefined behavior. I am with you in which that in the 100% of the cases +this scheme will really work, but the standard is the standard. If you can +look the layout-compatibility subject in it (http://www.kuzbass.ru/docs/isocpp/). +As you see, sometimes the standard is cruel. Although mutant seems a lost case, +please do not hurry to eliminate it. We will see what can be done for it. +]] + +[*Matias] +[:[' +I read the standard, and you were right about it. Mutant was an implementation +detail. It is a pity because I am sure that it will work perfect in any compiler. +Perhaps the standard becomes more strict some day and mutant returns to life... +We can then try a wrapper around a relation<A,B> that have two references named +first and second that bind to A and B, or B and A. +]] +`` +relation<TA,TB> r; +const_reference_pair<A,B> pba(r); +const_reference_pair<B,A> pbb(r); +`` +[:[' +It is not difficult to code the relation class in this way but two references +are initialized with every access and the use of `pba.first` will be slower +than `r.left` in most compilers. It is very difficult to optimize this kind of +references. +]] + +[*Joaquin] +[:[' +This workaround is not possible, due to technical problems with +the expected behavior of the iterators. If the iterators of bm.left are of +bidirectional type, then standard stated that it have to return an object of type +const value_type& when dereferenced. You will have to return a const_reference_pair +created in the flight, making it impossible to return a reference. +]] + +[*Matias] +[:[' +I understand... I have workaround for that also but surely +the standard will attack me again! We must manage to create the class relation +that responds as we want, the rest of the code will flow from this point. +This clear separation between the relation class and the rest of the library, +is going to help to us to separate the problems and to attack them better. +]] + +[*Joaquin] +[:[' +What workaround? It already pricks my curiosity,I have dedicated +a long time to the subject and I do not find any solution except that we +allow the relation class to occupy more memory. +]] + +[*Matias] +[:[' +We must achieve that the relation<A,B> size equals the pair<A,B> size +if we want this library to be really useful. I was going to write my workaround and +I realized that It does not work. Look at this: +http://www.boost.org/libs/iterator/doc/new-iter-concepts.html +Basically the problem that we are dealing is solved if we based our iterators on +this proposal. The present standard forces that the bidirectional iterators also +are of the type input and output. Using the new concepts there is no inconvenient +in making our iterators "Readable Writable Swappable Bidirectional Traversal". +Therefore the const_reference_pair returns to be valid. +]] + +[*Joaquin] +[:[' +It is correct in the sense that you simply say that +your iterators are less powerful than those of the std::map. It is +not that it is wrong, simply that instead of fixing the problem, you +confess it. +]] + +[*Matias] +[:[' +OK, but in our particular case; What are the benefits +of offering a LValue iterator against a Read Write iterator? +It does not seem to me that it is less powerful in this case. +]] + +[*Joaquin] +[:[' +The main problem with a ReadWrite is that the following thing: +`value_type * p=&(*it);` +fails or stores a transitory direction in p. Is this important in the real life? +I do not know. How frequently you store the direction of the elements of a map? +Perhaps it is not very frequent, since the logical thing is to store the +iterators instead of the directions of the elements. +Let us review our options: +]] +[:[' +1. We used mutant knowing that is not standard, but of course it is +supported in the 100% of the cases. +]] +[:[' +2. We used const_reference_pair and we declared the iterators not LValue. +]] +[:[' +3. We found some trick that still we do not know. I have thus been playing +with unions and things, without much luck. +]] +[:[' +4. We leverage the restriction that views have to support the first, second +notation. If we made this decision, there are several possibilities: +]] +[:[' +''' '''a. The left map has standard semantics first/second while the right map +has the inverse semantics. +]] +[:[' +''' '''b. Instead of first and second we provide first() and second(), with +which the problem is trivial. +]] +[:[' +''' '''c. The map view do not support first/second but left/right as the +father relation +]] +[:[' +5. We solve the problem using more memory than sizeof(pair<A,B>). +]] +[:[' +In any case, I would say that the only really unacceptable option is the last one. +]] + +[*Matias] +[:[' +Lets see. +]] +[:[' +1. I want the "standard compliant" label in the library. +]] +[:[' +2. This is the natural choice, but knowing that there is another option +that always works and it is more efficient is awful. +]] +[:[' +3. I have also tried to play with unions, the problem is that the union members +must be POD types. +]] +[:[' +4. This option implies a big lost to the library. +]] +[:[' +5. Totally agree. +]] +[:[' +I want to add another option to this list. Using metaprogramming, +the relation class checks if the compiler supports the mutant idiom. +If it supports it then it uses it and obtains zero overhead +plus LValue iterators, but if it do not supports it then uses +const_reference_pair and obtains minimum overhead with ReadWrite iterators. +This might be controversial but the advantages that mutant offers are very big +and the truth is that I do not believe that in any actual compiler this idiom is +not supported. This scheme would adjust perfectly to the present standard +since we are not supposing anything. The only drawback here is that although +the mutant approach allows to make LValue iterators we have to degrade they +to Read Write in both cases, because we want that the same code can be +compiled in any standard compliant compiler. +]] + + +[^- Hopefully we find our way out of the problem -] + +[*Joaquin] +[:[' +Changing the subject, I believe that the general concept of hooking data +is good, but I do not like the way you implement it. It has to be easy +to migrate to B.MI to anticipate the case in that Boost.Bimap becomes insufficient. +It is more natural for a B.MI user that the data is accessed without the indirection +of `.data`. I do not know how this can be articulated in your framework. +]] + +[*Matias] +[:[' +I have a technical problem to implement the data_hook in this way. +If the standard would let us use the mutant idiom directly, I can implement it +using multiple inheritance. But as we must use const_reference_pair too, It becomes +impossible for me to support it. We have three options here: +]] +[:[' +1) relation { left, right, data } and pair_view { first, second, data } +]] +[:[' +- This is more intuitive within the bimap framework, since it does not +mix the data with the index, as a table in a data base does, but gives more importance to +the index. +]] +[:[' +- It is not necessary that the user puts the mutable keyword in each member of +the data class. +]] +[:[' +- This moves away just a little bit from B.MI because the model +of it is similar to a table, but it continues to exist a clear path of migration. +]] +[:[' +2) relation { left,right, d1,d2... dn } and pair_view { first, second, data } +]] +[:[' +- The path to B.MI is the one you have proposed. +]] +[:[' +- It is very asymmetric. It is necessary to explain that the views are +handled different that the relation. +]] +[:[' +- The user must place the mutable keyboards in the data class. +]] +[:[' +3) Only relation { left,right, d1,d2... dn } +]] +[:[' +- Simple migration path to B.MI. +]] +[:[' +- You are not able to access the hooked data from the views. +]] +[:[' +My vote goes to the first proposal. +]] + + +[*Joaquin] +[:[' +Yes, the first option is the one that less surprises hold to the user. +I also vote for 1. +]] + +[^- The third week was over -] + +[*Matias] +[:[' +There is still one problem that I have to solve. I need to +know if it is necessary to create a map_view associated to nothing. If +it is necessary there are two options: that it behaves as an empty container or +that it throws an exception or assert when trying to use it. If it is not necessary, +the map_view is going to keep a reference instead of a pointer. +To me, the map_view always must be viewing something. In the case of the iterators +being able to create them empty, makes them easy to use in contexts that require +constructors by default, like being the value_type of a container, but I do not +believe that this is the case of map_view. +]] + +[*Joaquin] +[:[' +How would an empty map_view be useful? My intuition is like yours, +map_view would have to be always associate to something. If we wished to obtain +the semantics "is associated or not" we can use a pointer to a map_view. +]] + +[*Matias] +[:[' +OK, then you agree to that map_views stores a reference instead +of a pointer? +]] + +[*Joaquin] +[:[' +It depends on the semantics you want to give to map_views, and in +concrete to the copy of map_views. +]] +`` +map_view x=...; +map_view y=...; +x=y; +`` +[:[' +What is supposed to do this last line? +]] +[:[' +1. Rebinding of x, that is to say, x points at the same container that y. +]] +[:[' +2. Copy of the underlying container. +]] +[:[' +If you want to implement 1, you cannot use references internally. +If you want to implement 2, it is almost the same to use a reference or a pointer. +]] + +[*Matias] +[:[' +If I want that they behave exactly as std::maps then I must go for 2. +But if I think they as "views" of something, I like 1. The question is complicated. +I add another option: +]] +[:[' +3. Error: operator= is declare as private in boost::bimap::map_view std_container +]] +[:[' +Also What happens with `std_container = view;`? and with `view = std_container;`? +]] + +[endsect] + +[endsect] + + + + diff --git a/libs/bimap/doc/reference.qbk b/libs/bimap/doc/reference.qbk new file mode 100644 index 0000000000..63803be13d --- /dev/null +++ b/libs/bimap/doc/reference.qbk @@ -0,0 +1,64 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section Reference] + +[section Headers] + +The following are the interface headers of Boost.Bimap: + +[*Convenience] + +* "boost/bimap.hpp" ['(includes "boost/bimap/bimap.hpp" and imports the bimap class to boost namespace)] + +[*Container] + +* "boost/bimap/bimap.hpp" ['(includes "boost/bimap/set_of.hpp" and "boost/bimap/unconstrained_set_of.hpp")] + +[*Set Types] + +* "boost/bimap/set_of.hpp" +* "boost/bimap/multiset_of.hpp" +* "boost/bimap/unordered_set_of.hpp" +* "boost/bimap/unordered_multiset_of.hpp" +* "boost/bimap/list_of.hpp" +* "boost/bimap/vector_of.hpp" +* "boost/bimap/unconstrained_set_of.hpp" + +[*Boost Integration] + +* "boost/bimap/support/lambda.hpp" +* "boost/bimap/property_map/set_support.hpp" +* "boost/bimap/property_map/unordered_set_support.hpp" + +A program using Boost.Bimap must therefore include +"boost/bimap/bimap.hpp" and the headers defining the collection types to be used. + +Additional headers allow the integration of Boost.Bimap with other boost libraries, +like Boost.Lambda and Boost.Property_map. + +In order to use the serialization capabilities of Boost.Bimap, the appropriate +Boost.Serialization library module must be linked. Other than that, Boost.Bimap +is a header-only library, requiring no additional object modules. + +[endsect] + +[include reference/bimap.qbk] +[include reference/set_of.qbk] +[include reference/unordered_set_of.qbk] +[include reference/list_of.qbk] +[include reference/vector_of.qbk] +[include reference/unconstrained_set_of.qbk] + +[endsect]
\ No newline at end of file diff --git a/libs/bimap/doc/reference/bimap.qbk b/libs/bimap/doc/reference/bimap.qbk new file mode 100644 index 0000000000..737a11065d --- /dev/null +++ b/libs/bimap/doc/reference/bimap.qbk @@ -0,0 +1,523 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section Bimap Reference] + +[section View concepts] + +`bimap` instantiations comprise two side views and an view of the relation +specified at compile time. Each view allows read-write access to the elements contained +in a definite manner, mathing an STL container signature. + +Views are not isolated objects and so cannot be constructed on their +own; rather they are an integral part of a `bimap`. The name of the view +class implementation proper is never directly exposed to the user, who +has access only to the associated view type specifier. + +Insertion and deletion of elements are always performed through the +appropriate interface of any of the three views of the `bimap`; these +operations do, however, have an impact on all other views as well: for +instance, insertion through a given view may fail because there exists +another view that forbids the operation in order to preserve its +invariant (such as uniqueness of elements). The global operations +performed jointly in the any view can be reduced to six primitives: + +* copying +* insertion of an element +* hinted insertion, where a pre-existing element is suggested in order to improve +the efficiency of the operation +* deletion of an element +* replacement of the value of an element, which may trigger the +rearrangement of this element in one or more views, or may forbid the +replacement +* modification of an element, and its subsequent +rearrangement/banning by the various views + +The last two primitives deserve some further explanation: in order to +guarantee the invariants associated to each view (e.g. some definite +ordering) elements of a `bimap` are not mutable. To overcome this +restriction, the views expose member functions for updating and +modifying, which allows for the mutation of elements in a controlled +fashion. + +[endsect] + +[#complexity_signature_explanation] + +[section Complexity signature] + +Some member functions of a view interface are implemented by global +primitives from the above list. The complexity of these operations thus +depends on all views of a given `bimap`, not just the currently used view. + +In order to establish complexity estimates, a view is characterised by +its complexity signature, consisting of the following associated +functions on the number of elements: + +* `c(n)`: copying +* `i(n)`: insertion +* `h(n)`: hinted insertion +* `d(n)`: deletion +* `r(n)`: replacement +* `m(n)`: modifying + +If the collection type of the relation is `left_based` or `right_based`, and we use +an `l` subscript to denote the left view and an `r` for the right view, then +the insertion of an element in such a container is of complexity +`O(i_l(n)+i_r(n))`, where n is the number of elements. If the collection type of +relation is not side-based, then there is an additional term to add that +is contributed by the collection type of relation view. Using `a` to denote the +above view, the complexity of insertion will now be +`O(i_l(n)+i_r(n)+i_a(n))`. To abbreviate the notation, we adopt the +following definitions: + +* `C(n) = c_l(n) + c_r(n) [ + c_a(n) ]` +* `I(n) = i_l(n) + i_r(n) [ + i_a(n) ]` +* `H(n) = h_l(n) + h_r(n) [ + h_a(n) ]` +* `D(n) = d_l(n) + d_r(n) [ + d_a(n) ]` +* `R(n) = r_l(n) + r_r(n) [ + r_a(n) ]` +* `M(n) = m_l(n) + m_r(n) [ + m_a(n) ]` + +[endsect] + +[section Set type specification] + +Set type specifiers are passed as instantiation arguments to `bimap` and +provide the information needed to incorporate the corresponding views. +Currently, Boost.Bimap provides the collection type specifiers. The ['side collection type] +specifiers define the constraints of the two map views of the +bimap. The ['collection type of relation] specifier defines the main set view +constraints. If `left_based` (the default parameter) or `right_based` is +used, then the collection type of relation will be based on the left or right +collection type correspondingly. + +[table +[[Side collection type ][Collection type of relation ][Include ]] +[[`set_of` ][`set_of_relation` ][`boost/bimap/set_of.hpp` ]] +[[`multiset_of` ][`multiset_of_relation` ][`boost/bimap/multiset_of.hpp` ]] +[[`unordered_set_of` ][`unordered_set_of_relation` ][`boost/bimap/unordered_set_of.hpp` ]] +[[`unordered_multiset_of` ][`unordered_multiset_of_relation`][`boost/bimap/unordered_multiset_of.hpp` ]] +[[`list_of` ][`list_of_relation` ][`boost/bimap/list_of.hpp` ]] +[[`vector_of` ][`vector_of_relation` ][`boost/bimap/vector_of.hpp` ]] +[[`unconstrained_set_of` ][`unconstrained_set_of_relation` ][`boost/bimap/unconstrained_set_of.hpp` ]] +[[ ][`left_based` ][`boost/bimap/bimap.hpp` ]] +[[ ][`right_based` ][`boost/bimap/bimap.hpp` ]] +] + +[endsect] + +[section Tags] + +Tags are just conventional types used as mnemonics for the types stored +in a `bimap`. Boost.Bimap uses the tagged idiom to let the user specify +this tags. + +[endsect] + +[section Header "boost/bimap/bimap.hpp" synopsis] + + namespace boost { + namespace bimaps { + + template< class Type, typename Tag > + struct tagged; + + // bimap template class + + template + < + class LeftCollectionType, class RightCollectionType, + + class AdditionalParameter_1 = detail::not_specified, + class AdditionalParameter_2 = detail::not_specified + > + class bimap ``['- implementation defined { : public SetView } -]`` + { + public: + + // Metadata + + typedef ``['-unspecified-]`` left_tag; + typedef ``['-unspecified-]`` left_map; + + typedef ``['-unspecified-]`` right_tag; + typedef ``['-unspecified-]`` right_map; + + // Shortcuts + // typedef -side-_map::-type- -side-_-type-; + + typedef ``['-unspecified-]`` info_type; + + // Map views + + left_map left; + right_map right; + + // Constructors + + bimap(); + + template< class InputIterator > + bimap(InputIterator first,InputIterator last); + + bimap(const bimap &); + + bimap& operator=(const bimap& b); + + // Projection of iterators + + template< class IteratorType > + left_iterator project_left(IteratorType iter); + + template< class IteratorType > + left_const_iterator project_left(IteratorType iter) const; + + template< class IteratorType > + right_iterator project_right(IteratorType iter); + + template< class IteratorType > + right_const_iterator project_right(IteratorType iter) const; + + template< class IteratorType > + iterator project_up(IteratorType iter); + + template< class IteratorType > + const_iterator project_up(IteratorType iter) const; + + // Support for tags + + template< class Tag > + struct map_by; + + template< class Tag > + map_by<Tag>::type by(); + + template< class Tag > + const map_by<Tag>::type & by() const; + + template< class Tag, class IteratorType > + map_by<Tag>::iterator project(IteratorType iter); + + template< class Tag, class IteratorType > + map_by<Tag>::const_iterator project(IteratorType iter) const + + }; + + + } // namespace bimap + } // namespace boost + + +[/ + // Metafunctions for a bimap + + template< class Tag, class Bimap > struct value_type_by; + template< class Tag, class Bimap > struct key_type_by; + template< class Tag, class Bimap > struct data_type_by; + template< class Tag, class Bimap > struct iterator_type_by; + template< class Tag, class Bimap > struct const_iterator_type_by; + template< class Tag, class Bimap > struct reverse_iterator_type_by; + template< class Tag, class Bimap > struct const_reverse_iterator_type_by; + template< class Tag, class Bimap > struct local_iterator_type_by; + template< class Tag, class Bimap > struct const_local_iterator_type_by; + + // Functions for a bimap + + template<class Tag, class Relation> + result_of::map_by< Tag, Bimap>::type map_by(Bimap &); + + // Metafunctions for a relation + + template< class Tag, class Relation > struct value_type_of; + template< class Tag, class Relation > struct pair_type_by; + + // Functions for a relation + + template<class Tag, class Relation> + result_of::get< Tag, Relation>::type get(Relation &r); + + template<class Tag, class Relation> + result_of::pair_by< Tag, Relation>::type pair_by(Relation &); + +] + +[endsect] + +[section Class template bimap] + +This is the main component of Boost.Bimap. + +[section Complexity] + +In the descriptions of the operations of `bimap`, we adopt the scheme +outlined in the complexity signature section. + +[endsect] + +[section Instantiation types] + +`bimap` is instantiated with the following types: + +# LeftCollectionType and RightCollectionType are collection type specifications +optionally tagged, or any type optionally tagged, in which case that +side acts as a set. +# AdditionalParameter_{1/2} can be any ordered subset of: + * CollectionTypeOfRelation specification + * Allocator + +[endsect] + +[section Nested types] + + left_tag, right_tag + +[: Tags for each side of the bimap. If the user has not specified any tag the + tags default to `member_at::left` and `member_at::right`. +] + + left_key_type, right_key_type + +[: Key type of each side. In a `bimap<A,B> ` `left_key_type` is `A` and + `right_key_type` is `B`. + If there are tags, it is better to use: `Bimap::map_by<Tag>::key_type`. +] + + left_data_type, right_data_type + +[: Data type of each side. In a bimap<A,B> left_key_type is B and + right_key_type is A. + If there are tags, it is better to use: `Bimap::map_by<Tag>::data_type`. +] + + left_value_type, right_value_type + +[: Value type used for the views. + If there are tags, it is better to use: `Bimap::map_by<Tag>::value_type`. +] + + + left_iterator, right_iterator + left_const_iterator, right_const_iterator + +[: Iterators of the views. + If there are tags, it is better to use: + `Bimap::map_by<Tag>::iterator` and + `Bimap::map_by<Tag>::const_iterator` +] + + + left_map, right_map + +[: Map view type of each side. + If there are tags, it is better to use: + `Bimap::map_by<Tag>::type`. +] + +[endsect] + +[section Constructors, copy and assignment] + + bimap(); + +* [*Effects:] Constructs an empty `bimap`. +* [*Complexity:] Constant. + + template<typename InputIterator> + bimap(InputIterator first,InputIterator last); + +* [*Requires: ] `InputIterator` is a model of Input Iterator over elements of +type `relation` or a type convertible to `relation`. last is reachable from `first`. +* [*Effects:] Constructs an empty `bimap` and fills it with the elements in the range +`[first,last)`. Insertion of each element may or may not succeed depending on +acceptance by the collection types of the `bimap`. +* [link complexity_signature_explanation +[*Complexity:]] O(m*H(m)), where m is the number of elements in `[first,last)`. + + + bimap(const bimap & x); + +* [*Effects:] Constructs a copy of x, copying its elements as well as its +internal objects (key extractors, comparison objects, allocator.) +* [*Postconditions:] `*this == x`. The order of the views of the `bimap` +is preserved as well. +* [*Complexity:] O(x.size()*log(x.size()) + C(x.size())) + + + ~bimap() + +* [*Effects:] Destroys the `bimap` and all the elements contained. +The order in which the elements are destroyed is not specified. +* [*Complexity:] O(n). + + + bimap& operator=(const bimap& x); + +* [*Effects:] Replaces the elements and internal objects of the `bimap` +with copies from x. +* [*Postconditions:] `*this==x`. The order on the views of the `bimap` +is preserved as well. +* [*Returns: ] `*this`. +* [*Complexity:] O(n + x.size()*log(x.size()) + C(x.size())). +* [*Exception safety:] Strong, provided the copy and assignment operations +of the types of `ctor_args_list` do not throw. + +[/ + allocator_type get_allocator() const; + +* [*Effects:] Returns a copy of the `allocator_type` object used to construct +the `bimap`. +* [*Complexity:] Constant. +] + +[endsect] + +[#reference_projection_operations] + +[section Projection operations] + +Given a `bimap` with views v1 and v2, we say than an v1-iterator +it1 and an v2-iterator it2 are equivalent if: + +* `it1 == i1.end()` AND `it2 == i2.end()`, +* OR `it1` and `it2` point to the same element. + + + template< class IteratorType > + left_iterator project_left(IteratorType iter); + + template< class IteratorType > + left_const_iterator project_left(IteratorType iter) const; + +* [*Requires:] `IteratorType` is a bimap view iterator. it is a +valid iterator of some view of `*this` (i.e. does not refer to some other +`bimap`.) +* [*Effects:] Returns a left map view iterator equivalent to `it`. +* [*Complexity:] Constant. +* [*Exception safety:] nothrow. + + + template< class IteratorType > + right_iterator project_right(IteratorType iter); + + template< class IteratorType > + right_const_iterator project_right(IteratorType iter) const; + +* [*Requires:] `IteratorType` is a bimap view iterator. it is a +valid iterator of some view of `*this` (i.e. does not refer to some other +`bimap`.) +* [*Effects:] Returns a right map view iterator equivalent to `it`. +* [*Complexity:] Constant. +* [*Exception safety:] nothrow. + + + template< class IteratorType > + iterator project_up(IteratorType iter); + + template< class IteratorType > + const_iterator project_up(IteratorType iter) const; + +* [*Requires:] `IteratorType` is a bimap view iterator. it is a +valid iterator of some view of `*this` (i.e. does not refer to some other +`bimap`.) +* [*Effects:] Returns a collection of relations view iterator equivalent to `it`. +* [*Complexity:] Constant. +* [*Exception safety:] nothrow. + +[endsect] + +[#reference_support_for_used_defined_names] + +[section Support for user defined names] + + template< class Tag > + struct map_by; + +* `map_by<Tag>::type` yields the type of the map view tagged with `Tag`. +`map_by<Tag>::`['-type name-] is the same as `map_by<Tag>::type::`['-type name-]. +* [*Requires: ] `Tag` is a valid user defined name of the bimap. + + + template< class Tag > + map_by<Tag>::type by(); + + template< class Tag > + const map_by<Tag>::type & by() const; + + +* [*Requires: ] `Tag` is a valid user defined name of the bimap. +* [*Effects:] Returns a reference to the map view tagged with `Tag` held by +`*this`. +* [*Complexity:] Constant. +* [*Exception safety:] nothrow. + + + template< class Tag, class IteratorType > + map_by<Tag>::iterator project(IteratorType iter); + + template< class Tag, class IteratorType > + map_by<Tag>::const_iterator project(IteratorType iter) const + +* [*Requires: ] `Tag` is a valid user defined name of the bimap. `IteratorType` +is a bimap view iterator. it is a valid iterator of some view of `*this` +(i.e. does not refer to some other `bimap`.) +* [*Effects:] Returns a reference to the map view tagged with `Tag` held by +`*this`. +* [*Complexity:] Constant. +* [*Exception safety:] nothrow. + + +[endsect] + +[section Serialization] + +A `bimap` can be archived and retrieved by means of __BOOST_SERIALIZATION__. +Boost.Bimap does not expose a public serialisation interface, as this is +provided by Boost.Serialization itself. Both regular and XML archives +are supported. + +Each of the set specifications comprising a given `bimap` contributes its +own preconditions as well as guarantees on the retrieved containers. In describing +these, the following concepts are used. A type `T` is ['serializable] +(resp. XML-serializable) if any object of type `T` can be saved to an output +archive (XML archive) and later retrieved from an input archive (XML archive) +associated to the same storage. If `x`' of type `T` is loaded from the serialization +information saved from another object x, we say that x' is a ['restored copy] of x. +Given a __SGI_BINARY_PREDICATE__ `Pred` over `(T, T)`, and objects `p` and `q` of +type `Pred`, we say that `q` is ['serialization-compatible] with `p` if + +* `p(x,y) == q(x`'`,y`'`)` + +for every `x` and `y` of type `T` and `x`' and `y`' being restored copies of `x` +and `y`, respectively. + +[blurb [*Operation:] saving of a `bimap b` to an output archive +(XML archive) ar.] + +* [*Requires:] Value is serializable (XML-serializable). Additionally, each +of the views of b can impose other requirements. +* [*Exception safety:] Strong with respect to `b`. If an exception is thrown, ar +may be left in an inconsistent state. + +[blurb [*Operation:] loading of a `bimap` m' from an input archive +(XML archive) ar.] + +* [*Requires:] Value is serializable (XML-serializable). Additionally, each of +the views of `b`' can impose other requirements. +* [*Exception safety:] Basic. If an exception is thrown, ar may be left in an +inconsistent state. + +[endsect] +[endsect] + +[endsect]
\ No newline at end of file diff --git a/libs/bimap/doc/reference/list_of.qbk b/libs/bimap/doc/reference/list_of.qbk new file mode 100644 index 0000000000..b8f495ef8d --- /dev/null +++ b/libs/bimap/doc/reference/list_of.qbk @@ -0,0 +1,798 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section list_of Reference] + +[section Header "boost/bimap/list_of.hpp" synopsis] + + namespace boost { + namespace bimaps { + + + template< class KeyType > + struct list_of; + + struct list_of_relation; + + + } // namespace bimap + } // namespace boost + +[endsect] + +[section list_of Views] + +A list_of set view is a std::list signature compatible +interface to the underlying heap of elements contained in a `bimap`. + +If you look the bimap by a side, you will use a map view and if you looked +it as a whole you will be using a set view. + +Elements in a list_of view are by default sorted according to +their order of insertion: this means that new elements inserted through a +different view of the `bimap` are appended to the end of the +list_of view. Additionally, the view allows for free reordering of elements +in the same vein as `std::list` does. Validity of iterators and references to +elements is preserved in all operations. + +There are a number of differences with respect to `std::lists`: + +* list_of views are not +__SGI_ASSIGNABLE__ (like any other view.) +* Unlike as in `std::list`, insertions into a list_of view may fail due to +clashings with other views. This alters the semantics of the operations +provided with respect to their analogues in `std::list`. +* Elements in a list_of view are not mutable, and can only be changed +by means of `replace` and `modify` member functions. + +Having these restrictions into account, list_of views are models of +__SGI_REVERSIBLE_CONTAINER__, __SGI_FRONT_INSERTION_SEQUENCE__ and +__SGI_BACK_INSERTION_SEQUENCE__. +We only provide descriptions of those types and operations that are either +not present in the concepts modeled or do not exactly conform to the +requirements for these types of containers. + + namespace boost { + namespace bimaps { + namespace views { + + template< ``['-implementation defined parameter list-]`` > + class ``['-implementation defined view name-]`` + { + public: + + // types + + typedef ``['-unspecified-]`` value_type; + typedef ``['-unspecified-]`` allocator_type; + typedef ``['-unspecified-]`` reference; + typedef ``['-unspecified-]`` const_reference; + typedef ``['-unspecified-]`` iterator; + typedef ``['-unspecified-]`` const_iterator; + typedef ``['-unspecified-]`` size_type; + typedef ``['-unspecified-]`` difference_type; + typedef ``['-unspecified-]`` pointer; + typedef ``['-unspecified-]`` const_pointer; + typedef ``['-unspecified-]`` reverse_iterator; + typedef ``['-unspecified-]`` const_reverse_iterator; + + typedef ``['-unspecified-]`` info_type; + + // construct/copy/destroy + + this_type & operator=(const this_type & x); + + template< class InputIterator > + void ``[link reference_list_of_assign_iterator_iterator assign]``(InputIterator first, InputIterator last); + + void ``[link reference_list_of_assign_size_value assign]``(size_type n, const value_type & value); + + allocator_type get_allocator() const; + + // iterators + + iterator begin(); + const_iterator begin() const; + + iterator end(); + const_iterator end() const; + + reverse_iterator rbegin(); + const_reverse_iterator rbegin() const; + + reverse_iterator rend(); + const_reverse_iterator rend() const; + + // capacity + + bool empty() const; + + size_type size() const; + + size_type max_size() const; + + void ``[link reference_list_of_resize_size_value resize]``(size_type n, const value_type & x = value_type()); + + // access + + const_reference front() const; + const_reference back() const; + + // modifiers + + std::pair<iterator,bool> ``[link reference_list_of_push_front_value push_front]``(const value_type & x); + void pop_front(); + + std::pair<iterator,bool> ``[link reference_list_of_push_back_value push_back]``(const value_type & x); + void pop_back(); + + std::pair<iterator,bool> ``[link reference_list_of_insert_iterator_value insert]``(iterator position, const value_type & x); + + void ``[link reference_list_of_insert_iterator_size_value insert]``(iterator position, size_type n, const value_type & x); + + template< class InputIterator > + void ``[link reference_list_of_insert_iterator_iterator_iterator insert]``(iterator position, InputIterator first, InputIterator last); + + iterator ``[link reference_list_of_erase_iterator erase]``(iterator position); + iterator ``[link reference_list_of_erase_iterator_iterator erase]``(iterator first, iterator last); + + bool ``[link reference_list_of_replace_iterator_value replace]``(iterator position, const value_type & x); + + // Only in map views + // { + + template< class CompatibleKey > + bool ``[link reference_list_of_replace_key_iterator_key replace_key]``(iterator position, const CompatibleKey & x); + + template< class CompatibleData > + bool ``[link reference_list_of_replace_data_iterator_data replace_data]``(iterator position, const CompatibleData & x); + + template< class KeyModifier > + bool ``[link reference_list_of_modify_key_iterator_modifier modify_key]``(iterator position, KeyModifier mod); + + template< class DataModifier > + bool ``[link reference_list_of_modify_data_iterator_modifier modify_data]``(iterator position, DataModifier mod); + + // } + + + void clear(); + + // list operations + + void ``[link reference_list_of_splice_iterator_this splice]``(iterator position, this_type & x); + void ``[link reference_list_of_splice_iterator_this_iterator splice]``(iterator position, this_type & x, iterator i); + void splice( + iterator position, this_type & x, iterator first, iterator last); + + void ``[link reference_list_of_remove_value remove]``(const value_type & value); + + template< class Predicate > + void ``[link reference_list_of_remove_if_predicate remove_if]``(Predicate pred); + + void ``[link reference_list_of_unique unique]``(); + + template< class BinaryPredicate > + void ``[link reference_list_of_unique_predicate unique]``(BinaryPredicate binary_pred); + + void ``[link reference_list_of_merge_this merge]``(this_type & x); + + template< class Compare > + void ``[link reference_list_of_merge_this_compare merge]``(this_type & x,Compare comp); + + void ``[link reference_list_of_sort sort]``(); + + template< class Compare > + void ``[link reference_list_of_sort_compare sort]``(Compare comp); + + void ``[link reference_list_of_reverse reverse]``(); + + // rearrange operations + + void relocate(iterator position, iterator i); + void relocate(iterator position, iterator first, iterator last); + + } + + // view comparison + + bool operator==(const this_type & v1, const this_type & v2 ); + bool operator< (const this_type & v1, const this_type & v2 ); + bool operator!=(const this_type & v1, const this_type & v2 ); + bool operator> (const this_type & v1, const this_type & v2 ); + bool operator>=(const this_type & v1, const this_type & v2 ); + bool operator<=(const this_type & v1, const this_type & v2 ); + + } // namespace views + } // namespace bimap + } // namespace boost + +In the case of a `bimap< list_of<Left>, ... >` + +In the set view: + + typedef signature-compatible with relation< Left, ... > key_type; + typedef signature-compatible with relation< Left, ... > value_type; + +In the left map view: + + typedef Left key_type; + typedef ... data_type; + + typedef signature-compatible with std::pair< Left, ... > value_type; + +In the right map view: + + typedef ... key_type; + typedef Left data_type; + + typedef signature-compatible with std::pair< ... , Left > value_type; + + +[#list_of_complexity_signature] + +[section Complexity signature] + +Here and in the descriptions of operations of `list_of` views, we adopt the +scheme outlined in the +[link complexity_signature_explanation complexity signature section]. +The complexity signature of a `list_of` view is: + +* copying: `c(n) = n * log(n)`, +* insertion: `i(n) = 1` (constant), +* hinted insertion: `h(n) = 1` (constant), +* deletion: `d(n) = 1` (constant), +* replacement: `r(n) = 1` (constant), +* modifying: `m(n) = 1` (constant). + +[endsect] + +[section Instantiation types] + +`list_of` views are instantiated internally to `bimap` and specified +by means of the collection type specifiers and the bimap itself. +Instantiations are dependent on the following types: + +* `Value` from `list_of`, +* `Allocator` from `bimap`, + +[endsect] + +[section Constructors, copy and assignment] + +As explained in the view concepts section, views do not have public +constructors or destructors. Assignment, on the other hand, is provided. + + this_type & operator=(const this_type & x); + +* [*Effects: ] `a = b;` +where a and b are the `bimap` objects to which `*this` and `x` belong, +respectively. +* [*Returns: ] `*this`. + + +[#reference_list_of_assign_iterator_iterator] + + template< class InputIterator > + void assign(InputIterator first, InputIterator last); + +* [*Requires: ] `InputIterator` is a model of __SGI_INPUT_ITERATOR__ over elements of type +`value_type` or a type convertible to `value_type`. first and last are not +iterators into any views of the `bimap` to which this view belongs. +`last` is reachable from `first`. +* [*Effects: ] `clear(); insert(end(),first,last);` + + +[#reference_list_of_assign_size_value] + + void assign(size_type n, const value_type & value); + +* [*Effects: ] `clear(); for(size_type i = 0; i < n ; ++n) push_back(v);` + + +[endsect] + +[section Capacity operations] + +[#reference_list_of_resize_size_value] + + void resize(size_type n,const value_type& x=value_type()); + +* [*Effects: ] +`if( n > size() ) insert(end(), n - size(), x);` +`else if( n < size() ) {` +` iterator it = begin();` +` std::advance(it, n);` +` erase(it, end());` +`}` +* [*Note:] If an expansion is requested, the size of the view is not +guaranteed to be n after this operation (other views may ban insertions.) + +[endsect] + +[section Modifiers] + +[#reference_list_of_push_front_value] + + std::pair<iterator,bool> push_front(const value_type& x); + +* [*Effects:] Inserts `x` at the beginning of the sequence if no other views +of the `bimap` bans the insertion. +* [*Returns:] The return value is a pair `p`. `p.second` is `true` if and only +if insertion took place. On successful insertion, `p.first` points to the element +inserted; otherwise, `p.first` points to an element that caused the insertion to be +banned. Note that more than one element can be causing insertion not to be allowed. +* [link list_of_complexity_signature [*Complexity:]] O(I(n)). +* [*Exception safety:] Strong. + + +[#reference_list_of_push_back_value] + + std::pair<iterator,bool> push_back(const value_type & x); + +* [*Effects:] Inserts `x` at the end of the sequence if no other views of the +`bimap` bans the insertion. +* [*Returns:] The return value is a pair `p`. `p.second` is `true` if and only if +insertion took place. On successful insertion, `p.first` points to the element +inserted; otherwise, `p.first` points to an element that caused the insertion +to be banned. Note that more than one element can be causing insertion not +to be allowed. +* [link list_of_complexity_signature [*Complexity:]] O(I(n)). +* [*Exception safety:] Strong. + + +[#reference_list_of_insert_iterator_value] + + std::pair<iterator,bool> insert(iterator position, const value_type & x); + +* [*Requires: ] `position` is a valid `iterator` of the view. +* [*Effects:] Inserts `x` before position if insertion is allowed by all other +views of the `bimap`. +* [*Returns:] The return value is a pair `p`. `p.second` is `true` if and only if +insertion took place. On successful insertion, `p.first` points to the element +inserted; otherwise, `p.first` points to an element that caused the insertion +to be banned. Note that more than one element can be causing insertion not +to be allowed. +* [link list_of_complexity_signature +[*Complexity:]] O(I(n)). +* [*Exception safety:] Strong. + + +[#reference_list_of_insert_iterator_size_value] + + void insert(iterator position, size_type n, const value_type & x); + +* [*Requires: ] `position` is a valid `iterator` of the view. +* [*Effects: ] `for(size_type i = 0; i < n; ++i) insert(position, x);` + + +[#reference_list_of_insert_iterator_iterator_iterator] + + template< class InputIterator> + void insert(iterator position,InputIterator first,InputIterator last); + +* [*Requires: ] `position` is a valid `iterator` of the view. `InputIterator` is +a model of __SGI_INPUT_ITERATOR__ over elements of type `value_type`. +`first` and `last` are not iterators into any view of the +`bimap` to which this view belongs. `last` is reachable from `first`. +* [*Effects: ] `while(first != last) insert(position, *first++);` +* [link list_of_complexity_signature +[*Complexity:]] O(m*I(n+m)), where m is the number of elements in `[first,last)`. +* [*Exception safety:] Basic. + + +[#reference_list_of_erase_iterator] + + iterator erase(iterator position); + +* [*Requires: ] `position` is a valid dereferenceable `iterator` of the view. +* [*Effects:] Deletes the element pointed to by `position`. +* [*Returns:] An iterator pointing to the element immediately following the +one that was deleted, or `end()` if no such element exists. +* [link list_of_complexity_signature +[*Complexity:]] O(D(n)). +* [*Exception safety:] nothrow. + + +[#reference_list_of_erase_iterator_iterator] + + iterator erase(iterator first, iterator last); + +* [*Requires: ] `[first,last)` is a valid range of the view. +* [*Effects:] Deletes the elements in `[first,last)`. +* [*Returns: ] `last`. +* [link list_of_complexity_signature +[*Complexity:]] O(m*D(n)), where m is the number of elements in `[first,last)`. +* [*Exception safety:] nothrow. + + +[#reference_list_of_replace_iterator_value] + + bool replace(iterator position,const value_type& x); + +* [*Requires: ] `position` is a valid dereferenceable iterator of the view. +* [*Effects:] Assigns the value `x` to the element pointed to by `position` into +the `bimap` to which the view belongs if replacing is allowed by +all other views of the `bimap`. +* [*Postconditions:] Validity of `position` is preserved in all cases. +* [*Returns: ] `true` if the replacement took place, `false` otherwise. +* [link list_of_complexity_signature +[*Complexity:]] O(R(n)). +* [*Exception safety:] Strong. If an exception is thrown by some user-provided +operation the `bimap` to which the view belongs remains in its +original state. + + +[#reference_list_of_replace_key_iterator_key] + + template< class CompatibleKey > + bool replace_key(iterator position, const CompatibleKey & x); + +* [*Requires: ] `position` is a valid dereferenceable iterator of the set view. +`CompatibleKey` can be assigned to `key_type`. +* [*Effects:] Assigns the value `x` to `e.first`, where `e` is the element pointed +to by `position` into the `bimap` to which the set view belongs if replacing is allowed by +all other views of the `bimap`. +* [*Postconditions:] Validity of position is preserved in all cases. +* [*Returns: ] `true` if the replacement took place, `false` otherwise. +* [link list_of_complexity_signature +[*Complexity:]] O(R(n)). +* [*Exception safety:] Strong. If an exception is thrown by some user-provided +operation, the `bimap` to which the set view belongs remains in +its original state. + + +[#reference_list_of_replace_data_iterator_data] + + template< class CompatibleData > + bool replace_data(iterator position, const CompatibleData & x); + +* [*Requires: ] `position` is a valid dereferenceable iterator of the set view. +`CompatibleKey` can be assigned to `data_type`. +* [*Effects:] Assigns the value `x` to `e.second`, where `e` is the element pointed +to by `position` into the `bimap` to which the set view belongs if replacing is allowed by +all other views of the `bimap`. +* [*Postconditions:] Validity of position is preserved in all cases. +* [*Returns: ] `true` if the replacement took place, `false` otherwise. +* [link list_of_complexity_signature +[*Complexity:]] O(R(n)). +* [*Exception safety:] Strong. If an exception is thrown by some user-provided +operation, the `bimap` to which the set view belongs remains in +its original state. + + +[#reference_list_of_modify_key_iterator_modifier] + + template< class KeyModifier > + bool modify_key(iterator position, KeyModifier mod); + +* [*Requires: ] `KeyModifier` is a model of __SGI_UNARY_FUNCTION__ accepting arguments of +type: `key_type&`; `position` is a valid dereferenceable iterator of the view. +* [*Effects:] Calls `mod(e.first)` where e is the element pointed to by position and +rearranges `*position` into all the views of the `bimap`. +If the rearrangement fails, the element is erased. +It is successful if the rearrangement is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of `position` is preserved if the operation succeeds. +* [*Returns: ] `true` if the operation succeeded, `false` otherwise. +* [link list_of_complexity_signature +[*Complexity:]] O(M(n)). +* [*Exception safety:] Basic. If an exception is thrown by some user-provided +operation (except possibly mod), then the element pointed to by position is erased. +* [*Note:] Only provided for map views. + + +[#reference_list_of_modify_data_iterator_modifier] + + template< class DataModifier > + bool modify_data(iterator position, DataModifier mod); + +* [*Requires: ] `DataModifier` is a model of __SGI_UNARY_FUNCTION__ accepting arguments of +type: `data_type&`; `position` is a valid dereferenceable iterator of the view. +* [*Effects:] Calls `mod(e.second)` where e is the element pointed to by position and +rearranges `*position` into all the views of the `bimap`. +If the rearrangement fails, the element is erased. +It is successful if the rearrangement is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of `position` is preserved if the operation succeeds. +* [*Returns: ] `true` if the operation succeeded, `false` otherwise. +* [link list_of_complexity_signature +[*Complexity:]] O(M(n)). +* [*Exception safety:] Basic. If an exception is thrown by some user-provided +operation (except possibly mod), then the element pointed to by position is erased. +* [*Note:] Only provided for map views. + +[/ +[#reference_list_of_modify_iterator_modifier] + + template< class Modifier > + bool modify(iterator position,Modifier mod); + +* [*Requires: ] `Modifier` is a model of __SGI_BINARY_FUNCTION__ accepting arguments of +type: `first_type&` and `second_type&` for ['Map View] and `left_type&` and `right_type&` +for ['Set View]. `position` is a valid dereferenceable iterator of the view. +* [*Effects:] Calls `mod(e.first,e.second)` for ['Map View] or calls `mod(e.left,e.right)` +for ['Set View] where `e` is the element pointed to by `position` and +rearranges `*position` into all the views of the `bimap`. +Rearrangement on `list_of` views does not change the position of the element +with respect to the view; rearrangement on other views may or might not suceed. +If the rearrangement fails, the element is erased. +* [*Postconditions:] Validity of `position` is preserved if the operation succeeds. +* [*Returns: ] `true` if the operation succeeded, `false` otherwise. +* [link list_of_complexity_signature +[*Complexity:]] O(M(n)). +* [*Exception safety:] Basic. If an exception is thrown by some user-provided +operation (except possibly `mod`), then the element pointed to by position is erased. +] + +[endsect] + +[section List operations] + +`list_of` views provide the full set of list operations found in `std::list`; +the semantics of these member functions, however, differ from that of `std::list` +in some cases as insertions might not succeed due to banning by other views. +Similarly, the complexity of the operations may depend on the other views +belonging to the same `bimap`. + + +[#reference_list_of_splice_iterator_this] + + void splice(iterator position, this_type & x); + +* [*Requires: ] `position` is a valid iterator of the view. `&x!=this`. +* [*Effects:] Inserts the contents of `x` before position, in the same order as +they were in `x`. Those elements successfully inserted are erased from `x`. +* [link list_of_complexity_signature +[*Complexity:]] O(`x.size()`*I(n+`x.size()`) + `x.size()`*D(`x.size()`)). +* [*Exception safety:] Basic. + + +[#reference_list_of_splice_iterator_this_iterator] + + void splice(iterator position, this_type & x,iterator i); + +* [*Requires: ] `position` is a valid iterator of the view. `i` is a valid +dereferenceable iterator `x`. +* [*Effects:] Inserts the element pointed to by `i` before position: if insertion +is successful, the element is erased from `x`. In the special case `&x==this`, +no copy or deletion is performed, and the operation is always successful. If +`position==i`, no operation is performed. +* [*Postconditions:] If `&x==this`, no iterator or reference is invalidated. +* [link list_of_complexity_signature +[*Complexity:]] If `&x==this`, constant; otherwise O(I(n) + D(n)). +* [*Exception safety:] If `&x==this`, nothrow; otherwise, strong. + + +[#reference_list_of_splice_iterator_this_iterator_iterator] + + void splice(iterator position, this_type & x, iterator first, iterator last); + +* [*Requires: ] `position` is a valid iterator of the view. `first` and `last` are +valid iterators of `x`. last is reachable from `first`. position is not in the +range `[first,last)`. +* [*Effects:] For each element in the range `[first,last)`, insertion is tried +before position; if the operation is successful, the element is erased from x. +In the special case `&x==this`, no copy or deletion is performed, and insertions +are always successful. +* [*Postconditions:] If `&x==this`, no iterator or reference is invalidated. +* [link list_of_complexity_signature +[*Complexity:]] If `&x==this`, constant; otherwise O(m*I(n+m) + m*D(x.size())) +where m is the number of elements in `[first,last)`. +* [*Exception safety:] If `&x==this`, nothrow; otherwise, basic. + + +[#reference_list_of_remove_value] + + void remove(const value_type & value); + +* [*Effects:] Erases all elements of the view which compare equal to `value`. +* [link list_of_complexity_signature +[*Complexity:]] O(n + m*D(n)), where m is the number of elements erased. +* [*Exception safety:] Basic. + + +[#reference_list_of_remove_if_predicate] + + template< class Predicate > + void remove_if(Predicate pred); + +* [*Effects:] Erases all elements `x` of the view for which `pred(x)` holds. +* [link list_of_complexity_signature +[*Complexity:]] O(n + m*D(n)), where m is the number of elements erased. +* [*Exception safety:] Basic. + + +[#reference_list_of_unique] + + void unique(); + +* [*Effects:] Eliminates all but the first element from every consecutive +group of equal elements referred to by the iterator `i` in the range +`[first+1,last)` for which `*i==*(i-1)`. +* [link list_of_complexity_signature +[*Complexity:]] O(n + m*D(n)), where m is the number of elements erased. +* [*Exception safety:] Basic. + + +[#reference_list_of_unique_predicate] + + template< class BinaryPredicate > + void unique(BinaryPredicate binary_pred); + +* [*Effects:] Eliminates all but the first element from every consecutive +group of elements referred to by the iterator i in the range \[first+1,last) +for which `binary_pred(*i,*(i-1))` holds. +* [link list_of_complexity_signature +[*Complexity:]] O(n + m*D(n)), where m is the number of elements erased. +* [*Exception safety:] Basic. + + +[#reference_list_of_merge_this] + + void merge(this_type & x); + +* [*Requires: ] `std::less<value_type>` is a __SGI_STRICT_WEAK_ORDERING__ over `value_type`. +Both the view and `x` are sorted according to `std::less<value_type>`. +* [*Effects:] Attempts to insert every element of `x` into the corresponding +position of the view (according to the order). Elements successfully inserted +are erased from `x`. The resulting sequence is stable, i.e. equivalent elements +of either container preserve their relative position. In the special case +`&x==this`, no operation is performed. +* [*Postconditions:] Elements in the view and remaining elements in `x` are sorted. +Validity of iterators to the view and of non-erased elements of `x` references +is preserved. +* [link list_of_complexity_signature +[*Complexity:]] If `&x==this`, constant; otherwise +O(n + `x.size()`*I(n+`x.size()`) + `x.size()`*D(`x.size()`)). +* [*Exception safety:] If `&x==this`, nothrow; otherwise, basic. + + +[#reference_list_of_merge_this_compare] + + template< class Compare > + void merge(this_type & x, Compare comp); + +* [*Requires:] Compare is a __SGI_STRICT_WEAK_ORDERING__ over `value_type`. Both the view +and `x` are sorted according to `comp`. +* [*Effects:] Attempts to insert every element of `x` into the corresponding position +of the view (according to `comp`). Elements successfully inserted are erased from `x`. +The resulting sequence is stable, i.e. equivalent elements of either container preserve +their relative position. In the special case `&x==this`, no operation is performed. +* [*Postconditions:] Elements in the view and remaining elements in `x` are sorted +according to `comp`. Validity of iterators to the view and of non-erased elements +of `x` references is preserved. +* [link list_of_complexity_signature +[*Complexity:]] If `&x==this`, constant; +otherwise O(n + `x.size()`*I(n+`x.size()`) + `x.size()`*D(`x.size()`)). +* [*Exception safety:] If `&x==this`, nothrow; otherwise, basic. + + +[#reference_list_of_sort] + + void sort(); + +* [*Requires: ] `std::less<value_type>` is a __SGI_STRICT_WEAK_ORDERING__ over value_type. +* [*Effects:] Sorts the view according to `std::less<value_type>`. The sorting is stable, +i.e. equivalent elements preserve their relative position. +* [*Postconditions:] Validity of iterators and references is preserved. +* [*Complexity:] O(n*log(n)). +* [*Exception safety:] nothrow if `std::less<value_type>` does not throw; otherwise, basic. + + +[#reference_list_of_sort_compare] + + template< typename Compare > + void sort(Compare comp); + +* [*Requires:] Compare is a __SGI_STRICT_WEAK_ORDERING__ over value_type. +* [*Effects:] Sorts the view according to comp. The sorting is stable, i.e. equivalent +elements preserve their relative position. +* [*Postconditions:] Validity of iterators and references is preserved. +* [*Complexity:] O(n*log(n)). +* [*Exception safety:] nothrow if comp does not throw; otherwise, basic. + + +[#reference_list_of_reverse] + + void reverse(); + +* [*Effects:] Reverses the order of the elements in the view. +* [*Postconditions:] Validity of iterators and references is preserved. +* [*Complexity:] O(n). +* [*Exception safety:] nothrow. + + +[endsect] + +[section Rearrange operations] + +These operations, without counterpart in `std::list` (although splice provides +partially overlapping functionality), perform individual and global repositioning +of elements inside the index. + + +[#reference_list_of_relocate_iterator_iterator] + + void relocate(iterator position, iterator i); + +* [*Requires: ] `position` is a valid iterator of the view. `i` is a valid +dereferenceable iterator of the view. +* [*Effects:] Inserts the element pointed to by `i` before `position`. +If `position==i`, no operation is performed. +* [*Postconditions:] No iterator or reference is invalidated. +* [*Complexity:] Constant. +* [*Exception safety:] nothrow. + + +[#reference_list_of_relocate_iterator_iterator_iterator] + + void relocate(iterator position, iterator first, iterator last); + +* [*Requires: ] `position` is a valid iterator of the view. `first` and `last` are +valid iterators of the view. `last` is reachable from `first`. `position` is not +in the range `[first,last)`. +* [*Effects:] The range of elements `[first,last)` is repositioned just before +`position`. +* [*Postconditions:] No iterator or reference is invalidated. +* [*Complexity:] Constant. +* [*Exception safety:] nothrow. + + +[endsect] + +[section Serialization] + +Views cannot be serialized on their own, but only as part of the +`bimap` into which they are embedded. In describing the additional +preconditions and guarantees associated to `list_of` views with respect to +serialization of their embedding containers, we use the concepts defined in the +`bimap` serialization section. + +[blurb [*Operation:] saving of a `bimap` b to an output archive +(XML archive) ar.] + +* [*Requires:] No additional requirements to those imposed by the container. + + +[blurb [*Operation:] loading of a `bimap` b' from an input archive +(XML archive) ar.] + +* [*Requires:] No additional requirements to those imposed by the container. +[*Postconditions:] On successful loading, each of the elements of +`[begin(), end())` +is a restored copy of the corresponding element in +`[m.get<i>().begin(), m.get<i>().end())`, +where `i` is the position of the `list_of` view in the container. + + +[blurb [*Operation:] saving of an `iterator` or `const_iterator` it to an output +archive (XML archive) ar.] + +* [*Requires: ] `it` is a valid iterator of the view. The associated +`bimap` has been previously saved. + + +[blurb [*Operation:] loading of an `iterator` or `const_iterator it`' from an input +archive (XML archive) ar.] + +* [*Postconditions:] On successful loading, if it was dereferenceable then `*it`' is the +restored copy of `*it`, otherwise `it`'` == end()`. +* [*Note:] It is allowed that `it` be a `const_iterator` and the restored `it`' an iterator, +or viceversa. + + +[endsect] +[endsect] + + +[endsect] diff --git a/libs/bimap/doc/reference/set_of.qbk b/libs/bimap/doc/reference/set_of.qbk new file mode 100644 index 0000000000..543a6af227 --- /dev/null +++ b/libs/bimap/doc/reference/set_of.qbk @@ -0,0 +1,935 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section set_of Reference] + +[section Header "boost/bimap/set_of.hpp" synopsis] + + namespace boost { + namespace bimaps { + + + template + < + class KeyType, + class KeyCompare = std::less< KeyType > + > + struct set_of; + + + template + < + class KeyCompare = std::less< _relation > + > + struct set_of_relation; + + + } // namespace bimap + } // namespace boost + + +[endsect] + +[section Header "boost/bimap/multiset_of.hpp" synopsis] + + + namespace boost { + namespace bimaps { + + + template + < + class KeyType, + class KeyCompare = std::less< KeyType > + > + struct multiset_of; + + + template + < + class KeyCompare = std::less< _relation > + > + struct multiset_of_relation; + + + } // namespace bimap + } // namespace boost + + +[endsect] + + +[section Collection type specifiers set_of and multiset_of] + +These collection type specifiers allow for insertion of sets disallowing or +allowing duplicate elements, respectively. The syntaxes of `set_of` and +`multiset_of` coincide, so they are described together. + +[endsect] + + +[section \[multi\]set_of Views] + +A \[multi\]set_of set view is a std::\[multi\]set signature-compatible +interface to the underlying heap of elements contained in a `bimap`. + +There are two variants: set_of, which does not allow duplicate elements +(with respect to its associated comparison predicate) and multiset_of, +which does accept those duplicates. The interface of these two variants +is largely the same, so they are documented together with their +differences explicitly noted where they exist. + +If you look the bimap from a side, you will use a map view, and if you +look at it as a whole, you will be using a set view. + + + + namespace boost { + namespace bimaps { + namespace views { + + template< ``['-implementation defined parameter list-]`` > + class ``['-implementation defined view name-]`` + { + public: + + typedef ``['-unspecified-]`` key_type; + typedef ``['-unspecified-]`` value_type; + typedef ``['-unspecified-]`` key_compare; + typedef ``['-unspecified-]`` value_compare; + typedef ``['-unspecified-]`` allocator_type; + typedef ``['-unspecified-]`` reference; + typedef ``['-unspecified-]`` const_reference; + typedef ``['-unspecified-]`` iterator; + typedef ``['-unspecified-]`` const_iterator; + typedef ``['-unspecified-]`` size_type; + typedef ``['-unspecified-]`` difference_type; + typedef ``['-unspecified-]`` pointer; + typedef ``['-unspecified-]`` const_pointer; + typedef ``['-unspecified-]`` reverse_iterator; + typedef ``['-unspecified-]`` const_reverse_iterator; + + typedef ``['-unspecified-]`` info_type; + + this_type & operator=(const this_type & x); + + allocator_type get_allocator() const; + + // iterators + + iterator begin(); + const_iterator begin() const; + + iterator end(); + const_iterator end() const; + + reverse_iterator rbegin(); + const_reverse_iterator rbegin() const; + + reverse_iterator rend(); + const_reverse_iterator rend() const; + + // capacity + + bool empty() const; + + size_type size() const; + + size_type max_size() const; + + // modifiers + + std::pair<iterator,bool> ``[link reference_set_of_insert_value insert]``(const value_type & x); + + iterator ``[link reference_set_of_insert_iterator_value insert]``(iterator position, const value_type & x); + + template< class InputIterator> + void ``[link reference_set_of_insert_iterator_iterator insert]``(InputIterator first, InputIterator last); + + iterator ``[link reference_set_of_erase_iterator erase]``(iterator position); + + template< class CompatibleKey > + size_type ``[link reference_set_of_erase_key erase]``(const CompatibleKey & x); + + iterator ``[link reference_set_of_erase_iterator_iterator erase]``(iterator first, iterator last); + + bool ``[link reference_set_of_replace_iterator_value replace]``(iterator position, const value_type& x); + + // Only in map views + // { + + template< class CompatibleKey > + bool ``[link reference_set_of_replace_key_iterator_key replace_key]``(iterator position, const CompatibleKey & x); + + template< class CompatibleData > + bool ``[link reference_set_of_replace_data_iterator_data replace_data]``(iterator position, const CompatibleData & x); + + template< class KeyModifier > + bool ``[link reference_set_of_modify_key_iterator_modifier modify_key]``(iterator position, KeyModifier mod); + + template< class DataModifier > + bool ``[link reference_set_of_modify_data_iterator_modifier modify_data]``(iterator position, DataModifier mod); + + // } + + void swap(this_type & x); + + void clear(); + + // observers + + key_compare key_comp() const; + + value_compare value_comp() const; + + // set operations + + template< class CompatibleKey > + iterator ``[link reference_set_of_find_key find]``(const CompatibleKey & x); + + template< class CompatibleKey > + const_iterator ``[link reference_set_of_find_key find]``(const CompatibleKey & x) const; + + + template< class CompatibleKey > + size_type ``[link reference_set_of_count_key count]``(const CompatibleKey & x) const; + + + template< class CompatibleKey > + iterator ``[link reference_set_of_lower_bound_key lower_bound]``(const CompatibleKey & x); + + template< class CompatibleKey > + const_iterator ``[link reference_set_of_lower_bound_key lower_bound]``(const CompatibleKey & x) const; + + + template< class CompatibleKey > + iterator ``[link reference_set_of_upper_bound_key upper_bound]``(const CompatibleKey & x); + + template< class CompatibleKey > + const_iterator ``[link reference_set_of_upper_bound_key upper_bound]``(const CompatibleKey & x) const; + + + template< class CompatibleKey > + std::pair<iterator,iterator> + ``[link reference_set_of_equal_range_key equal_range]``(const CompatibleKey & x); + + template< class CompatibleKey > + std::pair<const_iterator,const_iterator> + ``[link reference_set_of_equal_range_key equal_range]``(const CompatibleKey & x) const; + + // Only in maps views + // { + + template< class LowerBounder, class UpperBounder> + std::pair<iterator,iterator> ``[link reference_set_of_range_lower_upper range]``( + LowerBounder lower, UpperBounder upper); + + template< class LowerBounder, class UpperBounder> + std::pair<const_iterator,const_iterator> ``[link reference_set_of_range_lower_upper range]``( + LowerBounder lower, UpperBounder upper) const; + + typedef ``['-unspecified-]`` data_type; + + // Only in for `set_of` collection type + // { + + template< class CompatibleKey > + const data_type & ``[link reference_set_of_at_key_const at]``(const CompatibleKey & k) const; + + // Only if the other collection type is mutable + // { + + template< class CompatibleKey > + data_type & ``[link reference_set_of_operator_bracket_key operator\[\]]``(const CompatibleKey & k); + + template< class CompatibleKey > + data_type & ``[link reference_set_of_at_key at]``(const CompatibleKey & k); + + // } + + // Only if info_hook is used + // { + + template< class CompatibleKey > + info_type & ``[link reference_set_of_info_at_key info_at]``(const CompatibleKey & k); + + template< class CompatibleKey > + const info_type & ``[link reference_set_of_info_at_key info_at]``(const CompatibleKey & k) const; + + // } + + // } + + // } + }; + + // view comparison + + bool operator==(const this_type & v1, const this_type & v2 ); + bool operator< (const this_type & v1, const this_type & v2 ); + bool operator!=(const this_type & v1, const this_type & v2 ); + bool operator> (const this_type & v1, const this_type & v2 ); + bool operator>=(const this_type & v1, const this_type & v2 ); + bool operator<=(const this_type & v1, const this_type & v2 ); + + } // namespace views + } // namespace bimap + } // namespace boost + + + +[/ Functions that may be implemented some day + + template< class Modifier> + bool ``[link reference_set_of_modify_iterator_modifier modify]``(iterator position, Modifier mod); + + template< class CompatibleKey, class CompatibleCompare > + iterator find(const CompatibleKey & x, + const CompatibleCompare & comp); + + template< class CompatibleKey, class CompatibleCompare > + const_iterator find(const CompatibleKey & x, + const CompatibleCompare & comp) const; + + template< class CompatibleKey, class CompatibleCompare > + size_type count(const CompatibleKey & x, + const CompatibleCompare & comp) const; + + template< class CompatibleKey, class CompatibleCompare > + iterator lower_bound(const CompatibleKey & x, + const CompatibleCompare & comp); + + template< class CompatibleKey, class CompatibleCompare > + const_iterator lower_bound(const CompatibleKey & x, + const CompatibleCompare & comp) const; + + template< class CompatibleKey, class CompatibleCompare > + iterator upper_bound(const CompatibleKey & x, + const CompatibleCompare & comp); + + template< class CompatibleKey, class CompatibleCompare > + const_iterator upper_bound(const CompatibleKey & x, + const CompatibleCompare & comp) const; + + template< class CompatibleKey, class CompatibleCompare > + std::pair<iterator,iterator> equal_range( + const CompatibleKey & x, const CompatibleCompare & comp); + + template< class CompatibleKey, class CompatibleCompare > + std::pair<const_iterator,const_iterator> equal_range( + const CompatibleKey & x, const CompatibleCompare & comp) const; + +] + + +In the case of a `bimap< {multi}set_of<Left>, ... >` + +In the set view: + + typedef signature-compatible with relation< Left, ... > key_type; + typedef signature-compatible with relation< const Left, ... > value_type; + +In the left map view: + + typedef Left key_type; + typedef ... data_type; + + typedef signature-compatible with std::pair< const Left, ... > value_type; + +In the right map view: + + typedef ... key_type; + typedef Left data_type; + + typedef signature-compatible with std::pair< ... ,const Left > value_type; + + +[#set_of_complexity_signature] + +[section Complexity signature] + +Here and in the descriptions of operations of this view, we adopt the +scheme outlined in the [link complexity_signature_explanation complexity signature section]. +The complexity signature of \[multi\]set_of view is: + +* copying: `c(n) = n * log(n)`, +* insertion: `i(n) = log(n)`, +* hinted insertion: `h(n) = 1` (constant) if the hint element precedes the point of +insertion, `h(n) = log(n)` otherwise, +* deletion: `d(n) = 1` (amortized constant), +* replacement: `r(n) = 1` (constant) if the element position does not change, +`r(n) = log(n)` otherwise, +* modifying: `m(n) = 1` (constant) if the element position does not change, +`m(n) = log(n)` otherwise. + +[endsect] + +[section Instantiation types] + +Set views are instantiated internally to a `bimap`. +Instantiations are dependent on the following types: + +* `Value` from the set specifier, +* `Allocator` from `bimap`, +* `Compare` from the set specifier. + +`Compare` is a __SGI_STRICT_WEAK_ORDERING__ on elements of `Value`. + +[endsect] + +[section Constructors, copy and assignment] + +Set views do not have public constructors or destructors. +Assignment, on the other hand, is provided. + + this_type & operator=(const this_type & x); + +* [*Effects: ] `a = b;` +where a and b are the `bimap` objects to which `*this` and x +belong, respectively. +* [*Returns: ] `*this`. + + + +[endsect] + +[section Modifiers] + +[#reference_set_of_insert_value] + + std::pair<iterator,bool> insert(const value_type & x); + +* [*Effects:] Inserts `x` into the `bimap` to which the set view belongs if + * the set view is non-unique OR no other element with equivalent key exists, + * AND insertion is allowed by the other set specifications the `bimap`. +* [*Returns:] The return value is a pair `p`. `p.second` is `true` if and only if insertion +took place. On successful insertion, `p.first` points to the element inserted; +otherwise, `p.first` points to an element that caused the insertion to be banned. +Note that more than one element can be causing insertion not to be allowed. +* [link set_of_complexity_signature +[*Complexity:]] O(I(n)). +* [*Exception safety:] Strong. + + +[#reference_set_of_insert_iterator_value] + + iterator insert(iterator position, const value_type & x); + +* [*Requires: ] `position` is a valid iterator of the view. +* [*Effects: ] `position` is used as a hint to improve the efficiency of the operation. Inserts `x` into the `bimap` to which the view belongs if + * the set view is non-unique OR no other element with equivalent key exists, + * AND insertion is allowed by all other views of the `bimap`. +* [*Returns:] On successful insertion, an iterator to the newly inserted +element. Otherwise, an iterator to an element that caused the insertion to be +banned. Note that more than one element can be causing insertion not to be allowed. +* [link set_of_complexity_signature +[*Complexity:]] O(H(n)). +* [*Exception safety:] Strong. + + +[#reference_set_of_insert_iterator_iterator] + + template< class InputIterator > + void insert(InputIterator first, InputIterator last); + +* [*Requires: ] `InputIterator` is a model of __SGI_INPUT_ITERATOR__ over elements of +type `value_type` or a type convertible to value_type. `first` and `last` are not +iterators into any view of the `bimap` to which this index +belongs. `last` is reachable from `first`. +* [*Effects: ] +`iterator hint = end()`; +`while( first != last ) hint = insert( hint, *first++ );` +* [link set_of_complexity_signature +[*Complexity:]] O(m*H(n+m)), where m is the number of elements in +`[first, last)`. +* [*Exception safety:] Basic. + + +[#reference_set_of_erase_iterator] + + iterator erase(iterator position); + +* [*Requires: ] `position` is a valid dereferenceable iterator if the set view. +* [*Effects:] Deletes the element pointed to by `position`. +* [*Returns:] An iterator pointing to the element immediately following +the one that was deleted, or `end()` if no such element exists. +* [link set_of_complexity_signature +[*Complexity:]] O(D(n)). +* [*Exception safety:] nothrow. + + +[#reference_set_of_erase_key] + + template< class CompatibleKey > + size_type erase(const CompatibleKey & x); + +* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. +* [*Effects:] Deletes the elements with key equivalent to `x`. +* [*Returns:] Number of elements deleted. +* [link set_of_complexity_signature +[*Complexity:]] O(log(n) + m*D(n)), where m is the number of elements deleted. +* [*Exception safety:] Basic. + + +[#reference_set_of_erase_iterator_iterator] + + iterator erase(iterator first, iterator last); + +* [*Requires: ] `[first,last)` is a valid range of the view. +* [*Effects:] Deletes the elements in `[first,last)`. +* [*Returns:] last. +* [link set_of_complexity_signature +[*Complexity:]] O(log(n) + m*D(n)), where m is the number of elements +in `[first,last)`. +* [*Exception safety:] nothrow. + + +[#reference_set_of_replace_iterator_value] + + bool replace(iterator position, const value_type& x); + +* [*Requires: ] `position` is a valid dereferenceable iterator of the set view. +* [*Effects:] Assigns the value `x` to the element pointed to by `position` into +the `bimap` to which the set view belongs if, for the value `x` + * the set view is non-unique OR no other element with equivalent key exists +(except possibly `*position`), + * AND replacing is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of position is preserved in all cases. +* [*Returns: ] `true` if the replacement took place, `false` otherwise. +* [link set_of_complexity_signature +[*Complexity:]] O(R(n)). +* [*Exception safety:] Strong. If an exception is thrown by some user-provided +operation, the `bimap` to which the set view belongs remains in +its original state. + + +[#reference_set_of_replace_key_iterator_key] + + template< class CompatibleKey > + bool replace_key(iterator position, const CompatibleKey & x); + +* [*Requires: ] `position` is a valid dereferenceable iterator of the set view. +`CompatibleKey` can be assigned to `key_type`. +* [*Effects:] Assigns the value `x` to `e.first`, where `e` is the element pointed +to by `position` into the `bimap` to which the set view belongs if, + * the map view is non-unique OR no other element with equivalent key exists +(except possibly `*position`), + * AND replacing is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of position is preserved in all cases. +* [*Returns: ] `true` if the replacement took place, `false` otherwise. +* [link set_of_complexity_signature +[*Complexity:]] O(R(n)). +* [*Exception safety:] Strong. If an exception is thrown by some user-provided +operation, the `bimap` to which the set view belongs remains in +its original state. + + +[#reference_set_of_replace_data_iterator_data] + + template< class CompatibleData > + bool replace_data(iterator position, const CompatibleData & x); + +* [*Requires: ] `position` is a valid dereferenceable iterator of the set view. +`CompatibleKey` can be assigned to `data_type`. +* [*Effects:] Assigns the value `x` to `e.second`, where `e` is the element pointed +to by `position` into the `bimap` to which the set view belongs if, + * the map view is non-unique OR no other element with equivalent key exists +(except possibly `*position`), + * AND replacing is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of position is preserved in all cases. +* [*Returns: ] `true` if the replacement took place, `false` otherwise. +* [link set_of_complexity_signature +[*Complexity:]] O(R(n)). +* [*Exception safety:] Strong. If an exception is thrown by some user-provided +operation, the `bimap` to which the set view belongs remains in +its original state. + + +[#reference_set_of_modify_key_iterator_modifier] + + template< class KeyModifier > + bool modify_key(iterator position, KeyModifier mod); + +* [*Requires: ] `KeyModifier` is a model of __SGI_UNARY_FUNCTION__ accepting arguments of +type: `key_type&`; `position` is a valid dereferenceable iterator of the view. +* [*Effects:] Calls `mod(e.first)` where e is the element pointed to by position and +rearranges `*position` into all the views of the `bimap`. +If the rearrangement fails, the element is erased. +Rearrangement is successful if + * the map view is non-unique OR no other element with equivalent key exists, + * AND rearrangement is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of `position` is preserved if the operation succeeds. +* [*Returns: ] `true` if the operation succeeded, `false` otherwise. +* [link set_of_complexity_signature +[*Complexity:]] O(M(n)). +* [*Exception safety:] Basic. If an exception is thrown by some user-provided +operation (except possibly mod), then the element pointed to by position is erased. +* [*Note:] Only provided for map views. + + +[#reference_set_of_modify_data_iterator_modifier] + + template< class DataModifier > + bool modify_data(iterator position, DataModifier mod); + +* [*Requires: ] `DataModifier` is a model of __SGI_UNARY_FUNCTION__ accepting arguments of +type: `data_type&`; `position` is a valid dereferenceable iterator of the view. +* [*Effects:] Calls `mod(e.second)` where e is the element pointed to by position and +rearranges `*position` into all the views of the `bimap`. +If the rearrangement fails, the element is erased. +Rearrangement is successful if + * the oppositte map view is non-unique OR no other element with equivalent key in that +view exists, + * AND rearrangement is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of `position` is preserved if the operation succeeds. +* [*Returns: ] `true` if the operation succeeded, `false` otherwise. +* [link set_of_complexity_signature +[*Complexity:]] O(M(n)). +* [*Exception safety:] Basic. If an exception is thrown by some user-provided +operation (except possibly mod), then the element pointed to by position is erased. +* [*Note:] Only provided for map views. + +[/ + +[#reference_set_of_modify_iterator_modifier] + + template< class Modifier > + bool modify(iterator position, Modifier mod); + +* [*Requires: ] `Modifier` is a model of __SGI_BINARY_FUNCTION__ accepting arguments of +type: `first_type&` and `second_type&` for ['Map View] or `left_type&` and `right_type&` +['Set View]; `position` is a valid dereferenceable iterator of the view. +* [*Effects:] Calls `mod(e.first,e.second)` for ['Map View] or Calls `mod(e.left,e.right)` +for ['Set View] where e is the element pointed to by position and rearranges `*position` +into all the views of the `bimap`. +If the rearrangement fails, the element is erased. +Rearrangement is successful if + * the view is non-unique OR no other element with equivalent key exists, + * AND rearrangement is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of `position` is preserved if the operation succeeds. +* [*Returns: ] `true` if the operation succeeded, `false` otherwise. +* [link set_of_complexity_signature +[*Complexity:]] O(M(n)). +* [*Exception safety:] Basic. If an exception is thrown by some user-provided +operation (except possibly mod), then the element pointed to by position is erased. + +] + +[endsect] + +[section Set operations] + +`[multi]set_of` views provide the full lookup functionality required by +__SGI_SORTED_ASSOCIATIVE_CONTAINER__ and __SGI_UNIQUE_ASSOCIATIVE_CONTAINER__, +namely `find`, `count`, `lower_bound`, `upper_bound` and `equal_range`. +Additionally, these member functions are templatized to allow for non-standard +arguments, so extending the types of search operations allowed. + +[/ +The kinds of arguments permissible when invoking the lookup member functions +are defined by the following concept. + +Consider a __SGI_STRICT_WEAK_ORDERING__ `Compare` over values of type `Key`. A pair of +types `(CompatibleKey, CompatibleCompare)` is said to be a ['compatible extension] +of Compare if + +* `CompatibleCompare` is a __SGI_BINARY_PREDICATE__ over `(Key, CompatibleKey)`, +* `CompatibleCompare` is a __SGI_BINARY_PREDICATE__ over `(CompatibleKey, Key)`, +* if `c_comp(ck,k1)` then `!c_comp(k1,ck)`, +* if `!c_comp(ck,k1)` and `!comp(k1,k2)` then `!c_comp(ck,k2)`, +* if `!c_comp(k1,ck)` and `!comp(k2,k1)` then `!c_comp(k2,ck)`, + +for every `c_comp` of type `CompatibleCompare`, `comp` of type `Compare`, `ck` of type +`CompatibleKey` and `k1`, `k2` of type `Key`. +] +A type `CompatibleKey` is said to be a ['compatible key] of `Compare` +if `(CompatibleKey, Compare)` is a compatible extension of `Compare`. This implies +that `Compare`, as well as being a strict weak ordering, accepts arguments of type +`CompatibleKey`, which usually means it has several overloads of `operator()`. + +[/ +In the context of a compatible extension or a compatible key, the expressions +"equivalent", "less than" and "greater than" take on their obvious interpretations. +] + +[#reference_set_of_find_key] + + template< class CompatibleKey > + iterator find(const CompatibleKey & x); + + template< class CompatibleKey > + const_iterator find(const CompatibleKey & x) const; + +* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. +* [*Effects:] Returns a pointer to an element whose key is equivalent to `x`, or +`end()` if such an element does not exist. +* [*Complexity:] O(log(n)). + +[/ + template< class CompatibleKey, class CompatibleCompare > + iterator find(const CompatibleKey & x, + const CompatibleCompare & comp); + + template< class CompatibleKey, class CompatibleCompare > + const_iterator find(const CompatibleKey & x, + const CompatibleCompare & comp) const; + +* [*Requires: ] `(CompatibleKey, CompatibleCompare)` is a compatible extension of +`key_compare.` +* [*Effects:] Returns a pointer to an element whose key is +equivalent to `x`, or `end()` if such an element does not exist. +* [*Complexity:] O(log(n)). +] + +[#reference_set_of_count_key] + + template< class CompatibleKey > + size_type count(const key_type & x) const; + +* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. +* [*Effects:] Returns the number of elements with key equivalent to `x`. +* [*Complexity:] O(log(n) + count(x)). + +[/ + template< class CompatibleKey, class CompatibleCompare > + size_type count(const CompatibleKey & x, + const CompatibleCompare & comp) const; + +* [*Requires: ] `(CompatibleKey, CompatibleCompare)` is a compatible extension of +`key_compare.` +* [*Effects:] Returns the number of elements with key equivalent to `x`. +* [*Complexity:] O(log(n) + count(x)). +] + +[#reference_set_of_lower_bound_key] + + template< class CompatibleKey > + iterator lower_bound(const key_type & x); + + template< class CompatibleKey > + const_iterator lower_bound(const key_type & x) const; + +* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. +* [*Effects:] Returns an iterator pointing to the first element with key not +less than `x`, or `end()` if such an element does not exist. +* [*Complexity:] O(log(n)). + + +[#reference_set_of_upper_bound_key] + + template< class CompatibleKey > + iterator upper_bound(const key_type & x); + + template< class CompatibleKey > + const_iterator upper_bound(const key_type & x) const; + +* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. +* [*Effects:] Returns an iterator pointing to the first element with key greater +than `x`, or `end()` if such an element does not exist. +* [*Complexity:] O(log(n)). + + +[#reference_set_of_equal_range_key] + + template< class CompatibleKey > + std::pair<iterator,iterator> + equal_range(const key_type & x); + + template< class CompatibleKey > + std::pair<const_iterator,const_iterator> + equal_range(const key_type & x) const; + +* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. +* [*Effects:] Equivalent to `make_pair(lower_bound(x),upper_bound(x))`. +* [*Complexity:] O(log(n)). + + + +[endsect] + +[section Range operations] + +The member function range is not defined for sorted associative +containers, but `[multi]set_of` map views provide it as a convenient utility. +A range or interval is defined by two conditions for the lower and upper +bounds, which are modelled after the following concepts. + +Consider a __SGI_STRICT_WEAK_ORDERING__ `Compare` over values of type Key. +A type `LowerBounder` is said to be a lower bounder of `Compare` if + +* `LowerBounder` is a `Predicate` over `Key`, +* if `lower(k1)` and `!comp(k2,k1)` then `lower(k2)`, + +for every `lower` of type `LowerBounder`, `comp` of type `Compare`, and `k1`, `k2` +of type `Key`. +Similarly, an upper bounder is a type `UpperBounder` such that + +* `UpperBounder` is a `Predicate` over `Key`, +* if `upper(k1)` and `!comp(k1,k2)` then `upper(k2)`, + +for every `upper` of type `UpperBounder`, `comp` of type `Compare`, and `k1`, `k2` +of type `Key`. + +[#reference_set_of_range_lower_upper] + + template< class LowerBounder, class UpperBounder> + std::pair<const_iterator,const_iterator> range( + LowerBounder lower, UpperBounder upper) const; + +* [*Requires: ] `LowerBounder` and `UpperBounder` are a lower and upper bounder of +`key_compare`, respectively. +* [*Effects:] Returns a pair of iterators pointing to +the beginning and one past the end of the subsequence of elements satisfying +lower and upper simultaneously. If no such elements exist, the iterators both +point to the first element satisfying lower, or else are equal to `end()` if this +latter element does not exist. +* [*Complexity:] O(log(n)). +* [*Variants:] In place of lower or upper (or both), the singular value +`boost::bimap::unbounded` can be provided. This acts as a predicate which +all values of type `key_type` satisfy. +* [*Note:] Only provided for map views. + +[endsect] + +[section at(), info_at() and operator\[\] - set_of only] + +[#reference_set_of_at_key_const] + + template< class CompatibleKey > + const data_type & at(const CompatibleKey & k) const; + +* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. +* [*Effects:] Returns the `data_type` reference that is associated with `k`, or +throws `std::out_of_range` if such key does not exist. +* [*Complexity:] O(log(n)). +* [*Note:] Only provided when `set_of` is used. + +The symmetry of bimap imposes some constraints on `operator[]` and the +non constant version of at() that are not found in `std::maps`. +Tey are only provided if the other collection type is mutable +(`list_of`, `vector_of` and `unconstrained_set_of`). + +[#reference_set_of_operator_bracket_key] + + template< class CompatibleKey > + data_type & operator[](const CompatibleKey & k); + +* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. +* [*Effects: ] `return insert(value_type(k,data_type()))->second;` +* [*Complexity:] O(log(n)). +* [*Note:] Only provided when `set_of` is used and the other collection +type is mutable. + +[#reference_set_of_at_key] + + template< class CompatibleKey > + data_type & at(const CompatibleKey & k); + +* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. +* [*Effects: ] Returns the `data_type` reference that is associated with `k`, or +throws `std::out_of_range` if such key does not exist. +* [*Complexity:] O(log(n)). +* [*Note:] Only provided when `set_of` is used and the other collection +type is mutable. + +[/ +The symmetry of bimap imposes some constraints on `operator[]` that are +not found in `std::maps`. If other views are unique, +`bimap::duplicate_value` is thrown whenever an assignment is attempted to +a value that is already a key in these views. As for +`bimap::value_not_found`, this exception is thrown while trying to access +a non-existent key: this behaviour differs from that of `std::map`, which +automatically assigns a default value to non-existent keys referred to +by `operator[]`. + + const data_type & operator[](const typename key_type & k) const; + +* [*Effects:] Returns the `data_type` reference that is associated with `k`, or +throws `bimap::value_not_found` if such an element does not exist. +* [*Complexity:] O(log(n)). + + + ``['-unspecified data_type proxy-]`` operator[](const typename key_type & k); + +* [*Effects:] Returns a proxy to a `data_type` associated with `k` and the +bimap. The proxy behaves as a reference to the `data_type` object. If this +proxy is read and `k` was not in the bimap, the bimap::value_not_found is +thrown. If it is written then `bimap::duplicate_value` is thrown if the +assignment is not allowed by one of the other views of the `bimap`. +* [link set_of_complexity_signature +[*Complexity:]] If the assignment operator of the proxy is not used, then +the order is O(log(n)). If it is used, the order is O(I(n)) if `k` was not +in the bimap and O(R(n)) if it existed in the bimap. +] + + +[#reference_set_of_info_at_key] + + template< class CompatibleKey > + info_type & info_at(const CompatibleKey & k); + + template< class CompatibleKey > + const info_type & info_at(const CompatibleKey & k) const; + +* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. +* [*Effects:] Returns the `info_type` reference that is associated with `k`, or +throws `std::out_of_range` if such key does not exist. +* [*Complexity:] O(log(n)). +* [*Note:] Only provided when `set_of` and `info_hook` are used + + +[endsect] + +[section Serialization] + +Views cannot be serialized on their own, but only as part of the `bimap` +into which they are embedded. In describing the additional preconditions and guarantees +associated to `[multi]set_of` views with respect to serialization of their embedding containers, +we use the concepts defined in the `bimap` serialization section. + +[blurb [*Operation:] saving of a `bimap` m to an output archive (XML archive) ar.] + +* [*Requires:] No additional requirements to those imposed by the container. + + +[blurb [*Operation:] loading of a `bimap` m' from an input archive (XML archive) ar.] + +* [*Requires:] In addition to the general requirements, `value_comp()` must be +serialization-compatible with `m.get<i>().value_comp()`, where i is the position +of the ordered view in the container. +* [*Postconditions:] On successful loading, each of the elements of `[begin(), end())` +is a restored copy of the corresponding element in `[m.get<i>().begin(), m.get<i>().end())`. + + + +[blurb [*Operation:] saving of an iterator or `const_iterator` it to an output archive +(XML archive) ar.] + +* [*Requires: ] `it` is a valid iterator of the view. The associated `bimap` +has been previously saved. + + +[blurb [*Operation:] loading of an `iterator` or `const_iterator` `it`' from an input archive ( +XML archive) ar.] + +* [*Postconditions:] On successful loading, if it was dereferenceable then `*it`' is the +restored copy of `*it`, otherwise `it`'` == end()`. +* [*Note:] It is allowed that it be a `const_iterator` and the restored `it`' an iterator, +or viceversa. + + +[endsect] +[endsect] + +[endsect]
\ No newline at end of file diff --git a/libs/bimap/doc/reference/unconstrained_set_of.qbk b/libs/bimap/doc/reference/unconstrained_set_of.qbk new file mode 100644 index 0000000000..9b487ddb81 --- /dev/null +++ b/libs/bimap/doc/reference/unconstrained_set_of.qbk @@ -0,0 +1,123 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section unconstrained_set_of Reference] + +[section Header "boost/bimap/unconstrained_set_of.hpp" synopsis] + + namespace boost { + namespace bimaps { + + + template< class KeyType > + struct unconstrained_set_of; + + struct unconstrained_set_of_relation; + + + } // namespace bimap + } // namespace boost + +[endsect] + +[section unconstrained_set_of Views] + +An unconstrained_set_of set view is a view with no constraints. The use +of these kind of view boost the bimap performance but the view can not +be accessed. An unconstrained view is an empty class. + + namespace boost { + namespace bimaps { + namespace views { + + template< ``['-implementation defined parameter list-]`` > + class ``['-implementation defined view name-]`` + { + // Empty view + }; + + } // namespace views + } // namespace bimap + } // namespace boost + + + +In the case of a `bimap< unconstrained_set_of<Left>, ... >` + +In the set view: + + typedef signature-compatible with relation< Left, ... > key_type; + typedef signature-compatible with relation< Left, ... > value_type; + +In the left map view: + + typedef Left key_type; + typedef ... data_type; + + typedef signature-compatible with std::pair< Left, ... > value_type; + +In the right map view: + + typedef ... key_type; + typedef Left data_type; + + typedef signature-compatible with std::pair< ... , Left > value_type; + + + +[#unconstrained_set_of_complexity_signature] + +[section Complexity signature] + +We adopt the scheme outlined in the +[link complexity_signature_explanation complexity signature section]. +An unconstrained view can not be accessed by the user, but the +formulas to find the order of an operation for a bimap hold with +the following definitions. +The complexity signature of a `unconstrained_set_of` view is: + +* copying: `c(n) = 0` +* insertion: `i(n) = 0` +* hinted insertion: `h(n) = 0` +* deletion: `d(n) = 0` +* replacement: `r(n) = 0` +* modifying: `m(n) = 0` + +[endsect] + +[section Serialization] + +Views cannot be serialized on their own, but only as part of the +`bimap` into which they are embedded. In describing the additional +preconditions and guarantees associated to `list_of` views with respect to +serialization of their embedding containers, we use the concepts defined in the +`bimap` serialization section. + +[blurb [*Operation:] saving of a `bimap` b to an output archive +(XML archive) ar.] + +* [*Requires:] No additional requirements to those imposed by the container. + +[blurb [*Operation:] loading of a `bimap` b' from an input archive +(XML archive) ar.] + +* [*Requires:] No additional requirements to those imposed by the container. + + +[endsect] +[endsect] + +[endsect] + + diff --git a/libs/bimap/doc/reference/unordered_set_of.qbk b/libs/bimap/doc/reference/unordered_set_of.qbk new file mode 100644 index 0000000000..d386b8754c --- /dev/null +++ b/libs/bimap/doc/reference/unordered_set_of.qbk @@ -0,0 +1,853 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section unordered_set_of Reference] + +[section Header "boost/bimap/unordered_set_of.hpp" synopsis] + + namespace boost { + namespace bimaps { + + + template + < + class KeyType, + class HashFunctor = hash< KeyType >, + class EqualKey = std::equal_to< KeyType > + > + struct unordered_set_of; + + + template + < + class HashFunctor = hash< _relation >, + class EqualKey = std::equal_to< _relation > + > + struct unordered_set_of_relation; + + + } // namespace bimap + } // namespace boost + + +[endsect] + +[section Header "boost/bimap/unordered_multiset_of.hpp" synopsis] + + namespace boost { + namespace bimaps { + + + template + < + class KeyType, + class HashFunctor = hash< KeyType >, + class EqualKey = std::equal_to< KeyType > + > + struct unordered_multiset_of; + + + template + < + class HashFunctor = hash< _relation >, + class EqualKey = std::equal_to< _relation > + > + struct unordered_multiset_of_relation; + + + } // namespace bimap + } // namespace boost + + +[endsect] + +[section Collection type specifiers unordered_set_of and unordered_multiset_of] + +These collection types specifiers allow for set views without and +with allowance of duplicate elements, respectively. The syntax of +`set_of` and `multiset_of` coincide, thus we describe them +in a grouped manner. + +[endsect] + +[section unordered_\[multi\]set_of Views] + +An unordered_\[multi\]set_of set view is a tr1::unordered\[multi\]set signature compatible +interface to the underlying heap of elements contained in a `bimap`. + +The interface and semantics of `unordered_[multi]set_of` views are +modeled according to the proposal for unordered associative containers given +in the __CPP_STANDARD_LIBRARY_TECHNICAL_REPORT__, also known as TR1. +An `unordered_[multi]set_of` view is particularized according to a given +`Hash` function object which returns hash values for the keys and a +binary predicate `Pred` acting as an equivalence relation on values of Key. + +There are two variants: unordered_set_of, which do not allow duplicate elements +(with respect to its associated comparison predicate) and unordered_multiset_of, +which accept those duplicates. The interface of these two variants is the same +to a great extent, so they are documented together with their differences +explicitly noted when they exist. + +If you look the bimap by a side, you will use a map view and if you looked +it as a whole you will be using a set view. + +Except where noted, `unordered_[multi]set_of` views (both unique and non-unique) are models +of [^Unordered Associative Container]. +Validity of iterators and references to elements is preserved in all cases. +Occasionally, the exception safety guarantees provided are actually stronger +than required by the extension draft. We only provide descriptions of those +types and operations that are either not present in the concepts modeled or +do not exactly conform to the requirements for unordered associative containers. + + + namespace boost { + namespace bimap { + namespace views { + + template< ``['-implementation defined parameter list-]`` > + class ``['-implementation defined view name-]`` + { + public: + + // types + + typedef ``['-unspecified-]`` key_type; + typedef ``['-unspecified-]`` value_type; + typedef ``['-unspecified-]`` key_compare; + typedef ``['-unspecified-]`` value_compare; + typedef ``['-unspecified-]`` hasher; + typedef ``['-unspecified-]`` key_equal; + typedef ``['-unspecified-]`` allocator_type; + typedef ``['-unspecified-]`` reference; + typedef ``['-unspecified-]`` const_reference; + typedef ``['-unspecified-]`` iterator; + typedef ``['-unspecified-]`` const_iterator; + typedef ``['-unspecified-]`` size_type; + typedef ``['-unspecified-]`` difference_type; + typedef ``['-unspecified-]`` pointer; + typedef ``['-unspecified-]`` const_pointer; + typedef ``['-unspecified-]`` local_iterator; + typedef ``['-unspecified-]`` const_local_iterator; + + typedef ``['-unspecified-]`` info_type; + + // construct/destroy/copy: + + this_type & operator=(const this_type & x); + + allocator_type get_allocator() const; + + // size and capacity + + bool empty() const; + size_type size() const; + size_type max_size() const; + + // iterators + + iterator begin(); + const_iterator begin() const; + iterator end(); + const_iterator end() const; + + // modifiers + + std::pair< iterator, bool > ``[link reference_unordered_set_of_insert_value insert]``(const value_type & x); + + iterator ``[link reference_unordered_set_of_insert_iterator_value insert]``(iterator position, const value_type & x); + + template< class InputIterator > + void ``[link reference_unordered_set_of_insert_iterator_iterator insert]``(InputIterator first, InputIterator last); + + iterator ``[link reference_unordered_set_of_erase_iterator erase]``(iterator position); + + template< class CompatibleKey > + size_type ``[link reference_unordered_set_of_erase_key erase]``(const CompatibleKey & x); + + iterator ``[link reference_unordered_set_of_erase_iterator_iterator erase]``(iterator first, iterator last); + + bool ``[link reference_unordered_set_of_replace_iterator_value replace]``(iterator position, const value_type & x); + + // Only in map views + // { + + template< class CompatibleKey > + bool ``[link reference_unordered_set_of_replace_key_iterator_key replace_key]``(iterator position, const CompatibleKey & x); + + template< class CompatibleData > + bool ``[link reference_unordered_set_of_replace_data_iterator_data replace_data]``(iterator position, const CompatibleData & x); + + template< class KeyModifier > + bool ``[link reference_unordered_set_of_modify_key_iterator_modifier modify_key]``(iterator position, KeyModifier mod); + + template< class DataModifier > + bool ``[link reference_unordered_set_of_modify_data_iterator_modifier modify_data]``(iterator position, DataModifier mod); + + // } + + + void clear(); + + // observers + + key_from_value key_extractor() const; + hasher hash_function() const; + key_equal key_eq() const; + + // lookup + + template< class CompatibleKey > + iterator ``[link reference_unordered_set_of_find_key find]``(const CompatibleKey & x); + + template< class CompatibleKey > + const_iterator ``[link reference_unordered_set_of_find_key find]``(const CompatibleKey & x) const; + + template< class CompatibleKey > + size_type ``[link reference_unordered_set_of_count_key count]``(const CompatibleKey & x) const; + + template< class CompatibleKey > + std::pair<iterator,iterator> + ``[link reference_unordered_set_of_equal_range_key equal_range]``(const CompatibleKey & x); + + template< class CompatibleKey > + std::pair<const_iterator,const_iterator> + ``[link reference_unordered_set_of_equal_range_key equal_range]``(const CompatibleKey & x) const; + + // bucket interface + + size_type bucket_count() const; + size_type max_bucket_count() const; + size_type bucket_size(size_type n) const; + size_type bucket(const key_type & k) const; + + local_iterator begin(size_type n); + const_local_iterator begin(size_type n) const; + local_iterator end(size_type n); + const_local_iterator end(size_type n) const; + + // hash policy + + float load_factor() const; + float max_load_factor() const; + void max_load_factor(float z); + void ``[link reference_unordered_set_of_rehash_size rehash]``(size_type n); + + // Only in maps views + // { + + typedef ``['-unspecified-]`` data_type; + + // Only in for `unordered_set_of` collection type + // { + + template<class CompatibleKey> + const data_type & ``[link reference_unordered_set_of_at_key_const at]``(const CompatibleKey & k) const; + + // Only if the other collection type is mutable + // { + + template<class CompatibleKey> + data_type & ``[link reference_unordered_set_of_operator_bracket_key operator\[\]]``(const CompatibleKey & k); + + template<class CompatibleKey> + data_type & ``[link reference_unordered_set_of_at_key at]``(const CompatibleKey & k); + + // } + + // Only if info_hook is used + // { + + template< class CompatibleKey > + info_type & ``[link reference_unordered_set_of_info_at_key info_at]``(const CompatibleKey & k); + + template< class CompatibleKey > + const info_type & ``[link reference_unordered_set_of_info_at_key info_at]``(const CompatibleKey & k) const; + + // } + + // } + + }; + + } // namespace views + } // namespace bimap + } // namespace boost + + + +In the case of a `bimap< unordered_{multi}set_of<Left>, ... >` + +In the set view: + + typedef signature-compatible with relation< Left, ... > key_type; + typedef signature-compatible with relation< const Left, ... > value_type; + +In the left map view: + + typedef Left key_type; + typedef ... data_type; + + typedef signature-compatible with std::pair< const Left, ... > value_type; + +In the right map view: + + typedef ... key_type; + typedef Left data_type; + + typedef signature-compatible with std::pair< ... ,const Left > value_type; + + + +[#unordered_set_of_complexity_signature] + +[section Complexity signature] + +Here and in the descriptions of operations of `unordered_[multi]set_of` views, +we adopt the scheme outlined in the +[link complexity_signature_explanation complexity signature section]. +The complexity signature of `unordered_[multi]set_of` view is: + +* copying: `c(n) = n * log(n)`, +* insertion: average case `i(n) = 1` (constant), worst case `i(n) = n`, +* hinted insertion: average case `h(n) = 1` (constant), worst case `h(n) = n`, +* deletion: average case `d(n) = 1` (constant), worst case `d(n) = n`, +* replacement: + * if the new element key is equivalent to the original, `r(n) = 1` (constant), + * otherwise, average case `r(n) = 1` (constant), worst case `r(n) = n`, +* modifying: average case `m(n) = 1` (constant), worst case `m(n) = n`. + +[endsect] + + +[section Instantiation types] + +`unordered_[multi]set_of` views are instantiated internally to `bimap` +specified by means of the collection type specifiers and the `bimap` itself. +Instantiations are dependent on the following types: + +* `Value` from `bimap`, +* `Allocator` from `bimap`, +* `Hash` from the collection type specifier, +* `Pred` from the collection type specifier. + +`Hash` is a __SGI_UNARY_FUNCTION__ taking a single argument of type +`key_type` and returning a value of type `std::size_t` in the range +`[0, std::numeric_limits<std::size_t>::max())`. +Pred is a __SGI_BINARY_PREDICATE__ inducing an equivalence relation on elements of +`key_type`. It is required that the `Hash` object return the same value for +keys equivalent under `Pred`. + +[endsect] + +[section Nested types] + + iterator + const_iterator + local_iterator + const_local_iterator + +[: These types are models of __SGI_FORWARD_ITERATOR__. +] + + +[endsect] + +[section Constructors, copy and assignment] + +As explained in the concepts section, +views do not have public constructors or destructors. Assignment, on the other +hand, is provided. +Upon construction, `max_load_factor()` is 1.0. + + this_type & operator=(const this_type & x); + +* [*Effects: ] `a = b`; +where a and b are the `bimap` objects to which `*this` +and x belong, respectively. +* [*Returns: ] `*this.` + + + +[endsect] + +[section Modifiers] + +[#reference_unordered_set_of_insert_value] + + std::pair<iterator,bool> insert(const value_type & x); + +* [*Effects:] Inserts `x` into the `bimap` to which the view belongs if + * the view is non-unique OR no other element with equivalent key exists, + * AND insertion is allowed by all other views of the `bimap`. +* [*Returns:] The return value is a pair `p`. `p.second` is `true` if and only if +insertion took place. On successful insertion, `p.first` points to the element +inserted; otherwise, `p.first` points to an element that caused the insertion to +be banned. Note that more than one element can be causing insertion not to be +allowed. +* [link unordered_set_of_complexity_signature +[*Complexity:]] O(I(n)). +* [*Exception safety:] Strong. + +[#reference_unordered_set_of_insert_iterator_value] + + iterator insert(iterator position, const value_type & x); + +* [*Requires: ] `position` is a valid iterator of the view. +* [*Effects: ] `position` is used as a hint to improve the efficiency of the operation. +Inserts `x` into the `bimap` to which the view belongs if + * the view is non-unique OR no other element with equivalent key exists, + * AND insertion is allowed by all other views of the `bimap`. +* [*Returns:] On successful insertion, an iterator to the newly inserted element. +Otherwise, an iterator to an element that caused the insertion to be banned. +Note that more than one element can be causing insertion not to be allowed. +* [link unordered_set_of_complexity_signature [*Complexity:]] O(H(n)). +* [*Exception safety:] Strong. + +[#reference_unordered_set_of_insert_iterator_iterator] + + template< class InputIterator> + void insert(InputIterator first, InputIterator last); + +* [*Requires: ] `InputIterator` is a model of __SGI_INPUT_ITERATOR__ over elements of type +`value_type`. `first` and `last` are not iterators into any views of the +`bimap` to which this view belongs. `last` is reachable from first. +* [*Effects: ] +`iterator hint = end();` +`while(first != last) hint = insert(hint, *first++);` +* [link unordered_set_of_complexity_signature +[*Complexity:]] O(m*H(n+m)), where m is the number of elements in `[first, last)`. +* [*Exception safety:] Basic. + +[#reference_unordered_set_of_erase_iterator] + + iterator erase(iterator position); + +* [*Requires: ] `position` is a valid dereferenceable `iterator` of the view. +* [*Effects:] Deletes the element pointed to by `position`. +* [*Returns:] An `iterator` pointing to the element immediately following the one +that was deleted, or `end()` if no such element exists. +* [link unordered_set_of_complexity_signature +[*Complexity:]] O(D(n)). +* [*Exception safety:] nothrow. + + +[#reference_unordered_set_of_erase_key] + + template< class CompatibleKey > + size_type erase(const CompatibleKey & x); + +* [*Effects:] Deletes the elements with key equivalent to `x`. +* [*Returns:] Number of elements deleted. +* [link unordered_set_of_complexity_signature +[*Complexity:]] Average case, O(1 + m*D(n)), worst case O(n + m*D(n)), +where m is the number of elements deleted. +* [*Exception safety:] Basic. + + +[#reference_unordered_set_of_erase_iterator_iterator] + + iterator erase(iterator first, iterator last); + +* [*Requires: ] `[first,last)` is a valid range of the view. +* [*Effects:] Deletes the elements in `[first,last)`. +* [*Returns: ] `last`. +* [link unordered_set_of_complexity_signature +[*Complexity:]] O(m*D(n)), where m is the number of elements in `[first,last)`. +* [*Exception safety:] nothrow. + + +[#reference_unordered_set_of_replace_iterator_value] + + bool replace(iterator position, const value_type & x); + +* [*Requires: ] `position` is a valid dereferenceable `iterator` of the view. +* [*Effects:] Assigns the value `x` to the element pointed to by `position` into +the `bimap` to which the view belongs if, for the value `x` + * the view is non-unique OR no other element with equivalent key exists +(except possibly `*position`), + * AND replacing is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of position is preserved in all cases. +* [*Returns: ] `true` if the replacement took place, `false` otherwise. +* [link unordered_set_of_complexity_signature +[*Complexity:]] O(R(n)). +* [*Exception safety:] Strong. If an exception is thrown by some user-provided +operation the `bimap` to which the view belongs remains in its original state. + + +[#reference_unordered_set_of_replace_key_iterator_key] + + template< class CompatibleKey > + bool replace_key(iterator position, const CompatibleKey & x); + +* [*Requires: ] `position` is a valid dereferenceable iterator of the set view. +`CompatibleKey` can be assigned to `key_type`. +* [*Effects:] Assigns the value `x` to `e.first`, where `e` is the element pointed +to by `position` into the `bimap` to which the set view belongs if, + * the map view is non-unique OR no other element with equivalent key exists +(except possibly `*position`), + * AND replacing is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of position is preserved in all cases. +* [*Returns: ] `true` if the replacement took place, `false` otherwise. +* [link unordered_set_of_complexity_signature +[*Complexity:]] O(R(n)). +* [*Exception safety:] Strong. If an exception is thrown by some user-provided +operation, the `bimap` to which the set view belongs remains in +its original state. + + +[#reference_unordered_set_of_replace_data_iterator_data] + + template< class CompatibleData > + bool replace_data(iterator position, const CompatibleData & x); + +* [*Requires: ] `position` is a valid dereferenceable iterator of the set view. +`CompatibleKey` can be assigned to `data_type`. +* [*Effects:] Assigns the value `x` to `e.second`, where `e` is the element pointed +to by `position` into the `bimap` to which the set view belongs if, + * the map view is non-unique OR no other element with equivalent key exists +(except possibly `*position`), + * AND replacing is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of position is preserved in all cases. +* [*Returns: ] `true` if the replacement took place, `false` otherwise. +* [link unordered_set_of_complexity_signature +[*Complexity:]] O(R(n)). +* [*Exception safety:] Strong. If an exception is thrown by some user-provided +operation, the `bimap` to which the set view belongs remains in +its original state. + + +[#reference_unordered_set_of_modify_key_iterator_modifier] + + template< class KeyModifier > + bool modify_key(iterator position, KeyModifier mod); + +* [*Requires: ] `KeyModifier` is a model of __SGI_UNARY_FUNCTION__ accepting arguments of +type: `key_type&`; `position` is a valid dereferenceable iterator of the view. +* [*Effects:] Calls `mod(e.first)` where e is the element pointed to by position and +rearranges `*position` into all the views of the `bimap`. +If the rearrangement fails, the element is erased. +Rearrangement is successful if + * the map view is non-unique OR no other element with equivalent key exists, + * AND rearrangement is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of `position` is preserved if the operation succeeds. +* [*Returns: ] `true` if the operation succeeded, `false` otherwise. +* [link unordered_set_of_complexity_signature +[*Complexity:]] O(M(n)). +* [*Exception safety:] Basic. If an exception is thrown by some user-provided +operation (except possibly mod), then the element pointed to by position is erased. +* [*Note:] Only provided for map views. + + +[#reference_unordered_set_of_modify_data_iterator_modifier] + + template< class DataModifier > + bool modify_data(iterator position, DataModifier mod); + +* [*Requires: ] `DataModifier` is a model of __SGI_UNARY_FUNCTION__ accepting arguments of +type: `data_type&`; `position` is a valid dereferenceable iterator of the view. +* [*Effects:] Calls `mod(e.second)` where e is the element pointed to by position and +rearranges `*position` into all the views of the `bimap`. +If the rearrangement fails, the element is erased. +Rearrangement is successful if + * the oppositte map view is non-unique OR no other element with equivalent key in that +view exists, + * AND rearrangement is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of `position` is preserved if the operation succeeds. +* [*Returns: ] `true` if the operation succeeded, `false` otherwise. +* [link unordered_set_of_complexity_signature +[*Complexity:]] O(M(n)). +* [*Exception safety:] Basic. If an exception is thrown by some user-provided +operation (except possibly mod), then the element pointed to by position is erased. +* [*Note:] Only provided for map views. + +[/ +[#reference_unordered_set_of_modify_iterator_modifier] + + template< class Modifier> + bool modify(iterator position, Modifier mod); + +* [*Requires: ] `Modifier` is a model of __SGI_BINARY_FUNCTION__ accepting arguments of +type: `first_type&` and `second_type&` for ['Map View] or `left_type&` and `right_type&` +for ['Set View]; `position` is a valid dereferenceable iterator of the view. +* [*Effects:] Calls `mod(e.first,e.second)` for ['Map View:] or calls `mod(e.left,e.right)` +for ['Set View] where `e` is the element pointed to by `position` and +rearranges `*position` into all the views of the `bimap`. +If the rearrangement fails, the element is erased. +Rearrangement is successful if + * the view is non-unique OR no other element with equivalent key exists, + * AND rearrangement is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of position is preserved if the operation succeeds. +* [*Returns: ] `true` if the operation succeeded, `false` otherwise. +* [link unordered_set_of_complexity_signature +[*Complexity:]] O(M(n)). +* [*Exception safety:] Basic. If an exception is thrown by some user-provided +operation (except possibly `mod`), then the element pointed to by `position` is erased. +/] + +[endsect] + +[section Lookup] + +`unordered_[multi]set_of` views provide the full lookup functionality required by unordered +associative containers, namely `find`, `count`, and `equal_range`. Additionally, +these member functions are templatized to allow for non-standard arguments, +so extending the types of search operations allowed. The kind of arguments +permissible when invoking the lookup member functions is defined by the +following concept. + +[/ +Consider a pair `(Hash, Pred)` where `Hash` is a hash functor over values of type +`Key` and `Pred` is a __SGI_BINARY_PREDICATE__ inducing an equivalence relation on `Key`, +with the additional constraint that equivalent keys have the same hash value. +A triplet of types `(CompatibleKey, CompatibleHash, CompatiblePred)` is said to +be a ['compatible extension] of `(Hash, Pred)` if + +* `CompatibleHash` is a hash functor on values of type `CompatibleKey`, +* `CompatiblePred` is a __SGI_BINARY_PREDICATE__ over `(Key, CompatibleKey)`, +* `CompatiblePred` is a __SGI_BINARY_PREDICATE__ over `(CompatibleKey, Key)`, +* if `c_eq(ck,k1)` then `c_eq(k1,ck)`, +* if `c_eq(ck,k1)` and `eq(k1,k2)` then `c_eq(ck,k2)`, +* if `c_eq(ck,k1)` and `c_eq(ck,k2)` then `eq(k1,k2)`, +* if `c_eq(ck,k1)` then `c_hash(ck)==hash(k1)`, + +for every `c_hash` of type `CompatibleHash`, `c_eq` of type `CompatiblePred`, hash of +type `Hash`, `eq` of type `Pred`, `ck` of type `CompatibleKey` and `k1`, `k2` of type `Key`. +] + +A type `CompatibleKey` is said to be a ['compatible key] of `(Hash, Pred)` +if `(CompatibleKey, Hash, Pred)` is a compatible extension of `(Hash, Pred)`. This +implies that `Hash` and `Pred` accept arguments of type `CompatibleKey`, which usually +means they have several overloads of their corresponding `operator()` member +functions. + +[/ +In the context of a compatible extension or a compatible key, the expression +"equivalent key" takes on its obvious interpretation. +] + +[#reference_unordered_set_of_find_key] + + template< class CompatibleKey > + iterator find(const CompatibleKey & x); + + template< class CompatibleKey > + const_iterator find(const CompatibleKey & x) const; + +* [*Effects:] Returns a pointer to an element whose key is equivalent to `x`, +or `end()` if such an element does not exist. +* [*Complexity:] Average case O(1) (constant), worst case O(n). + + +[#reference_unordered_set_of_count_key] + + template< class CompatibleKey > + size_type count(const CompatibleKey & x) const; + +* [*Effects:] Returns the number of elements with key equivalent to `x`. +* [*Complexity:] Average case O(count(x)), worst case O(n). + + +[#reference_unordered_set_of_equal_range_key] + + template< class CompatibleKey > + std::pair<iterator,iterator> + equal_range(const CompatibleKey & x); + + template< class CompatibleKey > + std::pair<const_iterator,const_iterator> + equal_range(const CompatibleKey & x) const; + +* [*Effects:] Returns a range containing all elements with keys equivalent +to `x` (and only those). +* [*Complexity:] Average case O(count(x)), worst case O(n). + + + +[endsect] + +[section at(), info_at() and operator\[\] - set_of only] + + +[#reference_unordered_set_of_at_key_const] + + template< class CompatibleKey > + const data_type & at(const CompatibleKey & k) const; + +* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. +* [*Effects:] Returns the `data_type` reference that is associated with `k`, or +throws `std::out_of_range` if such key does not exist. +* [*Complexity:] Average case O(1) (constant), worst case O(n). +* [*Note:] Only provided when `unordered_set_of` is used. + +The symmetry of bimap imposes some constraints on `operator[]` and the +non constant version of at() that are not found in `std::maps`. +Tey are only provided if the other collection type is mutable +(`list_of`, `vector_of` and `unconstrained_set_of`). + + +[#reference_unordered_set_of_operator_bracket_key] + + template< class CompatibleKey > + data_type & operator[](const CompatibleKey & k); + +* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. +* [*Effects: ] `return insert(value_type(k,data_type()))->second;` +* [*Complexity:] If the insertion is performed O(I(n)), else: Average case +O(1) (constant), worst case O(n). +* [*Note:] Only provided when `unordered_set_of` is used and the other collection +type is mutable. + + +[#reference_unordered_set_of_at_key] + + template< class CompatibleKey > + data_type & at(const CompatibleKey & k); + +* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. +* [*Effects: ] Returns the `data_type` reference that is associated with `k`, or +throws `std::out_of_range` if such key does not exist. +* [*Complexity:] Average case O(1) (constant), worst case O(n). +* [*Note:] Only provided when `unordered_set_of` is used and the other collection +type is mutable. + +[/ + +The symmetry of bimap imposes some constraints to the `operator[]` that are not +found in `std::maps`. +If other views are unique, `bimap::duplicate_value` is thrown whenever an assignment is +attempted to a value that is already a key in this views. +As for bimap::value_not_found, this exception is thrown while trying to access +a non-existent key: this behavior differs from that of std::map, which automatically +assigns a default value to non-existent keys referred to by `operator[]`. + + const data_type & operator[](const typename key_type & k) const; + +* [*Effects:] Returns the `data_type` reference that is associated with `k`, or +throws `bimap::value_not_found` if such an element does not exist. +* [*Complexity:] O(log(n)). + + + ``['-unspecified data_type proxy-]`` operator[](const typename key_type & k); + +* [*Effects:] Returns a proxy to a `data_type` associated with `k` and the +bimap. The proxy behaves as a reference to the `data_type` object. If this +proxy is read and `k` was not in the bimap, the bimap::value_not_found is +thrown. If it is written then `bimap::duplicate_value` is thrown if the +assignment is not allowed by one of the other views of the `bimap`. +* [link unordered_set_of_complexity_signature +[*Complexity:]] If the assignment operator of the proxy is not used, then +the order is O(log(n)). If it is used, the order is O(I(n)) if `k` was not +in the bimap and O(R(n)) if it existed in the bimap. + +] + +[#reference_unordered_set_of_info_at_key] + + template< class CompatibleKey > + info_type & info_at(const CompatibleKey & k); + + template< class CompatibleKey > + const info_type & info_at(const CompatibleKey & k) const; + +* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. +* [*Effects:] Returns the `info_type` reference that is associated with `k`, or +throws `std::out_of_range` if such key does not exist. +* [*Complexity:] Average case O(1) (constant), worst case O(n). +* [*Note:] Only provided when `unordered_set_of` and `info_hook` are used + + +[endsect] + +[section Hash policy] + + +[#reference_unordered_set_of_rehash_size] + + void rehash(size_type n); + +* [*Effects:] Increases if necessary the number of internal buckets so that +`size()/bucket_count()` does not exceed the maximum load factor, and +`bucket_count()>=n`. +* [*Postconditions:] Validity of iterators and references to the elements +contained is preserved. +* [*Complexity:] Average case O(size()), worst case O(size(n)2). +* [*Exception safety:] Strong. + + +[endsect] + +[section Serialization] + +Views cannot be serialized on their own, but only as part of the +`bimap` into which they are embedded. In describing the +additional preconditions and guarantees associated to `unordered_[multi]set_of` views +with respect to serialization of their embedding containers, we use +the concepts defined in the `bimap` serialization section. + +[blurb [*Operation:] saving of a `bimap` b to an output archive +(XML archive) ar.] + +* [*Requires:] No additional requirements to those imposed by the container. + + +[blurb [*Operation:] loading of a `bimap` b' from an input +archive (XML archive) ar.] + +* [*Requires:] Additionally to the general requirements, `key_eq()` must +be serialization-compatible with `m.get<i>().key_eq()`, where i is the +position of the `unordered_[multi]set_of` view in the container. +* [*Postconditions:] On successful loading, the range `[begin(), end())` +contains restored copies of every element in +`[m.get<i>().begin(), m.get<i>().end())`, though not necessarily in +the same order. + + +[blurb [*Operation:] saving of an `iterator` or `const_iterator` `it` to an output +archive (XML archive) ar.] + +* [*Requires: ] `it` is a valid `iterator` of the view. The associated +`bimap` has been previously saved. + + +[blurb [*Operation:] loading of an iterator or `const_iterator it`' from an +input archive (XML archive) ar.] + +* [*Postconditions:] On successful loading, if `it` was dereferenceable then +`*it`' is the restored copy of `*it`, otherwise `it`'` == end()`. +* [*Note:] It is allowed that `it` be a `const_iterator` and the restored +`it`' an `iterator`, or viceversa. + + +[blurb [*Operation:] saving of a local_iterator or const_local_iterator it +to an output archive (XML archive) ar.] + +* [*Requires: ] `it` is a valid local iterator of the view. The associated +`bimap` has been previously saved. + + +[blurb [*Operation:] loading of a `local_iterator` or `const_local_iterator` +`it`' from an input archive (XML archive) ar.] + +* [*Postconditions:] On successful loading, if `it` was dereferenceable then +`*it`' is the restored copy of `*it`; if `it` was `m.get<i>().end(n)` for some n, +then `it`'` == m`'`.get<i>().end(n)` (where `b` is the original `bimap`, +`b`' its restored copy and `i` is the ordinal of the index.) +* [*Note:] It is allowed that `it` be a `const_local_iterator` and the restored +`it`' a `local_iterator`, or viceversa. + + +[endsect] +[endsect] + +[endsect]
\ No newline at end of file diff --git a/libs/bimap/doc/reference/vector_of.qbk b/libs/bimap/doc/reference/vector_of.qbk new file mode 100644 index 0000000000..882302e28f --- /dev/null +++ b/libs/bimap/doc/reference/vector_of.qbk @@ -0,0 +1,843 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section vector_of Reference] + +[section Header "boost/bimap/vector_of.hpp" synopsis] + + namespace boost { + namespace bimaps { + + + template< class KeyType > + struct vector_of; + + struct vector_of_relation; + + + } // namespace bimap + } // namespace boost + + +[endsect] + +[section vector_of views] + +vector_of views are free-order sequences with constant time positional +access and random access iterators. Elements in a vector_of view are by +default sorted according to their order of insertion: this means that new elements +inserted through a different view of the `bimap` are appended to +the end of the vector_of view; additionally, facilities are provided for +further rearrangement of the elements. The public interface of vector_of views +includes that of list_of views, with differences in the complexity +of the operations, plus extra operations for positional access +(`operator[]` and `at()`) and for capacity handling. Validity of iterators and +references to elements is preserved in all operations, regardless of the +capacity status. + +As is the case with list_of views, vector_of views have the following +limitations with respect to STL sequence containers: + +* vector_of views +are not __SGI_ASSIGNABLE__ (like any other view.) +* Insertions into a vector_of view may fail due to clashings with other views. +This alters the semantics of the operations provided with respect to their analogues +in STL sequence containers. +* Elements in a vector_of view are not mutable, and can only be changed by +means of replace and modify member functions. + +Having these restrictions into account, vector of views are models of +__SGI_RANDOM_ACCESS_CONTAINER__ and __SGI_BACK_INSERTION_SEQUENCE__. Although these views +do not model __SGI_FRONT_INSERTION_SEQUENCE__, because front insertion and deletion +take linear time, front operations are nonetheless provided to match the interface +of list_of views. We only describe those types and operations that are either +not present in the concepts modeled or do not exactly conform to the requirements +for these types of containers. + + + namespace boost { + namespace bimaps { + namespace views { + + template< ``['-implementation defined parameter list-]`` > + class ``['-implementation defined view name-]`` + { + public: + + // types + + typedef ``['-unspecified-]`` value_type; + typedef ``['-unspecified-]`` allocator_type; + typedef ``['-unspecified-]`` reference; + typedef ``['-unspecified-]`` const_reference; + typedef ``['-unspecified-]`` iterator; + typedef ``['-unspecified-]`` const_iterator; + typedef ``['-unspecified-]`` size_type; + typedef ``['-unspecified-]`` difference_type; + typedef ``['-unspecified-]`` pointer; + typedef ``['-unspecified-]`` const_pointer; + typedef ``['-unspecified-]`` reverse_iterator; + typedef ``['-unspecified-]`` const_reverse_iterator; + + typedef ``['-unspecified-]`` info_type; + + // construct / copy / destroy + + this_type & operator=(this_type & x); + + template< class InputIterator > + void ``[link reference_vector_of_assign_iterator_iterator assign]``(InputIterator first, InputIterator last); + + void ``[link reference_vector_of_assign_size_value assign]``(size_type n, const value_type & value); + + allocator_type get_allocator() const; + + // iterators + + iterator begin(); + const_iterator begin() const; + + iterator end(); + const_iterator end() const; + + reverse_iterator rbegin(); + const_reverse_iterator rbegin() const; + + reverse_iterator rend(); + const_reverse_iterator rend() const; + + // capacity + + bool empty() const; + + size_type size() const; + + size_type max_size() const; + + size_type ``[link reference_vector_of_capacity capacity]``() const; + + void ``[link reference_vector_of_reserve_size reserve]``(size_type m); + + void ``[link reference_vector_of_resize_size_value resize]``(size_type n, const value_type & x = value_type()); + + // access + + const_reference operator[](size_type n) const; + + const_reference at(size_type n) const; + + const_reference front() const; + + const_reference back() const; + + // modifiers + + std::pair<iterator,bool> ``[link reference_vector_of_push_front_value push_front]``(const value_type & x); + void pop_front(); + + std::pair<iterator,bool> ``[link reference_vector_of_push_back_value push_back]``(const value_type & x); + void pop_back(); + + std::pair<iterator,bool> ``[link reference_vector_of_insert_iterator_value insert]``(iterator position, const value_type & x); + + void ``[link reference_vector_of_insert_iterator_size_value insert]``(iterator position, size_type m, const value_type & x); + + template< class InputIterator> + void ``[link reference_vector_of_insert_iterator_iterator_iterator insert]``(iterator position, InputIterator first, InputIterator last); + + iterator ``[link reference_vector_of_erase_iterator erase]``(iterator position); + iterator ``[link reference_vector_of_erase_iterator_iterator erase]``(iterator first, iterator last); + + bool ``[link reference_vector_of_replace_iterator_value replace]``(iterator position, const value_type & x); + + // Only in map views + // { + + template< class CompatibleKey > + bool ``[link reference_vector_of_replace_key_iterator_key replace_key]``(iterator position, const CompatibleKey & x); + + template< class CompatibleData > + bool ``[link reference_vector_of_replace_data_iterator_data replace_data]``(iterator position, const CompatibleData & x); + + template< class KeyModifier > + bool ``[link reference_vector_of_modify_key_iterator_modifier modify_key]``(iterator position, KeyModifier mod); + + template< class DataModifier > + bool ``[link reference_vector_of_modify_data_iterator_modifier modify_data]``(iterator position, DataModifier mod); + + // } + + + void clear(); + + // list operations + + void ``[link reference_vector_of_splice_iterator_this splice]``(iterator position, this_type & x); + void ``[link reference_vector_of_splice_iterator_this_iterator splice]``(iterator position, this_type & x, iterator i); + void ``[link reference_vector_of_splice_iterator_this_iterator_iterator splice]``( + iterator position, this_type & x, iterator first, iterator last); + + void ``[link reference_vector_of_remove_value remove]``(const value_type & value); + + template< class Predicate > + void ``[link reference_vector_of_remove_if_predicate remove_if]``(Predicate pred); + + void ``[link reference_vector_of_unique unique]``(); + + template< class BinaryPredicate > + void ``[link reference_vector_of_unique_predicate unique]``(BinaryPredicate binary_pred); + + void ``[link reference_vector_of_merge_this merge]``(this_type & x); + + template< typename Compare > + void ``[link reference_vector_of_merge_this_compare merge]``(this_type & x, Compare comp); + + void ``[link reference_vector_of_sort sort]``(); + + template< typename Compare > + void ``[link reference_vector_of_sort_compare sort]``(Compare comp); + + void ``[link reference_vector_of_reverse reverse]``(); + + // rearrange operations + + void ``[link reference_vector_of_relocate_iterator_iterator relocate]``(iterator position, iterator i); + void ``[link reference_vector_of_relocate_iterator_iterator_iterator relocate]``(iterator position, iterator first, iterator last); + }; + + // view comparison + + bool operator==(const this_type & v1, const this_type & v2 ); + bool operator< (const this_type & v1, const this_type & v2 ); + bool operator!=(const this_type & v1, const this_type & v2 ); + bool operator> (const this_type & v1, const this_type & v2 ); + bool operator>=(const this_type & v1, const this_type & v2 ); + bool operator<=(const this_type & v1, const this_type & v2 ); + + } // namespace views + } // namespace bimap + } // namespace boost + + + +In the case of a `bimap< vector_of<Left>, ... >` + +In the set view: + + typedef signature-compatible with relation< Left, ... > key_type; + typedef signature-compatible with relation< Left, ... > value_type; + +In the left map view: + + typedef Left key_type; + typedef ... data_type; + + typedef signature-compatible with std::pair< Left, ... > value_type; + +In the right map view: + + typedef ... key_type; + typedef Left data_type; + + typedef signature-compatible with std::pair< ... , Left > value_type; + + +[#vector_of_complexity_signature] + +[section Complexity signature] + +Here and in the descriptions of operations of `vector_of` views, we adopt +the scheme outlined in the +[link complexity_signature_explanation complexity signature section]. +The complexity signature of `vector_of` view is: + +* copying: `c(n) = n * log(n)`, +* insertion: `i(n) = 1` (amortized constant), +* hinted insertion: `h(n) = 1` (amortized constant), +* deletion: `d(n) = m`, where m is the distance from the deleted element to the +end of the sequence, +* replacement: `r(n) = 1` (constant), +* modifying: `m(n) = 1` (constant). + +The following expressions are also used as a convenience for writing down some +of the complexity formulas: + +[blurb +`shl(a,b) = a+b` if a is nonzero, 0 otherwise. +`rel(a,b,c) =` if `a<b`, `c-a`, else `a-b`, +] + +(`shl` and `rel` stand for ['shift left] and ['relocate], respectively.) + +[endsect] + +[section Instantiation types] + +`vector_of` views are instantiated internally to `bimap` and specified +by means of the collection type specifiers and the bimap itself. +Instantiations are dependent on the following types: + +* `Value` from `vector_of`, +* `Allocator` from `bimap`, + +[endsect] + +[section Constructors, copy and assignment] + +As explained in the views concepts section, +views do not have public constructors or destructors. +Assignment, on the other hand, is provided. + + this_type & operator=(const this_type & x); + +* [*Effects: ] `a=b;` +where a and b are the `bimap` objects to which `*this` and +`x` belong, respectively. +* [*Returns: ] `*this`. + + +[#reference_vector_of_assign_iterator_iterator] + + template< class InputIterator > + void assign(InputIterator first, InputIterator last); + +* [*Requires: ] `InputIterator` is a model of __SGI_INPUT_ITERATOR__ over elements +of type `value_type` or a type convertible to `value_type`. `first` and `last` are +not iterators into any view of the `bimap` to which this +view belongs. `last` is reachable from `first`. +* [*Effects: ] `clear(); insert(end(),first,last);` + + +[#reference_vector_of_assign_size_value] + + void assign(size_type n, const value_type & value); + +* [*Effects: ] `clear(); for(size_type i = 0; i < n; ++n) push_back(v);` + +[endsect] + +[section Capacity operations] + +[#reference_vector_of_capacity] + + size_type capacity() const; + +* [*Returns:] The total number of elements `c` such that, when `size() < c`, +back insertions happen in constant time (the general case as described by +i(n) is ['amortized] constant time.) +* [*Note:] Validity of iterators and references to elements is preserved +in all insertions, regardless of the capacity status. + + +[#reference_vector_of_reserve_size] + + void reserve(size_type m); + +* [*Effects:] If the previous value of `capacity()` was greater than or equal +to `m`, nothing is done; otherwise, the internal capacity is changed so that +`capacity()>=m`. +* [*Complexity:] If the capacity is not changed, constant; otherwise O(n). +* [*Exception safety:] If the capacity is not changed, nothrow; otherwise, strong. + + +[#reference_vector_of_resize_size_value] + + void resize(size_type n, const value_type & x = value_type()); + +* [*Effects: ] `if( n > size() ) insert(end(), n-size(), x);` +`else if( n<size() ) erase(begin()+n,end());` +* [*Note:] If an expansion is requested, the size of the view is not guaranteed +to be n after this operation (other views may ban insertions.) + + +[endsect] + +[section Modifiers] + +[#reference_vector_of_push_front_value] + + std::pair<iterator,bool> push_front(const value_type & x); + +* [*Effects:] Inserts x at the beginning of the sequence if no other view +of the `bimap` bans the insertion. +* [*Returns:] The return value is a pair `p`. `p.second` is `true` if and only if +insertion took place. On successful insertion, `p.first` points to the element +inserted; otherwise, `p.first` points to an element that caused the insertion +to be banned. Note that more than one element can be causing insertion not +to be allowed. +* [link vector_of_complexity_signature [*Complexity:]] O(n+I(n)). +* [*Exception safety:] Strong. + + +[#reference_vector_of_push_back_value] + + std::pair<iterator,bool> push_back(const value_type & x); + +* [*Effects:] Inserts `x` at the end of the sequence if no other view of +the `bimap` bans the insertion. +* [*Returns:] The return value is a pair `p`. `p.second` is `true` if and only +if insertion took place. On successful insertion, `p.first` points to the +element inserted; otherwise, `p.first` points to an element that caused +the insertion to be banned. Note that more than one element can be +causing insertion not to be allowed. +* [link vector_of_complexity_signature [*Complexity:]] O(I(n)). +* [*Exception safety:] Strong. + + +[#reference_vector_of_insert_iterator_value] + + std::pair<iterator,bool> insert(iterator position, const value_type & x); + +* [*Requires: ] `position` is a valid iterator of the view. +* [*Effects:] Inserts `x` before position if insertion is allowed by all +other views of the `bimap`. +* [*Returns:] The return value is a pair `p`. `p.second` is `true` if and only +if insertion took place. On successful insertion, `p.first` points to the +element inserted; otherwise, `p.first` points to an element that caused the +insertion to be banned. Note that more than one element can be causing +insertion not to be allowed. +* [link vector_of_complexity_signature [*Complexity:]] O(shl(end()-position,1) + I(n)). +* [*Exception safety:] Strong. + + +[#reference_vector_of_insert_iterator_size_value] + + void insert(iterator position, size_type m, const value_type & x); + +* [*Requires: ] `position` is a valid iterator of the view. +* [*Effects: ] `for(size_type i = 0; i < m; ++i) insert(position, x);` +* [link vector_of_complexity_signature +[*Complexity:]] O(shl(end()-position,m) + m*I(n+m)). + + +[#reference_vector_of_insert_iterator_iterator_iterator] + + template< class InputIterator > + void insert(iterator position, InputIterator first, InputIterator last); + +* [*Requires: ] `position` is a valid iterator of the view. `InputIterator` +is a model of __SGI_INPUT_ITERATOR__ over elements of type `value_type` or a type +convertible to `value_type`. `first` and `last` are not iterators into any view +of the `bimap` to which this view belongs. `last` is reachable +from `first`. +* [*Effects: ] `while(first!=last)insert(position,*first++);` +* [link vector_of_complexity_signature +[*Complexity:]] O(shl(end()-position,m) + m*I(n+m)), where m is the number +of elements in `[first,last)`. +* [*Exception safety:] Basic. + + +[#reference_vector_of_erase_iterator] + + iterator erase(iterator position); + +* [*Requires: ] `position` is a valid dereferenceable iterator of the view. +* [*Effects:] Deletes the element pointed to by `position`. +* [*Returns:] An iterator pointing to the element immediately following the +one that was deleted, or `end()` if no such element exists. +* [link vector_of_complexity_signature [*Complexity:]] O(D(n)). +* [*Exception safety:] nothrow. + + +[#reference_vector_of_erase_iterator_iterator] + + iterator erase(iterator first, iterator last); + +* [*Requires: ] `[first,last)` is a valid range of the view. +* [*Effects:] Deletes the elements in `[first,last)`. +* [*Returns:] last. +* [link vector_of_complexity_signature +[*Complexity:]] O(m*D(n)), where m is the number of elements in `[first,last)`. +* [*Exception safety:] nothrow. + + +[#reference_vector_of_replace_iterator_value] + + bool replace(iterator position, const value_type & x); + +* [*Requires: ] `position` is a valid dereferenceable iterator of the view. +* [*Effects:] Assigns the value x to the element pointed to by position into +the `bimap` to which the view belongs if replacing is allowed +by all other views of the `bimap`. +* [*Postconditions:] Validity of position is preserved in all cases. +* [*Returns: ] `true` if the replacement took place, `false` otherwise. +* [link vector_of_complexity_signature +[*Complexity:]] O(R(n)). +* [*Exception safety:] Strong. If an exception is thrown by some user-provided +operation the `bimap` to which the view belongs remains in its +original state. + + + +[#reference_vector_of_replace_key_iterator_key] + + template< class CompatibleKey > + bool replace_key(iterator position, const CompatibleKey & x); + +* [*Requires: ] `position` is a valid dereferenceable iterator of the set view. +`CompatibleKey` can be assigned to `key_type`. +* [*Effects:] Assigns the value `x` to `e.first`, where `e` is the element pointed +to by `position` into the `bimap` to which the set view belongs if replacing is allowed by +all other views of the `bimap`. +* [*Postconditions:] Validity of position is preserved in all cases. +* [*Returns: ] `true` if the replacement took place, `false` otherwise. +* [link vector_of_complexity_signature +[*Complexity:]] O(R(n)). +* [*Exception safety:] Strong. If an exception is thrown by some user-provided +operation, the `bimap` to which the set view belongs remains in +its original state. + + +[#reference_vector_of_replace_data_iterator_data] + + template< class CompatibleData > + bool replace_data(iterator position, const CompatibleData & x); + +* [*Requires: ] `position` is a valid dereferenceable iterator of the set view. +`CompatibleKey` can be assigned to `data_type`. +* [*Effects:] Assigns the value `x` to `e.second`, where `e` is the element pointed +to by `position` into the `bimap` to which the set view belongs if replacing is allowed by +all other views of the `bimap`. +* [*Postconditions:] Validity of position is preserved in all cases. +* [*Returns: ] `true` if the replacement took place, `false` otherwise. +* [link vector_of_complexity_signature +[*Complexity:]] O(R(n)). +* [*Exception safety:] Strong. If an exception is thrown by some user-provided +operation, the `bimap` to which the set view belongs remains in +its original state. + + +[#reference_vector_of_modify_key_iterator_modifier] + + template< class KeyModifier > + bool modify_key(iterator position, KeyModifier mod); + +* [*Requires: ] `KeyModifier` is a model of __SGI_UNARY_FUNCTION__ accepting arguments of +type: `key_type&`; `position` is a valid dereferenceable iterator of the view. +* [*Effects:] Calls `mod(e.first)` where e is the element pointed to by position and +rearranges `*position` into all the views of the `bimap`. +If the rearrangement fails, the element is erased. +It is successful if the rearrangement is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of `position` is preserved if the operation succeeds. +* [*Returns: ] `true` if the operation succeeded, `false` otherwise. +* [link vector_of_complexity_signature +[*Complexity:]] O(M(n)). +* [*Exception safety:] Basic. If an exception is thrown by some user-provided +operation (except possibly mod), then the element pointed to by position is erased. +* [*Note:] Only provided for map views. + + +[#reference_vector_of_modify_data_iterator_modifier] + + template< class DataModifier > + bool modify_data(iterator position, DataModifier mod); + +* [*Requires: ] `DataModifier` is a model of __SGI_UNARY_FUNCTION__ accepting arguments of +type: `data_type&`; `position` is a valid dereferenceable iterator of the view. +* [*Effects:] Calls `mod(e.second)` where e is the element pointed to by position and +rearranges `*position` into all the views of the `bimap`. +If the rearrangement fails, the element is erased. +It is successful if the rearrangement is allowed by all other views of the `bimap`. +* [*Postconditions:] Validity of `position` is preserved if the operation succeeds. +* [*Returns: ] `true` if the operation succeeded, `false` otherwise. +* [link vector_of_complexity_signature +[*Complexity:]] O(M(n)). +* [*Exception safety:] Basic. If an exception is thrown by some user-provided +operation (except possibly mod), then the element pointed to by position is erased. +* [*Note:] Only provided for map views. + +[/ +[#reference_vector_of_modify_iterator_modifier] + + template< class Modifier > + bool modify(iterator position, Modifier mod); + +* [*Requires: ] `Modifier` is a model of __SGI_BINARY_FUNCTION__ accepting arguments of +type: `first_type&` and `second_type&` for ['Map View] or `left_type&` and `right_type&` +for ['Set View]; `position` is a valid dereferenceable iterator of the view. +* [*Effects:] Calls `mod(e.first,e.second)` for ['Map View:] or calls `mod(e.left,e.right)` +for ['Set View] where e is the element pointed to by `position` and +rearranges `*position` into all the views of the `bimap`. +Rearrangement on `vector_of` views does not change the position of the +element with respect to the view; rearrangement on other views may or +might not suceed. If the rearrangement fails, the element is erased. +* [*Postconditions:] Validity of `position` is preserved if the operation succeeds. +* [*Returns: ] `true` if the operation succeeded, `false` otherwise. +* [link vector_of_complexity_signature [*Complexity:]] O(M(n)). +* [*Exception safety:] Basic. If an exception is thrown by some user-provided +operation (except possibly `mod`), then the element pointed to by position +is erased. +] + + +[endsect] + +[section List operations] + +`vector_of` views replicate the interface of `list_of` views, which +in turn includes the list operations provided by `std::list`. The syntax and +behavior of these operations exactly matches those of `list_of` views, but +the associated complexity bounds differ in general. + + +[#reference_vector_of_splice_iterator_this] + + void splice(iterator position, this_type & x); + +* [*Requires: ] `position` is a valid iterator of the view. `&x!=this`. +* [*Effects:] Inserts the contents of `x` before position, in the same order +as they were in `x`. Those elements successfully inserted are erased from `x`. +* [link vector_of_complexity_signature +[*Complexity:]] O(shl(end()-position,x.size()) + x.size()*I(n+x.size()) + x.size()*D(x.size())). +* [*Exception safety:] Basic. + + +[#reference_vector_of_splice_iterator_this_iterator] + + void splice(iterator position, this_type & x,iterator i); + +* [*Requires: ] `position` is a valid iterator of the view. `i` is a valid +dereferenceable iterator `x`. +* [*Effects:] Inserts the element pointed to by `i` before `position`: if +insertion is successful, the element is erased from `x`. In the special +case `&x==this`, no copy or deletion is performed, and the operation is +always successful. If `position==i`, no operation is performed. +* [*Postconditions:] If `&x==this`, no iterator or reference is invalidated. +* [link vector_of_complexity_signature +[*Complexity:]] If `&x==this`, O(rel(position,i,i+1)); +otherwise O(shl(end()-position,1) + I(n) + D(n)). +* [*Exception safety:] If `&x==this`, nothrow; otherwise, strong. + + +[#reference_vector_of_splice_iterator_this_iterator_iterator] + + void splice(iterator position, this_type & x, iterator first, iterator last); + +* [*Requires: ] `position` is a valid iterator of the view. `first` and +`last` are valid iterators of `x`. `last` is reachable from `first`. `position` is +not in the range `[first,last)`. +* [*Effects:] For each element in the range `[first,last)`, insertion is +tried before `position`; if the operation is successful, the element is +erased from `x`. In the special case `&x==this`, no copy or deletion is +performed, and insertions are always successful. +* [*Postconditions:] If `&x==this`, no iterator or reference is invalidated. +* [link vector_of_complexity_signature +[*Complexity:]] If `&x==this`, O(rel(position,first,last)); +otherwise O(shl(end()-position,m) + m*I(n+m) + m*D(x.size())) +where m is the number of elements in `[first,last)`. +* [*Exception safety:] If `&x==this`, nothrow; otherwise, basic. + + +[#reference_vector_of_remove_value] + + void remove(const value_type & value); + +* [*Effects:] Erases all elements of the view which compare equal to `value`. +* [link vector_of_complexity_signature +[*Complexity:]] O(n + m*D(n)), where m is the number of elements erased. +* [*Exception safety:] Basic. + + +[#reference_vector_of_remove_if_predicate] + + template< class Predicate > + void remove_if(Predicate pred); + +* [*Effects:] Erases all elements `x` of the view for which `pred(x)` holds. +* [link vector_of_complexity_signature +[*Complexity:]] O(n + m*D(n)), where m is the number of elements erased. +* [*Exception safety:] Basic. + + +[#reference_vector_of_unique] + + void unique(); + +* [*Effects:] Eliminates all but the first element from every consecutive +group of equal elements referred to by the iterator `i` in the range +`[first+1,last)` for which `*i==*(i-1)`. +* [link vector_of_complexity_signature +[*Complexity:]] O(n + m*D(n)), where m is the number of elements erased. +* [*Exception safety:] Basic. + + +[#reference_vector_of_unique_predicate] + + template< class BinaryPredicate > + void unique(BinaryPredicate binary_pred); + +* [*Effects:] Eliminates all but the first element from every consecutive +group of elements referred to by the iterator i in the range `[first+1,last)` +for which `binary_pred(*i, *(i-1))` holds. +* [link vector_of_complexity_signature +[*Complexity:]] O(n + m*D(n)), where m is the number of elements erased. +* [*Exception safety:] Basic. + + +[#reference_vector_of_merge_this] + + void merge(this_type & x); + +* [*Requires: ] `std::less<value_type>` is a __SGI_STRICT_WEAK_ORDERING__ over +`value_type`. Both the view and `x` are sorted according to `std::less<value_type>`. +* [*Effects:] Attempts to insert every element of x into the corresponding +position of the view (according to the order). Elements successfully +inserted are erased from `x`. The resulting sequence is stable, i.e. equivalent +elements of either container preserve their relative position. In the special +case `&x==this`, no operation is performed. +* [*Postconditions:] Elements in the view and remaining elements in `x` are +sorted. Validity of iterators to the view and of non-erased elements of `x` +references is preserved. +* [link vector_of_complexity_signature +[*Complexity:]] If `&x==this`, constant; +otherwise O(n + x.size()*I(n+x.size()) + x.size()*D(x.size())). +* [*Exception safety:] If `&x==this`, nothrow; otherwise, basic. + + +[#reference_vector_of_merge_this_compare] + + template< class Compare > + void merge(this_type & x, Compare comp); + +* [*Requires: ] `Compare` is a __SGI_STRICT_WEAK_ORDERING__ over `value_type`. +Both the view and `x` are sorted according to comp. +* [*Effects:] Attempts to insert every element of `x` into the corresponding +position of the view (according to `comp`). Elements successfully inserted +are erased from `x`. The resulting sequence is stable, i.e. equivalent +elements of either container preserve their relative position. In the +special case `&x==this`, no operation is performed. +* [*Postconditions:] Elements in the view and remaining elements in `x` are +sorted according to `comp`. Validity of iterators to the view and of +non-erased elements of `x` references is preserved. +* [link vector_of_complexity_signature +[*Complexity:]] If `&x==this`, constant; +otherwise O(n + x.size()*I(n+x.size()) + x.size()*D(x.size())). +* [*Exception safety:] If `&x==this`, nothrow; otherwise, basic. + + +[#reference_vector_of_sort] + + void sort(); + +* [*Requires: ] `std::less<value_type>` is a __SGI_STRICT_WEAK_ORDERING__ over `value_type`. +* [*Effects:] Sorts the view according to `std::less<value_type>`. +The sorting is stable, i.e. equivalent elements preserve their relative position. +* [*Postconditions:] Validity of iterators and references is preserved. +* [*Complexity:] O(n*log(n)). +* [*Exception safety:] Basic. + + +[#reference_vector_of_sort_compare] + + template< class Compare > + void sort(Compare comp); + +* [*Requires:] Compare is a __SGI_STRICT_WEAK_ORDERING__ over `value_type`. +* [*Effects:] Sorts the view according to `comp`. The sorting is stable, i.e. +equivalent elements preserve their relative position. +* [*Postconditions:] Validity of iterators and references is preserved. +* [*Complexity:] O(n*log(n)). +* [*Exception safety:] Basic. + + +[#reference_vector_of_reverse] + + void reverse(); + +* [*Effects:] Reverses the order of the elements in the view. +* [*Postconditions:] Validity of iterators and references is preserved. +* [*Complexity:] O(n). +* [*Exception safety:] nothrow. + + +[endsect] + +[section Rearrange operations] + +These operations, without counterpart in `std::list` (although splice provides +partially overlapping functionality), perform individual and global repositioning +of elements inside the index. + + +[#reference_vector_of_relocate_iterator_iterator] + + void relocate(iterator position, iterator i); + +* [*Requires: ] `position` is a valid iterator of the view. `i` is a valid +dereferenceable iterator of the view. +* [*Effects:] Inserts the element pointed to by `i` before `position`. +If `position==i`, no operation is performed. +* [*Postconditions:] No iterator or reference is invalidated. +* [*Complexity:] Constant. +* [*Exception safety:] nothrow. + + +[#reference_vector_of_relocate_iterator_iterator_iterator] + + void relocate(iterator position, iterator first, iterator last); + +* [*Requires: ] `position` is a valid iterator of the view. `first` and `last` are +valid iterators of the view. `last` is reachable from `first`. `position` is not +in the range `[first,last)`. +* [*Effects:] The range of elements `[first,last)` is repositioned just before +`position`. +* [*Postconditions:] No iterator or reference is invalidated. +* [*Complexity:] Constant. +* [*Exception safety:] nothrow. + + +[endsect] + + +[section Serialization] + +Views cannot be serialized on their own, but only as part of the `bimap` +into which they are embedded. In describing the additional preconditions and guarantees +associated to `vector_of` views with respect to serialization of their embedding +containers, we use the concepts defined in the `bimap` serialization section. + +[blurb [*Operation:] saving of a `bimap` b to an output archive (XML archive) ar.] + +* [*Requires:] No additional requirements to those imposed by the container. + + +[blurb [*Operation:] loading of a `bimap` b' from an input archive (XML archive) ar.] + +* [*Requires:] No additional requirements to those imposed by the container. +* [*Postconditions:] On successful loading, each of the elements of `[begin(), end())` is a +restored copy of the corresponding element in `[m.get<i>().begin(), m.get<i>().end())`, +where `i` is the position of the `vector_of` view in the container. + + + +[blurb [*Operation:] saving of an `iterator` or `const_iterator` `it` to an output archive (XML archive) ar.] + +* [*Requires: ] `it` is a valid iterator of the view. The associated `bimap` +has been previously saved. + + + +[blurb [*Operation:] loading of an `iterator` or `const_iterator` `it`' from an input archive (XML archive) ar.] + +* [*Postconditions:] On successful loading, if it was dereferenceable then `*it`' is the +restored copy of `*it`, otherwise `it`'`==end()`. +* [*Note:] It is allowed that it be a `const_iterator` and the restored `it`' an `iterator`, +or viceversa. + + +[endsect] +[endsect] + + +[endsect]
\ No newline at end of file diff --git a/libs/bimap/doc/release_notes.qbk b/libs/bimap/doc/release_notes.qbk new file mode 100644 index 0000000000..e093aa2666 --- /dev/null +++ b/libs/bimap/doc/release_notes.qbk @@ -0,0 +1,19 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section Release notes] + +Not yet released. + +[endsect]
\ No newline at end of file diff --git a/libs/bimap/doc/test_suite.qbk b/libs/bimap/doc/test_suite.qbk new file mode 100644 index 0000000000..c6213b8aff --- /dev/null +++ b/libs/bimap/doc/test_suite.qbk @@ -0,0 +1,147 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section Test suite] + +The Boost.Bimap test suite exercises the whole spectrum of functionalities provided by the library. +Although the tests are not meant to serve as a learning guide, the interested reader may find it +useful to inspect the source code to gain familiarity with some of the least common features +offered by Boost.Bimap. + +[table +[[Program ][Description ] +] +[[[@../../test/test_tagged.cpp + test_tagged.cpp ]] + [Tagged idiom checks ]] + +[[[@../../test/test_mutant.cpp + test_mutant.cpp ]] + [Test the mutant idiom ]] + +[[[@../../test/test_structured_pair.cpp + test_structured_pair.cpp ]] + [Test structured pair class ]] + +[[[@../../test/test_mutant_relation.cpp + test_mutant_relation.cpp ]] + [Test the relation class ]] + +[[[@../../test/test_bimap_set_of.cpp + test_bimap_set_of.cpp ]] + [Library interface check ]] + +[[[@../../test/test_bimap_multiset_of.cpp + test_bimap_multiset_of.cpp ]] + [Library interface check ]] + +[[[@../../test/test_bimap_unordered_set_of.cpp + test_bimap_unordered_set_of.cpp ]] + [Library interface check ]] + +[[[@../../test/test_bimap_unordered_multiset_of.cpp + test_bimap_unordered_multiset_of.cpp ]] + [Library interface check ]] + +[[[@../../test/test_bimap_list_of.cpp + test_bimap_list_of.cpp ]] + [Library interface check ]] + +[[[@../../test/test_bimap_vector_of.cpp + test_bimap_vector_of.cpp ]] + [Library interface check ]] + +[[[@../../test/test_bimap_convenience_header.cpp + test_bimap_convenience_header.cpp ]] + [Library interface check ]] + +[[[@../../test/test_bimap_ordered.cpp + test_bimap_ordered.cpp ]] + [Test set and multiset based bimaps ]] + +[[[@../../test/test_bimap_unordered.cpp + test_bimap_unordered.cpp ]] + [Test unordered_set and unordered_multiset based bimaps ]] + +[[[@../../test/test_bimap_sequenced.cpp + test_bimap_sequenced.cpp ]] + [Test list and vector based bimaps ]] + +[[[@../../test/test_bimap_unconstrained.cpp + test_bimap_unconstrained.cpp ]] + [Test bimaps with unconstrained views ]] + +[[[@../../test/test_bimap_serialization.cpp + test_bimap_serialization.cpp ]] + [Serialization support checks ]] + +[[[@../../test/test_bimap_property_map.cpp + test_bimap_property_map.cpp ]] + [Property map concepts for the set and unordered set views ]] + +[[[@../../test/test_bimap_modify.cpp + test_bimap_modify.cpp ]] + [`replace`, `modify` and `operator[]` ]] + +[[[@../../test/test_bimap_lambda.cpp + test_bimap_lambda.cpp ]] + [Test lambda modified idom support ]] + +[[[@../../test/test_bimap_assign.cpp + test_bimap_assign.cpp ]] + [Test Boost.Assign support ]] + +[[[@../../test/test_bimap_project.cpp + test_bimap_project.cpp ]] + [Projection of iterators support ]] + +[[[@../../test/test_bimap_operator_bracket.cpp + test_bimap_operator_bracket.cpp ]] + [`operator[]` and `at()` functions ]] + +[[[@../../test/test_bimap_info.cpp + test_bimap_info.cpp ]] + [Information hooking support ]] + +[[[@../../test/test_bimap_extra.cpp + test_bimap_extra.cpp ]] + [Additional checks ]] + +[[[@../../test/compile_fail/test_bimap_info_1.cpp + test_bimap_info_1.cpp ]] + [Information hooking compilation fail test ]] + +[[[@../../test/compile_fail/test_bimap_info_2.cpp + test_bimap_info_2.cpp ]] + [Information hooking compilation fail test ]] + +[[[@../../test/compile_fail/test_bimap_info_3.cpp + test_bimap_info_3.cpp ]] + [Information hooking compilation fail test ]] + +[[[@../../test/compile_fail/test_bimap_mutable_1.cpp + test_bimap_mutable_1.cpp ]] + [Mutable members compilation fail test ]] + +[[[@../../test/compile_fail/test_bimap_mutable_2.cpp + test_bimap_mutable_2.cpp ]] + [Mutable members compilation fail test ]] + +[[[@../../test/compile_fail/test_bimap_mutable_3.cpp + test_bimap_mutable_3.cpp ]] + [Mutable members compilation fail test ]] + +] + +[endsect]
\ No newline at end of file diff --git a/libs/bimap/doc/toolbox.qbk b/libs/bimap/doc/toolbox.qbk new file mode 100644 index 0000000000..3ced8740ae --- /dev/null +++ b/libs/bimap/doc/toolbox.qbk @@ -0,0 +1,75 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section Bimap Toolbox] + +[section Mutant] + +[tip +A mutant class defines storage compatible views in its declaration. +You can the use the mutate<View>(m) function to get a view of the +data with zero overhead. +] + +__UNDER_CONSTRUCTION__ + +[endsect] + +[section Structured_pair] + +[tip +A structured pair allows you to control the order of the two types. +You can instantiate it so the ['second] member appears in the first +position. +] + +__UNDER_CONSTRUCTION__ + + +[endsect] + +[section Tagged] + +[tip +Tagged idiom and support metafunctions. +] + +__UNDER_CONSTRUCTION__ + + +[endsect] + +[section Relation] + +[tip +The bidirectional std::pair cousin. +] + +__UNDER_CONSTRUCTION__ + +[endsect] + +[section Container_adaptor] + +[tip +Easy way to adapt a container so it behaves different in some aspect. +It is the same concept that is use in iterator_adaptor. +] + +__UNDER_CONSTRUCTION__ + +[endsect] + + +[endsect] diff --git a/libs/bimap/doc/tutorial.qbk b/libs/bimap/doc/tutorial.qbk new file mode 100644 index 0000000000..3d661ff3cb --- /dev/null +++ b/libs/bimap/doc/tutorial.qbk @@ -0,0 +1,1057 @@ +[/license + +Boost.Bimap + +Copyright (c) 2006-2007 Matias Capeletto + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +] + +[/ QuickBook Document version 1.4 ] + +[section The tutorial] + +[section Roadmap] + +# Boost.Bimap is intuitive because it is based on the standard +template library. New concepts are however presented to extend the +standard maps to bidirectional maps. The first step is to gain a +firm grasp of the bimap framework. The first section +([link boost_bimap.the_tutorial.discovering_the_bimap_framework Discovering the bimap framework]) +aims to explain this. + +# Boost.Bimap offers much more than just a one-to-one ordered unique +bidirectional map. It is possible to control the collection type of each side +of the relationship that the bimap represents, giving one-to-many +containers, hashed bidirectional containers and others that may be more +suitable to the the task at hand. The second section +([link boost_bimap.the_tutorial.controlling_collection_types Controlling collection types]) +explains how to instantiate a bimap with different collection constraints. + +# The section +([link boost_bimap.the_tutorial.the_collection_of_relations_type The "collection of relations" type]) +explains how to create new types of bidirectional maps using custom collection types. + +# In the section [link boost_bimap.the_tutorial.differences_with_standard_maps Differences with standard maps] we will learn about the subtle differences between a bimap map view and a standard map. + +# The section [link boost_bimap.the_tutorial.useful_functions Useful functions] provides information +about functions of a bimap that are not found in the STL. + +# The types of a bimap can be tagged so that each side is accessible +by something closer to the problem than left and right. This leads to +more readable, self-documenting code. The fourth section +([link boost_bimap.the_tutorial.bimaps_with_user_defined_names Bimaps with user defined names]) shows +how to use this feature. + +# The bimap mapping framework allows to disable a view of a bimap, including the standard +mapping containers as a particular case. The section +[link boost_bimap.the_tutorial.unconstrained_sets Unconstrained Sets] explains how they work. + +# The section [link boost_bimap.the_tutorial.additional_information Additional information] +explains how to attach information to each relation of a bimap. + +# The final section +([link boost_bimap.the_tutorial.complete_instantiation_scheme Complete Instantiation Scheme]) +summarizes bimap instantiation and explains how change the allocator type to be used. + +[endsect] + +[section Discovering the bimap framework] + +[section Interpreting bidirectional maps] + +One way to interpret bidirectional maps is as a function between two +collections of data, lets call them the left and the right collection. +An element in this bimap is a relation between an element from the left +collection and an element from the right collection. +The types of both collections defines the bimap behaviour. We can view +the stored data from the left side, as a mapping between keys from the +left collection and data from the right one, or from the right side, as +a mapping between keys from the right collection and data from the +left collection. + +[endsect] + +[section Standard mapping framework] + +Relationships between data in the STL are represented by maps. A +standard map is a directed relation of keys from a left collection and +data from a right unconstrained collection. +The following diagram shows the relationship represented and the +user's viewpoint. + +__STANDARD_MAPPING_FRAMEWORK__ + +The left collection type depends on the selected map type. For example if the the map type is `std::multimap` the collection type of X is a `multiset_of`. +The following table shows the equivalent types for the std associative containers. + +[table std associative containers +[[container ][left collection type ][right collection type]] +[[`map` ][`set_of` ][no constraints ]] +[[`multimap` ][`multiset_of` ][no constraints ]] +[[`unordered_map` ][`unordered_set_of` ][no constraints ]] +[[`unordered_multimap`][`unordered_multiset_of` ][no constraints ]] +] + +[endsect] + +[section Bimap mapping framework] + +Boost.Bimap design is based on the STL, and extends the framework in a natural way. +The following diagram represents the new situation. + +__EXTENDED_MAPPING_FRAMEWORK__ + +Notice that now the `std::maps` are a particular case of a Boost.Bimap +container, where you can view only one side of the relationship and can +control the constraints of only one of the collections. Boost.Bimap +allows the user to view the relationship from three viewpoints. +You can view it from one side, obtaining a `std::map` compatible +container, or you can work directly with the whole relation. + +The next diagram shows the layout of the relation and pairs of a bimap. It is +the one from the ['one minute tutorial] + +__RELATION_AND_PAIR__ + +Bimap pairs are signature-compatible with standard pairs but are different +from them. As you will see in other sections they can be tagged with user +defined names and additional information can be attached to them. You can +convert from `std::pairs` to bimap pairs directly but the reverse conversion +is not provided. This mean that you can insert elements in a bimap using +algorithms like `std::copy` from containers `like std::map`, or use `std::make_pair` +to add new elements. However it is best to use `bm.left.insert( bm_type::left_value_type(f,s) )` instead of `bm.insert( std::make_pair(f,s) )` to avoid an extra call to the +copy constructor of each type. + +The following code snippet shows the relation between a bimap and standard +maps. + +[note +You have to used references to views, and not directly views object. +Views cannot be constructed as separate objects from the container they +belong to, so the following: +`` +// Wrong: we forgot the & after bm_type::left_type +bm_type::left_map lm = bm.left; +`` +does not compile, since it is trying to construct the view object `lm`. +This is a common source of errors in user code. +] + +[@../../example/standard_map_comparison.cpp Go to source code] + +[import ../example/standard_map_comparison.cpp] + +[code_standard_map_comparison] + +[endsect] + +[endsect] + +[section Controlling collection types] + +[section Freedom of choice] + +As has already been said, in STL maps, you can only control the +constraints from one of the collections, namely the one that you are +viewing. In Boost.Bimap, you can control both and it is as easy as using the STL. + +__EXTENDED_MAPPING_FRAMEWORK__ + +The idea is to use the same constraint names that are used in the +standard. If you don't specify the collection type, Boost.Bimap assumes +that the collection is a set. The instantiation of a bimap with custom +collection types looks like this: + + typedef bimap< ``*CollectionType*``_of<A>, ``*CollectionType*``_of<B> > bm_type; + +The following is the list of all supported collection types. + + +[table Collection of Key Types +[[name ][Features ][map view type ]] +[[`set_of` ][['ordered, unique]][`map` ]] +[[`multiset_of` ][['ordered ]][`multimap` ]] +[[`unordered_set_of` ][['hashed, unique ]][`unordered_map` ]] +[[`unordered_multiset_of`][['hashed ]][`unordered_multimap` ]] +[[`list_of` ][['sequenced ]][`list_map` ]] +[[`vector_of` ][['random access ]][`vector_map` ]] +[[`unconstrained_set_of` ][['unconstrained ]][['can not be viewed] ]] +] + + +`list_of` and `vector_of` map views are not associated with any existing STL +associative containers. They are two examples of unsorted associative +containers. `unconstrained_set_of` allow the user to ignore a view. This +will be explained later. + +__BIMAP_STRUCTURES__ + +The selection of the collection type affects the possible operations that you +can perform with each side of the bimap and the time it takes to do +each. If we have: + + typedef bimap< ``*CollectionType*``_of<A>, ``*CollectionType*``_of<B> > bm_type; + bm_type bm; + +The following now describes the resulting map views of the bidirectional +map. + +* `bm.left` is signature-compatible with *LeftMapType*`<A,B>` +* `bm.right` is signature-compatible with *RightMapType*`<B,A>` + +[endsect] + +[section Configuration parameters] + +Each collection type template has different parameters to control its +behaviour. For example, in `set_of` specification, you can pass a Functor +type that compares two types. All of these parameters are exactly the +same as those of the standard library container, except for the +allocator type. You will learn later how to change the allocator for a +bimap. + +The following table lists the meanings of each collection type's parameters. + +[table +[[name ][Additional Parameters]] + +[[`set_of<T,KeyComp>` + + `multiset_of<T,KeyComp>` ] + +[[*KeyComp ] is a Functor that compares two types using a less-than operator. +By default, this is `std::less<T>`. ]] + +[[`unordered_set_of<T,HashFunctor,EqualKey>` + + `unordered_multiset_of<T,HashFunctor,EqualKey>`] + +[[*HashFunctor ] converts a `T` object into an `std::size_t` value. By default it is `boost::hash<T>`. + + [*EqualKey ] is a Functor that tests two types for equality. By default, the +equality operator is `std::equal_to<T>`. ]] +[[`list_of<T>` ][No additional parameters.]] +[[`vector_of<T>` ][No additional parameters.]] +[[`unconstrained_set_of<T>` ][No additional parameters.]] +] + +[endsect] + +[section Examples] + +[heading Countries Populations] + +We want to store countries populations. +The requeriments are: + +# Get a list of countries in decresing order of their populations. +# Given a countrie, get their population. + +Lets create the appropiate bimap. + + typedef bimap< + + unordered_set_of< std::string >, + multiset_of< long, std::greater<long> > + + > populations_bimap; + +First of all countries names are unique identifiers, while two countries +may have the same population. This is why we choose *multi*`set_of` for +populations. + +Using a `multiset_of` for population allow us to iterate over the data. +Since listing countries ordered by their names is not a requisite, we can +use an `unordered_set_of` that allows constant order look up. + +And now lets use it in a complete example + +[@../../example/population_bimap.cpp Go to source code] + +[import ../example/population_bimap.cpp] + +[code_population_bimap] + + +[heading Repetitions counter] + +We want to count the repetitions for each word in a text and print them +in order of appearance. + +[@../../example/repetitions_counter.cpp Go to source code] + +[import ../example/repetitions_counter.cpp] + +[code_repetitions_counter] + +[endsect] + +[endsect] + +[section The collection of relations type] + +[section A new point of view] + +Being able to change the collection type of the bimap relation view is another +very important feature. Remember that this view allows the user to see +the container as a group of the stored relations. This view has set +semantics instead of map semantics. + +__COLLECTION_TYPE_OF_RELATION__ + +By default, Boost.Bimap will base the collection type of the relation on the +type of the left collection. If the left collection type is a set, then the collection +type of the relation will be a set with the same order as the left view. + +In general, Boost.Bimap users will base the collection type of a relation on +the type of the collection on one of the two sides. However there are times +where it is useful to give this collection other constraints or simply to order +it differently. The user is allowed to choose between: + +* left_based +* right_based +* set_of_relation<> +* multiset_of_relation<> +* unordered_set_of_relation<> +* unordered_multiset_of_relation<> +* list_of_relation +* vector_of_relation +* unconstrained_set_of_relation + +[tip +The first two options and the last produce faster bimaps, so prefer +these where possible. +] + +__MORE_BIMAP_STRUCTURES__ + +The collection type of relation can be used to create powerful containers. For +example, if you need to maximize search speed, then the best +bidirectional map possible is one that relates elements from an +`unordered_set` to another `unordered_set`. The problem is that this +container cannot be iterated. If you need to know the list of relations +inside the container, you need another collection type of relation. In this +case, a `list_of_relation` is a good choice. The resulting container +trades insertion and deletion time against fast search capabilities and +the possibility of bidirectional iteration. + +[@../../example/mighty_bimap.cpp Go to source code] + +[code_mighty_bimap] + +[endsect] + +[section Configuration parameters] + +Each collection type of relation has different parameters to control its +behaviour. For example, in the `set_of_relation` specification, you can +pass a Functor type that compares two types. All of the parameters are +exactly as in the standard library containers, except for the type, +which is set to the bimap relation and the allocator type. To help users +in the creation of each functor, the collection type of relation templates +takes an mpl lambda expression where the relation type will be evaluated +later. A placeholder named `_relation` is available to bimap users. + +The following table lists the meaning of the parameters for each collection type of +relations. + +[table +[[name ][Additional Parameters]] + +[[`left_based` ][Not a template.]] +[[`right_based` ][Not a template.]] +[[`set_of_relation<KeyComp>` + + `multiset_of_relation<KeyComp>` ] +[[*KeyComp ] is a Functor that compares two types using less than. By +default, the less-than operator is `std::less<_relation>`. ]] + +[[`unordered_set_of_relation<HashFunctor,EqualKey>` + + `unordered_multiset_of_relation<HashFunctor,EqualKey>`] +[[*HashFunctor ] converts the `relation` into an `std::size_t` value. By default it is `boost::hash<_relation>`. + + [*EqualKey ] is a Functor that tests two relations for equality. By default, +the equality operator is `std::equal_to<_relation>`. ]] +[[`list_of_relation` ][Not a template.]] +[[`vector_of_relation` ][Not a template.]] +[[`unconstrained_set_of_relation` ][Not a template.]] +] + +[endsect] + +[section Examples] + +Consider this example: + + template< class Rel > + struct RelOrder + { + bool operator()(Rel ra, Rel rb) const + { + return (ra.left+ra.right) < (rb.left+rb.right); + } + }; + + typedef bimap + < + multiset_of< int >, + multiset_of< int >, + set_of_relation< RelOrder<_relation> > + + > bimap_type; + +Here the bimap relation view is ordered using the information of +both sides. This container will only allow unique relations because +`set_of_relation` has been used but the elements in each side of the +bimap can be repeated. + + struct name {}; + struct phone_number {}; + + typedef bimap + < + tagged< unordered_multiset_of< string >, name >, + tagged< unordered_set_of < int >, phone_number >, + set_of_relation<> + + > bimap_type; + +In this other case the bimap will relate names to phone numbers. +Names can be repeated and phone numbers are unique. You can perform +quick searches by name or phone number and the container can be viewed +ordered using the relation view. + +[endsect] + +[endsect] + +[section Differences with standard maps] + +[section Insertion] + +Remember that a map can be interpreted as a relation between two collections. +In bimaps we have the freedom to change both collection types, imposing +constrains in each of them. Some insertions that we give for granted to +success in standard maps fails with bimaps. +For example: + + bimap<int,std::string> bm; + + bm.left.insert(1,"orange"); + bm.left.insert(2,"orange"); // No effect! returns make_pair(iter,false) + +The insertion will only succeed if it is allowed by all views of the `bimap`. +In the next snippet we define the right collection as a multiset, when we +try to insert the same two elements the second insertion is allowed by the +left map view because both values are different and it is allowed by the +right map view because it is a non-unique collection type. + + bimap<int, multiset_of<std::string> > bm; + + bm.left.insert(1,"orange"); + bm.left.insert(2,"orange"); // Insertion succeed! + +If we use a custom collection of relation type, the insertion has to be +allowed by it too. + +[endsect] + +[section iterator::value_type] + +The relations stored in the Bimap will not be in most cases modifiable +directly by iterators because both sides are used as keys of +['key-based] sets. When a `bimap<A,B>` left view iterator is dereferenced +the return type is ['signature-compatible] with a +`std::pair< const A, const B >`. +However there are some collection types that are not ['key_based], for example +list_of. If a Bimap uses one of these collection types there is no problem with +modifying the data of that side. The following code is valid: + + typedef bimap< int, list_of< std::string > > bm_type; + bm_type bm; + bm.insert( bm_type::relation( 1, "one" ) ); + ... + bm.left.find(1)->second = "1"; // Valid + +In this case, when the iterator is dereferenced the return type is +['signature-compatible] with a `std::pair<const int, std::string>`. + +The following table shows the constness of the dereferenced data of each +collection type of: + +[table +[[Side collection type ][Dereferenced data]] +[[`set_of` ][['constant]]] +[[`multiset_of` ][['constant]]] +[[`unordered_set_of` ][['constant]]] +[[`unordered_multiset_of`][['constant]]] +[[`list_of` ][['mutable] ]] +[[`vector_of` ][['mutable] ]] +[[`unconstrained_set_of` ][['mutable] ]] +] + +Here are some examples. When dereferenced the iterators returns a type that +is ['signature-compatible] with these types. + +[table +[[Bimap type ][Signature-compatible types]] +[[`bimap<A,B>`][ + `iterator ` *->* `relation<const A,const B>` + + `left_iterator ` *->* `pair<const A,const B>` + + `right_iterator` *->* `pair<const B,const A>` +]] +[[`bimap<multiset_of<A>,unordered_set_of<B> >`][ + `iterator ` *->* `relation<const A,const B>` + + `left_iterator ` *->* `pair<const A,const B>` + + `right_iterator` *->* `pair<const B,const A>` +]] +[[`bimap<set_of<A>,list_of<B> >`][ + `iterator ` *->* `relation<const A,B>` + + `left_iterator ` *->* `pair<const A,B>` + + `right_iterator` *->* `pair<B,const A>` +]] +[[`bimap<vector_of<A>,set_of<B> >`][ + `iterator ` *->* `relation<A,const B>` + + `left_iterator ` *->* `pair<A,const B>` + + `right_iterator` *->* `pair<const B,A>` +]] +[[`bimap<list_of<A>,unconstrained_set_of<B> >`][ + `iterator ` *->* `relation<A,B>` + + `left_iterator ` *->* `pair<A,B>` + + `right_iterator` *->* `pair<B,A>` +]] +] + +[endsect] + +[section operator\[\] and at()] + +`set_of` and `unordered_set_of` map views overload `operator[]` to retrieve the +associated data of a given key only when the other collection type is a +mutable one. In these cases it works in the same way as the standard. + + bimap< unorderd_set_of< std::string>, list_of<int> > bm; + + bm.left["one"] = 1; // Ok + +The standard defines an access function for `map` and `unordered_map`: + + const data_type & at(const key_type & k) const; + data_type & at(const key_type & k); + +These functions look for a key and returns the associated data value, but +throws a `std::out_of_range` exception if the key is not found. + +In bimaps the constant version of these functions is given for `set_of` and +`unorderd_set_of` map views independently of the other collection type. +The mutable version is only provided when the other collection type is +mutable. + +The following examples shows the behaviour of `at(key)` + +[@../../example/at_function_examples.cpp Go to source code] + +[import ../example/at_function_examples.cpp] + +[code_at_function_first] + +[code_at_function_second] + +[/ +`set_of` and `unordered_set_of` views overload `operator[]` to retrieve the +associated data of a given key. +The symmetry of bimap imposes some constraints on `operator[]` that are +not found in `std::map` or `std::unordered_map`. If other views are unique, +`bimap::duplicate_value` is thrown whenever an assignment is attempted to +a value that is already a key in these views. As for +`bimap::value_not_found`, this exception is thrown while trying to access +a non-existent key: this behaviour differs from the standard containers, +which automatically assigns a default value to non-existent keys referred to +by `operator[]`. + + + const data_type & operator[](const typename key_type & k) const; + +[: Returns the `data_type` reference that is associated with `k`, or + throws `bimap::value_not_found` if such an element does not exist. +] + + ``['-unspecified data_type proxy-]`` operator[](const typename key_type & k); + +[: Returns a proxy to a `data_type` associated with `k` and the + bimap. The proxy behaves as a reference to the `data_type` object. If this + proxy is read and `k` was not in the bimap, the bimap::value_not_found is + thrown. If it is written then `bimap::duplicate_value` is thrown if the + assignment is not allowed by one of the other views of the `bimap`. +] + + +The following example shows the behaviour of `operator[]` + + bimap<int,std::string> bm; + + bm.left[1] = "one"; // Ok + + bm.right["two"] = 2; // Ok + + if( bm.left[3] == "three" ) // throws bimap::value_not_found + { + ... + } + + bm.left[3] = "one"; // throws bimap::duplicate_value +] + +[endsect] + +[section Complexity of operations] + +The complexity of some operations is different in bimaps. Read +[link complexity_signature_explanation the reference] to find the +complexity of each function. + +[endsect] + +[endsect] + +[section Useful functions] + +[section Projection of iterators] + +Iterators can be projected to any of the three views of the bimap. +A bimap provides three member functions to cope with projection: `project_left`, +`project_right` and `project_up`, with projects iterators to the ['left map view], +the ['right map view] and the ['collection of relations view]. These functions +take any iterator from the bimap and retrieve an iterator over the projected view +pointing to the same element. + +[import ../example/projection.cpp] + +Here is an example that uses projection: + +[@../../example/projection.cpp Go to source code] + +[code_projection_years] + +[endsect] + +[section replace and modify] + +[import ../example/tutorial_modify_and_replace.cpp] + +These functions are members of the views of a bimap that are not founded in +their standard counterparts. + +The `replace` family member functions performs in-place replacement of a given +element as the following example shows: + +[@../../example/tutorial_modify_and_replace.cpp Go to source code] + +[code_tutorial_replace] + +`replace` functions performs this substitution in such a manner that: + +* The complexity is constant time if the changed element retains its original order +with respect to all views; it is logarithmic otherwise. +* Iterator and reference validity are preserved. +* The operation is strongly exception-safe, i.e. the `bimap` remains unchanged if +some exception (originated by the system or the user's data types) is thrown. + +`replace` functions are powerful operations not provided by standard STL containers, +and one that is specially handy when strong exception-safety is required. + +The observant reader might have noticed that the convenience of replace comes at a +cost: namely the whole element has to be copied ['twice] to do the updating (when +retrieving it and inside `replace`). If elements are expensive to copy, this may +be quite a computational cost for the modification of just a tiny part of the +object. To cope with this situation, Boost.Bimap provides an alternative +updating mechanism: `modify` functions. + +`modify` functions accepts a functor (or pointer to function) taking a reference +to the data to be changed, thus eliminating the need for spurious copies. Like +`replace` functions, `modify` functions does preserve the internal orderings of +all the indices of the `bimap`. However, the semantics of modify functions are not +entirely equivalent to replace functions. Consider what happens if a collision occurs +as a result of modifying the element, i.e. the modified element clashes with another +with respect to some unique view. In the case of `replace` functions, the original +value is kept and the method returns without altering the container, but `modify` +functions cannot afford such an approach, since the modifying functor leaves no +trace of the previous value of the element. Integrity constraints thus lead to the +following policy: when a collision happens in the process of calling a modify functions, +the element is erased and the method returns false. This difference in behavior +between `replace` and `modify` functions has to be considered by the programmer on +a case-by-case basis. + +Boost.Bimap defines new placeholders named `_key` and `_data` to allow a sounder solution. +You have to include `<boost/bimap/support/lambda.hpp>` to use them. + +[/ +Boost.Bimap defines new placeholders to allow a sounder solution. For +pairs, two new placeholders are instantiated: `_first` and `_second`, and +for a relation, two more complete the set: `_left` and `_right`. +] + +[@../../example/tutorial_modify_and_replace.cpp Go to source code] + +[code_tutorial_modify] + +[endsect] + +[section Retrieval of ranges] + +[import ../example/tutorial_range.cpp] + +Standard `lower_bound` and `upper_bound` functions can be used to lookup for +all the elements in a given range. + +Suppose we want to retrieve the elements from a `bimap<int,std::string>` +where the left value is in the range `[20,50]` + +[code_tutorial_range_standard_way] + +Subtle changes to the code are required when strict inequalities are considered. +To retrieve the elements greater than 20 and less than 50, the code has to be +rewritten as + +[code_tutorial_range_standard_way_subtle_changes] + +To add to this complexity, the careful programmer has to take into account that +the lower and upper bounds of the interval searched be compatible: for instance, +if the lower bound is 50 and the upper bound is 20, the iterators `iter_first` and +`iter_second` produced by the code above will be in reverse order, with possibly +catastrophic results if a traversal from `iter_first` to `iter_second` is tried. +All these details make range searching a tedious and error prone task. + +The range member function, often in combination with lambda expressions, +can greatly help alleviate this situation: + +[code_tutorial_range] + +`range` simply accepts predicates specifying the lower and upper bounds of +the interval searched. Please consult the reference for a detailed explanation +of the permissible predicates passed to range. + +One or both bounds can be omitted with the special unbounded marker: + +[code_tutorial_range_unbounded] + +[@../../example/tutorial_range.cpp Go to source code] + +[endsect] + +[endsect] + +[section Bimaps with user defined names] + +[import ../example/user_defined_names.cpp] + +In the following example, the library user inserted comments to guide +future programmers: + +[@../../example/user_defined_names.cpp Go to source code] + +[code_user_defined_names_untagged_version] + +In Boost.Bimap there is a better way to document the code and +in the meantime helping you to write more mantainable and readable code. +You can tag the two collections of the bimap so they can be +accessed by more descriptive names. + +__TAGGED__ + +A tagged type is a type that has been labelled using a tag. A tag is any +valid C++ type. In a bimap, the types are always tagged. If you do not +specify your own tag, the container uses `member_at::left` and +`member_at::right` to tag the left and right sides respectively. In order +to specify a custom tag, the type of each side has to be tagged. +Tagging a type is very simple: + + typedef tagged< int, a_tag > tagged_int; + +Now we can rewrite the example: + +[@../../example/user_defined_names.cpp Go to source code] + +[code_user_defined_names_tagged_version] + +Here is a list of common structures in both tagged and untagged versions. +Remember that when the bimap has user defined tags you can still use +the untagged version structures. + + + struct Left {}; + struct Right {}; + typedef bimap< + multiset_of< tagged< int, Left > >, + unordered_set_of< tagged< int, Right > > + > bm_type; + + bm_type bm; + + //... + + bm_type::iterator iter = bm.begin(); + bm_type::left_iterator left_iter = bm.left.begin(); + bm_type::right_iterator right_iter = bm.right.begin(); + + + +[table Equivalence of expresions using user defined names +[[Untagged version] [Tagged version] ] +[[`bm.left`] [`bm.by<Left>()`] ] +[[`bm.right`] [`bm.by<Right>()`] ] +[[`bm_type::left_map`] [`bm::map_by<Left>::type`] ] +[[`bm_type::right_value_type`] [`bm::map_by<Right>::value_type`] ] +[[`bm_type::left_iterator`] [`bm::map_by<Left>::iterator`] ] +[[`bm_type::right_const_iterator`][`bm::map_by<Right>::const_iterator`]] +[[`iter->left`] [`iter->get<Left>()`] ] +[[`iter->right`] [`iter->get<Right>()`] ] +[[`left_iter->first`] [`left_iter->get<Left>()`] ] +[[`left_iter->second`] [`left_iter->get<Right>()`] ] +[[`right_iter->first`] [`right_iter->get<Right>()`] ] +[[`right_iter->second`] [`right_iter->get<Left>()`] ] +[[`bm.project_left(iter)`] [`bm.project<Left>(iter)`] ] +[[`bm.project_right(iter)`] [`bm.project<Right>(iter)`] ] +] + +[endsect] + +[section Unconstrained Sets] + +Unconstrained sets allow the user to disable one of the views of a +bimap. Doing so makes the bimap operations execute faster and reduces +memory consumption. This completes the bidirectional mapping framework +by including unidirectional mappings as a particular case. + +Unconstrained sets are useful for the following reasons: + +* A bimap type has stronger guarantees than its standard equivalent, +and includes some useful functions (replace, modify) that the standard +does not have. +* You can view the mapping as a collection of relations. +* Using this kind of map makes the code very extensible. If, at any +moment of the development, the need to perform searches from the right +side of the mapping arises, the only necessary change is to the `typedef`. + +[import ../example/unconstrained_collection.cpp] + +Given this bimap instance, + +[code_unconstrained_collection_bimap] + +or this standard map one + +[code_unconstrained_collection_map] + +The following code snippet is valid + +[code_unconstrained_collection_common] + +But using a bimap has some benefits + +[code_unconstrained_collection_only_for_bimap] + +[@../../example/unconstrained_collection.cpp Go to source code] + +[endsect] + +[section Additional information] + +[import ../example/tutorial_info_hook.cpp] + +Bidirectional maps may have associated information about each relation. +Suppose we want to represent a books and author bidirectional map. + +[code_tutorial_info_hook_nothing] + +Suppose now that we want to store abstract of each book. +We have two options: + +# Books name are unique identifiers, so we can create a separate +`std::map< string, string >` that relates books names with abstracts. +# We can use __BOOST_MULTI_INDEX__ for the new beast. + +Option 1 is the wrong approach, if we go this path we lost what bimap has +won us. We now have to maintain the logic of two interdependent containers, +there is an extra string stored for each book name, and the performance will +be worse. This is far away from being a good solution. + +Option 2 is correct. We start thinking books as entries in a table. So it +makes sense to start using Boost.MultiIndex. We can then add the year +of publication, the price, etc... and we can index this new items too. So +Boost.MultiIndex is a sound solution for our problem. + +The thing is that there are cases where we want to maintain bimap +semantics (use `at()` to find an author given a book name and the other way +around) and add information about the relations that we are sure we will not +want to index later (like the abstracts). Option 1 is not possible, option 2 +neither. + +Boost.Bimap provides support for this kind of situations by means of +an embedded information member. +You can pass an extra parameter to a bimap: `with_info< InfoType >` +and an `info` member of type `InfoType` will appear in the relation and bimap +pairs. + +__RELATION_AND_PAIR_WITH_INFO__ + +Relations and bimap pairs constructors will take an extra argument. +If only two arguments are used, the information will be initialized with +their default constructor. + +[code_tutorial_info_hook_first] + +Contrary to the two key types, the information will be mutable using iterators. + +[code_tutorial_info_hook_mutable] + +A new function is included in ['unique] map views: `info_at(key)`, that mimics the +standard `at(key)` function but returned the associated information instead of +the data. + +[code_tutorial_info_hook_info_at] + +The info member can be tagged just as the left or the right member. The following +is a rewrite of the above example using user defined names: + +[code_tutorial_info_hook_tagged_info] + +[@../../example/tutorial_info_hook.cpp Go to source code] + +[endsect] + +[section Complete instantiation scheme] + +To summarize, this is the complete instantiation scheme. + + typedef bimap + < + LeftCollectionType, RightCollectionType + + [ , SetTypeOfRelation ] // Default to left_based + [ , with_info< Info > ] // Default to no info + [ , Allocator ] // Default to std::allocator<> + + > bm; + +`{Side}CollectionType` can directly be a type. This defaults to +`set_of<Type>`, or can be a `{CollectionType}_of<Type>` specification. +Additionally, the type of this two parameters can be tagged to specify +user defined names instead of the usual `member_at::-Side-` tags. + +The possibles way to use the first parameter are: + + bimap< Type, R > + +* Left type: `Type` +* Left collection type: `set_of< Type >` +* Left tag: `member_at::left` + + bimap< {CollectionType}_of< Type >, R > + +* Left type: `Type` +* Left collection type: `{CollectionType}_of< LeftType >` +* Left tag: `member_at::left` + + bimap< tagged< Type, Tag >, R > + +* Left type: `Type` +* Left collection type: `set_of< LeftType >` +* Left tag: `Tag` + + bimap< {CollectionType}_of< tagged< Type, Tag > >, R > + +* Left type: `Type` +* Left collection type: `{CollectionType}_of< LeftType >` +* Left tag: `Tag` + +The same options are available for the second parameter. + +The last three parameters are used to specify the collection type of the relation, +the information member and the allocator type. + +If you want to specify a custom allocator type while relying on the default +value of CollectionTypeOfRelation, you can do so by simply writing +`bimap<LeftKeyType, RightKeyType, Allocator>`. Boost.Bimap's internal +machinery detects that the third parameter in this case does not refer +to the relation type but rather to an allocator. + +The following are the possible ways of instantiating the last three parameters +of a bimap. You can ignore some of the parameter but the order must be respected. + + + bimap< L, R > + +* set_of_relation_type: based on the left key type +* info: no info +* allocator: std::allocator + + + bimap< L, R ,SetOfRelationType> + +* set_of_relation_type: SetOfRelationType +* info: no info +* allocator: std::allocator + + + bimap< L, R , SetOfRelationType, with_info<Info> > + +* set_of_relation_type: SetOfRelationType +* info: Info +* allocator: std::allocator + + + bimap< L, R , SetOfRelationType, with_info<Info>, Allocator> + +* set_of_relation_type: SetOfRelationType +* info: Info +* allocator: Allocator + + + bimap< L, R , SetOfRelationType, Allocator> + +* set_of_relation_type: SetOfRelationType +* info: no info +* allocator: Allocator + + + bimap< L, R , with_info<Info> > + +* set_of_relation_type: based on the left key type +* info: Info +* allocator: std::allocator + + + bimap< L, R , with_info<Info>, Allocator> + +* set_of_relation_type: based on the left key type +* allocator: Allocator + + + bimap< L, R , Allocator> + +* set_of_relation_type: based on the left key type +* info: no info +* allocator: Allocator + + + + +[endsect] + +[endsect] diff --git a/libs/bimap/example/Jamfile.v2 b/libs/bimap/example/Jamfile.v2 new file mode 100644 index 0000000000..424162943d --- /dev/null +++ b/libs/bimap/example/Jamfile.v2 @@ -0,0 +1,50 @@ +# Boost.Bimap +# +# Copyright (c) 2006-2007 Matias Capeletto +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# bring in rules for testing +import testing ; + +test-suite "examples" + : + [ compile mighty_bimap.cpp ] + [ run simple_bimap.cpp ] + [ run tagged_simple_bimap.cpp ] + [ run step_by_step.cpp ] + [ run population_bimap.cpp ] + [ run repetitions_counter.cpp ] + [ compile user_defined_names.cpp ] + [ run standard_map_comparison.cpp ] + [ run at_function_examples.cpp ] + [ run tutorial_modify_and_replace.cpp ] + [ run tutorial_range.cpp ] + [ run unconstrained_collection.cpp ] + [ run tutorial_info_hook.cpp ] + [ run projection.cpp ] + ; + +test-suite "bimap_and_boost" + : + [ run bimap_and_boost/property_map.cpp ] + [ run bimap_and_boost/range.cpp ] + [ run bimap_and_boost/foreach.cpp ] + [ run bimap_and_boost/lambda.cpp ] + [ run bimap_and_boost/assign.cpp ] + [ run bimap_and_boost/xpressive.cpp ] + [ run bimap_and_boost/typeof.cpp ] + [ run bimap_and_boost/serialization.cpp + /boost/serialization//boost_serialization ] + ; + +test-suite "mi_to_b_path" + : + [ compile mi_to_b_path/bidirectional_map.cpp ] + [ run mi_to_b_path/hashed_indices.cpp ] + [ compile mi_to_b_path/tagged_bidirectional_map.cpp ] + [ compile mi_to_b_path/mi_bidirectional_map.cpp ] + [ run mi_to_b_path/mi_hashed_indices.cpp ] + ; diff --git a/libs/bimap/example/at_function_examples.cpp b/libs/bimap/example/at_function_examples.cpp new file mode 100644 index 0000000000..c0b916f7ef --- /dev/null +++ b/libs/bimap/example/at_function_examples.cpp @@ -0,0 +1,97 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <string> +#include <iostream> +#include <cassert> + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/unordered_set_of.hpp> +#include <boost/bimap/list_of.hpp> +#include <boost/bimap/multiset_of.hpp> + +using namespace boost::bimaps; + +void first_bimap() +{ + //[ code_at_function_first + + typedef bimap< set_of< std::string >, list_of< int > > bm_type; + bm_type bm; + + try + { + bm.left.at("one") = 1; // throws std::out_of_range + } + catch( std::out_of_range & e ) {} + + assert( bm.empty() ); + + bm.left["one"] = 1; // Ok + + assert( bm.left.at("one") == 1 ); // Ok + //] +} + +void second_bimap() +{ + //[ code_at_function_second + + typedef bimap< multiset_of<std::string>, unordered_set_of<int> > bm_type; + bm_type bm; + + //<- + /* + //-> + bm.right[1] = "one"; // compilation error + //<- + */ + //-> + + bm.right.insert( bm_type::right_value_type(1,"one") ); + + assert( bm.right.at(1) == "one" ); // Ok + + try + { + std::cout << bm.right.at(2); // throws std::out_of_range + } + catch( std::out_of_range & e ) {} + + //<- + /* + //-> + bm.right.at(1) = "1"; // compilation error + //<- + */ + //-> + + //] +} + +int main() +{ + first_bimap(); + second_bimap(); + return 0; +} + diff --git a/libs/bimap/example/bimap_and_boost/assign.cpp b/libs/bimap/example/bimap_and_boost/assign.cpp new file mode 100644 index 0000000000..7c7652ba9d --- /dev/null +++ b/libs/bimap/example/bimap_and_boost/assign.cpp @@ -0,0 +1,79 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <string> + +#include <boost/assign/list_of.hpp> +#include <boost/assign/list_inserter.hpp> + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/multiset_of.hpp> +#include <boost/bimap/list_of.hpp> + +using namespace boost::bimaps; +using namespace boost; + + +int main() +{ + //[ code_bimap_and_boost_assign + + typedef bimap< multiset_of< int >, list_of< std::string > > bm_type; + + // We can use assign::list_of to initialize the container. + + bm_type bm = assign::list_of< bm_type::relation > /*< + Note that `bm_type::relation` has to be used instead of `bm_type::value_type`. + Contrary to `value_type`, `relation` type stores the elements as non const, a + requirement of `assign::list_of` >*/ + ( 1, "one" ) + ( 2, "two" ) + ( 3, "three" ); + + // The left map view is a multiset, again we use insert + + assign::insert( bm.left ) + ( 4, "four" ) + ( 5, "five" ) + ( 6, "six" ); + + // The right map view is a list so we use push_back here + // Note the order of the elements in the list! + + assign::push_back( bm.right ) + ( "seven" , 7 ) + ( "eight" , 8 ); + + assign::push_front( bm.right ) + ( "nine" , 9 ) + ( "ten" , 10 ) + ( "eleven", 11 ); + + // Since it is left_based the main view is a multiset, so we use insert + + assign::insert( bm ) + ( 12, "twelve" ) + ( 13, "thirteen" ); + //] + + return 0; +} diff --git a/libs/bimap/example/bimap_and_boost/foreach.cpp b/libs/bimap/example/bimap_and_boost/foreach.cpp new file mode 100644 index 0000000000..7ca9a7b275 --- /dev/null +++ b/libs/bimap/example/bimap_and_boost/foreach.cpp @@ -0,0 +1,106 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <string> +#include <iostream> + +#include <boost/foreach.hpp> + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/list_of.hpp> +#include <boost/bimap/support/lambda.hpp> + +using namespace boost::bimaps; + + +int main() +{ + //[ code_bimap_and_boost_foreach + + typedef bimap< std::string, list_of<int> > bm_type; + + bm_type bm; + bm.insert( bm_type::value_type("1", 1) ); + bm.insert( bm_type::value_type("2", 2) ); + bm.insert( bm_type::value_type("3", 4) ); + bm.insert( bm_type::value_type("4", 2) ); + + BOOST_FOREACH( bm_type::left_reference p, bm.left ) + { + ++p.second; /*< We can modify the right element because we have + use a mutable collection type in the right side. >*/ + } + + BOOST_FOREACH( bm_type::right_const_reference p, bm.right ) + { + std::cout << p.first << "-->" << p.second << std::endl; + } + + //] + + // More examples + + BOOST_FOREACH( bm_type::right_reference p, bm.right ) + { + ++p.first; + } + + BOOST_FOREACH( bm_type::left_const_reference p, bm.left ) + { + std::cout << p.first << "-->" << p.second << std::endl; + } + + BOOST_FOREACH( bm_type::reference p, bm ) + { + ++p.right; + } + + const bm_type & cbm = bm; + BOOST_FOREACH( bm_type::const_reference p, cbm ) + { + std::cout << p.left << "-->" << p.right << std::endl; + } + + BOOST_FOREACH( bm_type::const_reference p, bm ) + { + std::cout << p.left << "-->" << p.right << std::endl; + } + + //[ code_bimap_and_boost_foreach_using_range + + BOOST_FOREACH( bm_type::left_reference p, + ( bm.left.range( std::string("1") <= _key, _key < std::string("3") ) )) + { + ++p.second; + } + + BOOST_FOREACH( bm_type::left_const_reference p, + ( bm.left.range( std::string("1") <= _key, _key < std::string("3") ) )) + { + std::cout << p.first << "-->" << p.second << std::endl; + } + //] + + return 0; +} + + diff --git a/libs/bimap/example/bimap_and_boost/lambda.cpp b/libs/bimap/example/bimap_and_boost/lambda.cpp new file mode 100644 index 0000000000..765503de69 --- /dev/null +++ b/libs/bimap/example/bimap_and_boost/lambda.cpp @@ -0,0 +1,49 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <string> + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/support/lambda.hpp> + +using namespace boost::bimaps; + +int main() +{ + //[ code_bimap_and_boost_lambda + + typedef bimap< std::string, int > bm_type; + + bm_type bm; + bm.insert( bm_type::value_type("one",1) ); + bm.insert( bm_type::value_type("two",2) ); + + bm.right.range( 5 < _key, _key < 10 ); + + bm.left.modify_key( bm.left.find("one"), _key = "1" ); + + bm.left.modify_data( bm.left.begin(), _data *= 10 ); + //] + return 0; +} + + diff --git a/libs/bimap/example/bimap_and_boost/property_map.cpp b/libs/bimap/example/bimap_and_boost/property_map.cpp new file mode 100644 index 0000000000..298bae8028 --- /dev/null +++ b/libs/bimap/example/bimap_and_boost/property_map.cpp @@ -0,0 +1,59 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <iostream> +#include <string> + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/multiset_of.hpp> +#include <boost/bimap/property_map/set_support.hpp> + +using namespace boost::bimaps; + +//[ code_bimap_and_boost_property_map + +template <typename AddressMap> +void foo(AddressMap & address_map) +{ + typedef typename boost::property_traits<AddressMap>::value_type value_type; + typedef typename boost::property_traits<AddressMap>::key_type key_type; + + value_type address; + key_type fred = "Fred"; + std::cout << get(address_map, fred); +} + +int main() +{ + typedef bimap<std::string, multiset_of<std::string> > Name2Address; + typedef Name2Address::value_type location; + + Name2Address name2address; + name2address.insert( location("Fred", "710 West 13th Street") ); + name2address.insert( location( "Joe", "710 West 13th Street") ); + + foo( name2address.left ); + + return 0; +} +//] + diff --git a/libs/bimap/example/bimap_and_boost/range.cpp b/libs/bimap/example/bimap_and_boost/range.cpp new file mode 100644 index 0000000000..605e86a273 --- /dev/null +++ b/libs/bimap/example/bimap_and_boost/range.cpp @@ -0,0 +1,121 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <iostream> + +#include <boost/range/functions.hpp> +#include <boost/range/metafunctions.hpp> + +//[ code_bimap_and_boost_range_functions + +template< class ForwardReadableRange, class UnaryFunctor > +UnaryFunctor for_each(const ForwardReadableRange & r, UnaryFunctor func) +{ + typedef typename + boost::range_const_iterator<ForwardReadableRange>::type const_iterator; + + for(const_iterator i= boost::begin(r), iend= boost::end(r); i!=iend; ++i ) + { + func(*i); + } + + return func; +} + +template< class ForwardReadableRange, class Predicate > +typename boost::range_difference<ForwardReadableRange>::type + count_if(const ForwardReadableRange & r, Predicate pred) +{ + typedef typename + boost::range_const_iterator<ForwardReadableRange>::type const_iterator; + + typename boost::range_difference<ForwardReadableRange>::type c = 0; + + for( const_iterator i = boost::begin(r), iend = boost::end(r); i != iend; ++i ) + { + if( pred(*i) ) ++c; + } + + return c; +} +//] + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/multiset_of.hpp> +#include <boost/bimap/support/lambda.hpp> +#include <boost/bind.hpp> + +using namespace boost::bimaps; +using namespace boost; + +//[ code_bimap_and_boost_range + +struct pair_printer +{ + pair_printer(std::ostream & o) : os(o) {} + template< class Pair > + void operator()(const Pair & p) + { + os << "(" << p.first << "," << p.second << ")"; + } + private: + std::ostream & os; +}; + +struct second_extractor +{ + template< class Pair > + const typename Pair::second_type & operator()(const Pair & p) + { + return p.second; + } +}; + +int main() +{ + typedef bimap< double, multiset_of<int> > bm_type; + + bm_type bm; + bm.insert( bm_type::value_type(2.5 , 1) ); + bm.insert( bm_type::value_type(3.1 , 2) ); + //... + bm.insert( bm_type::value_type(6.4 , 4) ); + bm.insert( bm_type::value_type(1.7 , 2) ); + + // Print all the elements of the left map view + + for_each( bm.left, pair_printer(std::cout) ); + + // Print a range of elements of the right map view + + for_each( bm.right.range( 2 <= _key, _key < 6 ), pair_printer(std::cout) ); + + // Count the number of elements where the data is equal to 2 from a + // range of elements of the left map view + + count_if( bm.left.range( 2.3 < _key, _key < 5.4 ), + bind<int>( second_extractor(), _1 ) == 2 ); + + return 0; +} +//] + diff --git a/libs/bimap/example/bimap_and_boost/serialization.cpp b/libs/bimap/example/bimap_and_boost/serialization.cpp new file mode 100644 index 0000000000..f4791a1334 --- /dev/null +++ b/libs/bimap/example/bimap_and_boost/serialization.cpp @@ -0,0 +1,89 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <fstream> +#include <string> +#include <cassert> + +#include <boost/bimap/bimap.hpp> + +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/text_iarchive.hpp> + +using namespace boost::bimaps; + +int main() +{ + //[ code_bimap_and_boost_serialization + + typedef bimap< std::string, int > bm_type; + + // Create a bimap and serialize it to a file + { + bm_type bm; + bm.insert( bm_type::value_type("one",1) ); + bm.insert( bm_type::value_type("two",2) ); + + std::ofstream ofs("data"); + boost::archive::text_oarchive oa(ofs); + + oa << const_cast<const bm_type&>(bm); /*< + We must do a const cast because Boost.Serialization archives + only save const objects. Read Boost.Serializartion docs for the + rationale behind this decision >*/ + + /*<< We can only serialize iterators if the bimap was serialized first. + Note that the const cast is not requiered here because we create + our iterators as const. >>*/ + const bm_type::left_iterator left_iter = bm.left.find("two"); + oa << left_iter; + + const bm_type::right_iterator right_iter = bm.right.find(1); + oa << right_iter; + } + + // Load the bimap back + { + bm_type bm; + + std::ifstream ifs("data", std::ios::binary); + boost::archive::text_iarchive ia(ifs); + + ia >> bm; + + assert( bm.size() == 2 ); + + bm_type::left_iterator left_iter; + ia >> left_iter; + + assert( left_iter->first == "two" ); + + bm_type::right_iterator right_iter; + ia >> right_iter; + + assert( right_iter->first == 1 ); + } + //] + + return 0; +} + diff --git a/libs/bimap/example/bimap_and_boost/typeof.cpp b/libs/bimap/example/bimap_and_boost/typeof.cpp new file mode 100644 index 0000000000..3cd99c6b28 --- /dev/null +++ b/libs/bimap/example/bimap_and_boost/typeof.cpp @@ -0,0 +1,86 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <string> +#include <iostream> +#include <boost/bimap/bimap.hpp> + +#include <boost/typeof/typeof.hpp> + +using namespace boost::bimaps; + +struct name {}; +struct number {}; + +void using_auto() +{ + //[ code_bimap_and_boost_typeof_first + + typedef bimap< tagged<std::string,name>, tagged<int,number> > bm_type; + bm_type bm; + bm.insert( bm_type::value_type("one" ,1) ); + bm.insert( bm_type::value_type("two" ,2) ); + //] + + //[ code_bimap_and_boost_typeof_using_auto + + for( BOOST_AUTO(iter, bm.by<name>().begin()); iter!=bm.by<name>().end(); ++iter) + { + std::cout << iter->first << " --> " << iter->second << std::endl; + } + + BOOST_AUTO( iter, bm.by<number>().find(2) ); + std::cout << "2: " << iter->get<name>(); + //] +} + +void not_using_auto() +{ + typedef bimap< tagged<std::string,name>, tagged<int,number> > bm_type; + bm_type bm; + bm.insert( bm_type::value_type("one" ,1) ); + bm.insert( bm_type::value_type("two" ,2) ); + + //[ code_bimap_and_boost_typeof_not_using_auto + + for( bm_type::map_by<name>::iterator iter = bm.by<name>().begin(); + iter!=bm.by<name>().end(); ++iter) + { + std::cout << iter->first << " --> " << iter->second << std::endl; + } + + bm_type::map_by<number>::iterator iter = bm.by<number>().find(2); + std::cout << "2: " << iter->get<name>(); + //] +} + +int main() +{ + using_auto(); + not_using_auto(); + + return 0; +} + + + + diff --git a/libs/bimap/example/bimap_and_boost/xpressive.cpp b/libs/bimap/example/bimap_and_boost/xpressive.cpp new file mode 100644 index 0000000000..dce2c15d2f --- /dev/null +++ b/libs/bimap/example/bimap_and_boost/xpressive.cpp @@ -0,0 +1,57 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <string> + +#include <boost/bimap/bimap.hpp> + +#include <boost/xpressive/xpressive.hpp> +#include <boost/xpressive/regex_actions.hpp> + +using namespace boost::bimaps; +using namespace boost::xpressive; +namespace xp = boost::xpressive; + +int main() +{ + //[ code_bimap_and_boost_xpressive + + typedef bimap< std::string, int > bm_type; + bm_type bm; + + std::string rel_str("one <--> 1 two <--> 2 three <--> 3"); + + sregex rel = ( (s1= +_w) >> " <--> " >> (s2= +_d) ) + [ + xp::ref(bm)->*insert( xp::construct<bm_type::value_type>(s1, as<int>(s2)) ) + ]; + + sregex relations = rel >> *(+_s >> rel); + + regex_match(rel_str, relations); + + assert( bm.size() == 3 ); + //] + + return 0; +} + diff --git a/libs/bimap/example/mi_to_b_path/bidirectional_map.cpp b/libs/bimap/example/mi_to_b_path/bidirectional_map.cpp new file mode 100644 index 0000000000..20edf941ae --- /dev/null +++ b/libs/bimap/example/mi_to_b_path/bidirectional_map.cpp @@ -0,0 +1,87 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +// Boost.Bimap Example +//----------------------------------------------------------------------------- +// This example shows how to construct a bidirectional map with +// multi_index_container. +// By a bidirectional map we mean a container of elements of +// std::pair<const FromType,const ToType> such that no two elements exists with +// the same first or second value (std::map only guarantees uniqueness of the +// first member). +// Fast lookup is provided for both keys. The program features a tiny +// Spanish-English dictionary with online query of words in both languages. + +#include <boost/config.hpp> + +//[ code_mi_to_b_path_bidirectional_map + +#include <iostream> +#include <boost/tokenizer.hpp> +#include <boost/bimap/bimap.hpp> + +using namespace boost::bimaps; + +// A dictionary is a bidirectional map from strings to strings + +typedef bimap<std::string,std::string> dictionary; +typedef dictionary::value_type translation; + +int main() +{ + dictionary d; + + // Fill up our microdictionary. + // first members Spanish, second members English. + + d.insert( translation("hola" ,"hello" )); + d.insert( translation("adios","goodbye")); + d.insert( translation("rosa" ,"rose" )); + d.insert( translation("mesa" ,"table" )); + + std::cout << "enter a word" << std::endl; + std::string word; + std::getline(std::cin,word); + + // search the queried word on the from index (Spanish) + + dictionary::left_const_iterator it = d.left.find(word); + + if( it != d.left.end() ) + { + // the second part of the element is the equivalent in English + + std::cout << word << " is said " + << it->second /*< `it` is an iterator of the left view, so + `it->second` refers to the right element of + the relation, the word in english >*/ + << " in English" << std::endl; + } + else + { + // word not found in Spanish, try our luck in English + + dictionary::right_const_iterator it2 = d.right.find(word); + if( it2 != d.right.end() ) + { + std::cout << word << " is said " + << it2->second /*< `it2` is an iterator of the right view, so + `it2->second` refers to the left element of + the relation, the word in spanish >*/ + << " in Spanish" << std::endl; + } + else + { + std::cout << "No such word in the dictionary" << std::endl; + } + } + + return 0; +} +//] diff --git a/libs/bimap/example/mi_to_b_path/hashed_indices.cpp b/libs/bimap/example/mi_to_b_path/hashed_indices.cpp new file mode 100644 index 0000000000..22bb391b8f --- /dev/null +++ b/libs/bimap/example/mi_to_b_path/hashed_indices.cpp @@ -0,0 +1,94 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +// Boost.Bimap Example +//----------------------------------------------------------------------------- +// Hashed indices can be used as an alternative to ordered indices when fast +// lookup is needed and sorting information is of no interest. The example +// features a word counter where duplicate entries are checked by means of a +// hashed index. + +#include <boost/config.hpp> + +//[ code_mi_to_b_path_hashed_indices + +#include <iostream> +#include <iomanip> + +#include <boost/tokenizer.hpp> + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/unordered_set_of.hpp> +#include <boost/bimap/multiset_of.hpp> +#include <boost/bimap/support/lambda.hpp> + +using namespace boost::bimaps; + +struct word {}; +struct occurrences {}; + +typedef bimap +< + + multiset_of< tagged<unsigned int,occurrences>, std::greater<unsigned int> >, +unordered_set_of< tagged< std::string, word> > + +> word_counter; + +typedef boost::tokenizer<boost::char_separator<char> > text_tokenizer; + +int main() +{ + + std::string text= + "Relations between data in the STL are represented with maps." + "A map is a directed relation, by using it you are representing " + "a mapping. In this directed relation, the first type is related to " + "the second type but it is not true that the inverse relationship " + "holds. This is useful in a lot of situations, but there are some " + "relationships that are bidirectional by nature."; + + // feed the text into the container + + word_counter wc; + text_tokenizer tok(text,boost::char_separator<char>(" \t\n.,;:!?'\"-")); + unsigned int total_occurrences = 0; + + for( text_tokenizer::const_iterator it = tok.begin(), it_end = tok.end(); + it != it_end ; ++it ) + { + ++total_occurrences; + + word_counter::map_by<occurrences>::iterator wit = + wc.by<occurrences>().insert( + word_counter::map_by<occurrences>::value_type(0,*it) + ).first; + + wc.by<occurrences>().modify_key( wit, ++_key); + } + + // list words by frequency of appearance + + std::cout << std::fixed << std::setprecision(2); + + for( word_counter::map_by<occurrences>::const_iterator + wit = wc.by<occurrences>().begin(), + wit_end = wc.by<occurrences>().end(); + + wit != wit_end; ++wit ) + { + std::cout << std::setw(15) << wit->get<word>() << ": " + << std::setw(5) + << 100.0 * wit->get<occurrences>() / total_occurrences << "%" + << std::endl; + } + + return 0; +} +//] diff --git a/libs/bimap/example/mi_to_b_path/mi_bidirectional_map.cpp b/libs/bimap/example/mi_to_b_path/mi_bidirectional_map.cpp new file mode 100644 index 0000000000..27045d0beb --- /dev/null +++ b/libs/bimap/example/mi_to_b_path/mi_bidirectional_map.cpp @@ -0,0 +1,107 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/****************************************************************************** +Boost.MultiIndex +******************************************************************************/ + +#include <boost/config.hpp> + +//[ code_mi_to_b_path_mi_bidirectional_map + +#include <iostream> +#include <boost/tokenizer.hpp> + +#include <boost/multi_index_container.hpp> +#include <boost/multi_index/key_extractors.hpp> +#include <boost/multi_index/ordered_index.hpp> + +using namespace boost; +using namespace boost::multi_index; + +// tags for accessing both sides of a bidirectional map + +struct from {}; +struct to {}; + +// The class template bidirectional_map wraps the specification +// of a bidirectional map based on multi_index_container. + +template<typename FromType,typename ToType> +struct bidirectional_map +{ + typedef std::pair<FromType,ToType> value_type; + + typedef multi_index_container< + value_type, + indexed_by + < + ordered_unique + < + tag<from>, member<value_type,FromType,&value_type::first> + >, + ordered_unique + < + tag<to>, member<value_type,ToType,&value_type::second> + > + > + + > type; + +}; + +// A dictionary is a bidirectional map from strings to strings + +typedef bidirectional_map<std::string,std::string>::type dictionary; + +int main() +{ + dictionary d; + + // Fill up our microdictionary. + // first members Spanish, second members English. + + d.insert(dictionary::value_type("hola","hello")); + d.insert(dictionary::value_type("adios","goodbye")); + d.insert(dictionary::value_type("rosa","rose")); + d.insert(dictionary::value_type("mesa","table")); + + std::cout << "enter a word" << std::endl; + std::string word; + std::getline(std::cin,word); + + // search the queried word on the from index (Spanish) + + dictionary::iterator it = d.get<from>().find(word); + + if( it != d.end() ) + { + // the second part of the element is the equivalent in English + + std::cout << word << " is said " + << it->second << " in English" << std::endl; + } + else + { + // word not found in Spanish, try our luck in English + + dictionary::index_iterator<to>::type it2 = d.get<to>().find(word); + if( it2 != d.get<to>().end() ) + { + std::cout << word << " is said " + << it2->first << " in Spanish" << std::endl; + } + else + { + std::cout << "No such word in the dictionary" << std::endl; + } + } + + return 0; +} +//] diff --git a/libs/bimap/example/mi_to_b_path/mi_hashed_indices.cpp b/libs/bimap/example/mi_to_b_path/mi_hashed_indices.cpp new file mode 100644 index 0000000000..f91b835d03 --- /dev/null +++ b/libs/bimap/example/mi_to_b_path/mi_hashed_indices.cpp @@ -0,0 +1,100 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +/***************************************************************************** +Boost.MultiIndex +*****************************************************************************/ + +#include <boost/config.hpp> + +//[ code_mi_to_b_path_mi_hashed_indices + +#include <iostream> +#include <iomanip> + +#include <boost/tokenizer.hpp> + +#include <boost/multi_index_container.hpp> +#include <boost/multi_index/key_extractors.hpp> +#include <boost/multi_index/ordered_index.hpp> +#include <boost/multi_index/hashed_index.hpp> +#include <boost/lambda/lambda.hpp> + +using namespace boost::multi_index; +namespace bl = boost::lambda; + +// word_counter keeps the ocurrences of words inserted. A hashed +// index allows for fast checking of preexisting entries. + +struct word_counter_entry +{ + std::string word; + unsigned int occurrences; + + word_counter_entry( std::string word_ ) : word(word_), occurrences(0) {} +}; + +typedef multi_index_container +< + word_counter_entry, + indexed_by + < + ordered_non_unique + < + BOOST_MULTI_INDEX_MEMBER( + word_counter_entry,unsigned int,occurrences), + std::greater<unsigned int> + >, + hashed_unique + < + BOOST_MULTI_INDEX_MEMBER(word_counter_entry,std::string,word) + > + > + +> word_counter; + +typedef boost::tokenizer<boost::char_separator<char> > text_tokenizer; + +int main() +{ + std::string text= + "En un lugar de la Mancha, de cuyo nombre no quiero acordarme... " + "...snip..." + "...no se salga un punto de la verdad."; + + // feed the text into the container + + word_counter wc; + text_tokenizer tok(text,boost::char_separator<char>(" \t\n.,;:!?'\"-")); + unsigned int total_occurrences = 0; + + for( text_tokenizer::iterator it = tok.begin(), it_end = tok.end(); + it != it_end ; ++it ) + { + ++total_occurrences; + word_counter::iterator wit = wc.insert(*it).first; + wc.modify_key( wit, ++ bl::_1 ); + } + + // list words by frequency of appearance + + std::cout << std::fixed << std::setprecision(2); + + for( word_counter::iterator wit = wc.begin(), wit_end=wc.end(); + wit != wit_end; ++wit ) + { + std::cout << std::setw(11) << wit->word << ": " + << std::setw(5) + << 100.0 * wit->occurrences / total_occurrences << "%" + << std::endl; + } + + return 0; +} +//] diff --git a/libs/bimap/example/mi_to_b_path/tagged_bidirectional_map.cpp b/libs/bimap/example/mi_to_b_path/tagged_bidirectional_map.cpp new file mode 100644 index 0000000000..4c0ddb616d --- /dev/null +++ b/libs/bimap/example/mi_to_b_path/tagged_bidirectional_map.cpp @@ -0,0 +1,90 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +// Boost.Bimap Example +//----------------------------------------------------------------------------- +// This example shows how to construct a bidirectional map with +// multi_index_container. +// By a bidirectional map we mean a container of elements of +// std::pair<const FromType,const ToType> such that no two elements exists with +// the same first or second value (std::map only guarantees uniqueness of the +// first member). +// Fast lookup is provided for both keys. The program features a tiny +// Spanish-English dictionary with online query of words in both languages. + +//[ code_mi_to_b_path_tagged_bidirectional_map + +#include <iostream> + +#include <boost/bimap/bimap.hpp> + +using namespace boost::bimaps; + +// tags + +struct spanish {}; +struct english {}; + +// A dictionary is a bidirectional map from strings to strings + +typedef bimap +< + tagged< std::string,spanish >, tagged< std::string,english > + +> dictionary; + +typedef dictionary::value_type translation; + +int main() +{ + dictionary d; + + // Fill up our microdictionary. + // first members Spanish, second members English. + + d.insert( translation("hola" ,"hello" )); + d.insert( translation("adios","goodbye")); + d.insert( translation("rosa" ,"rose" )); + d.insert( translation("mesa" ,"table" )); + + std::cout << "enter a word" << std::endl; + std::string word; + std::getline(std::cin,word); + + // search the queried word on the from index (Spanish) */ + + dictionary::map_by<spanish>::const_iterator it = + d.by<spanish>().find(word); + + if( it != d.by<spanish>().end() ) + { + std::cout << word << " is said " + << it->get<english>() << " in English" << std::endl; + } + else + { + // word not found in Spanish, try our luck in English + + dictionary::map_by<english>::const_iterator it2 = + d.by<english>().find(word); + + if( it2 != d.by<english>().end() ) + { + std::cout << word << " is said " + << it2->get<spanish>() << " in Spanish" << std::endl; + } + else + { + std::cout << "No such word in the dictionary" << std::endl; + } + } + + return 0; +} +//] diff --git a/libs/bimap/example/mighty_bimap.cpp b/libs/bimap/example/mighty_bimap.cpp new file mode 100644 index 0000000000..8641ad3b5b --- /dev/null +++ b/libs/bimap/example/mighty_bimap.cpp @@ -0,0 +1,109 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- +// This is the translator example from the tutorial. +// In this example the set type of relation is changed to allow the iteration +// of the container. + +#include <boost/config.hpp> + +//[ code_mighty_bimap + +#include <iostream> +#include <string> +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/list_of.hpp> +#include <boost/bimap/unordered_set_of.hpp> + +struct english {}; +struct spanish {}; + +int main() +{ + using namespace boost::bimaps; + + typedef bimap + < + unordered_set_of< tagged< std::string, spanish > >, + unordered_set_of< tagged< std::string, english > >, + list_of_relation + + > translator; + + translator trans; + + // We have to use `push_back` because the collection of relations is + // a `list_of_relation` + + trans.push_back( translator::value_type("hola" ,"hello" ) ); + trans.push_back( translator::value_type("adios" ,"goodbye" ) ); + trans.push_back( translator::value_type("rosa" ,"rose" ) ); + trans.push_back( translator::value_type("mesa" ,"table" ) ); + + std::cout << "enter a word" << std::endl; + std::string word; + std::getline(std::cin,word); + + // Search the queried word on the from index (Spanish) + + translator::map_by<spanish>::const_iterator is + = trans.by<spanish>().find(word); + + if( is != trans.by<spanish>().end() ) + { + std::cout << word << " is said " + << is->get<english>() + << " in English" << std::endl; + } + else + { + // Word not found in Spanish, try our luck in English + + translator::map_by<english>::const_iterator ie + = trans.by<english>().find(word); + + if( ie != trans.by<english>().end() ) + { + std::cout << word << " is said " + << ie->get<spanish>() + << " in Spanish" << std::endl; + } + else + { + // Word not found, show the possible translations + + std::cout << "No such word in the dictionary" << std::endl; + std::cout << "These are the possible translations" << std::endl; + + for( translator::const_iterator + i = trans.begin(), + i_end = trans.end(); + + i != i_end ; ++i ) + { + std::cout << i->get<spanish>() + << " <---> " + << i->get<english>() + << std::endl; + } + } + } + return 0; +} +//] diff --git a/libs/bimap/example/population_bimap.cpp b/libs/bimap/example/population_bimap.cpp new file mode 100644 index 0000000000..84c5eccab9 --- /dev/null +++ b/libs/bimap/example/population_bimap.cpp @@ -0,0 +1,121 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <iostream> +#include <string> + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/unordered_set_of.hpp> +#include <boost/bimap/multiset_of.hpp> + +#include <boost/optional.hpp> +#include <boost/none.hpp> +#include <boost/foreach.hpp> +#include <boost/assign/list_inserter.hpp> + +using namespace boost::bimaps; +using namespace boost; +using namespace std; + +int main() +{ + { + + typedef bimap< + + string, + multiset_of< optional<string> > + + > bm_type; + + bm_type bm; + + assign::insert( bm ) + + ( "John" , string("lazarus" ) ) + ( "Peter", string("vinicius") ) + ( "Simon", string("vinicius") ) + ( "Brian", none ) + ; + + cout << "John is working in " + << bm.left.at( "John" ).get_value_or( "no project" ) + << endl; + + cout << "Project vinicius is being developed by " << endl; + BOOST_FOREACH( bm_type::right_reference rp, + bm.right.equal_range( std::string("vinicius") ) ) + { + cout << rp.second << endl; + } + + cout << "This workers need a project " << endl; + BOOST_FOREACH( bm_type::right_reference rp, + bm.right.equal_range(none) ) + { + cout << rp.second << endl; + } + +} + + //[ code_population_bimap + + typedef bimap< + + unordered_set_of< std::string >, + multiset_of< long, std::greater<long> > + + > population_bimap; + + typedef population_bimap::value_type population; + + population_bimap pop; + pop.insert( population("China", 1321000000) ); + pop.insert( population("India", 1129000000) ); + pop.insert( population("United States", 301950000) ); + pop.insert( population("Indonesia", 234950000) ); + pop.insert( population("Brazil", 186500000) ); + pop.insert( population("Pakistan", 163630000) ); + + std::cout << "Countries by their population:" << std::endl; + + // First requirement + /*<< The right map view works like a + `std::multimap< long, std::string, std::greater<long> >`, + We can iterate over it to print the results in the required order. >>*/ + for( population_bimap::right_const_iterator + i = pop.right.begin(), iend = pop.right.end(); + i != iend ; ++i ) + { + std::cout << i->second << " with " << i->first << std::endl; + } + + // Second requirement + /*<< The left map view works like a `std::unordered_map< std::string, long >`, + given the name of the country we can use it to search for the population + in constant time >>*/ + std::cout << "Population of China: " << pop.left.at("China") << std::endl; + //] + + return 0; +} + diff --git a/libs/bimap/example/projection.cpp b/libs/bimap/example/projection.cpp new file mode 100644 index 0000000000..7fa3489070 --- /dev/null +++ b/libs/bimap/example/projection.cpp @@ -0,0 +1,60 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <string> +#include <iostream> + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/multiset_of.hpp> +using namespace boost::bimaps; + +void years_example() +{ + //[ code_projection_years + + typedef bimap<std::string,multiset_of<int,std::greater<int> > > bm_type; + + bm_type bm; + bm.insert( bm_type::value_type("John" ,34) ); + bm.insert( bm_type::value_type("Peter",24) ); + bm.insert( bm_type::value_type("Mary" ,12) ); + + // Find the name of the next younger person after Peter + + bm_type::left_const_iterator name_iter = bm.left.find("Peter"); + + bm_type::right_const_iterator years_iter = bm.project_right(name_iter); + + ++years_iter; + + std::cout << "The next younger person after Peter is " << years_iter->second; + //] +} + +int main() +{ + years_example(); + + return 0; +} + + diff --git a/libs/bimap/example/repetitions_counter.cpp b/libs/bimap/example/repetitions_counter.cpp new file mode 100644 index 0000000000..5d939850d4 --- /dev/null +++ b/libs/bimap/example/repetitions_counter.cpp @@ -0,0 +1,91 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <iostream> +#include <boost/tokenizer.hpp> + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/unordered_set_of.hpp> +#include <boost/bimap/list_of.hpp> + +using namespace boost::bimaps; + +struct counter { + counter() : c(0) {} + counter& operator++() { ++c; return *this; } + unsigned int operator++(int) { return c++; } + operator const unsigned int() const { return c; } + private: + unsigned int c; +}; + +int main() +{ + //[ code_repetitions_counter + + typedef bimap + < + unordered_set_of< std::string >, + list_of< counter > /*< `counter` is an integer that is initialized + in zero in the constructor >*/ + + > word_counter; + + typedef boost::tokenizer<boost::char_separator<char> > text_tokenizer; + + std::string text= + "Relations between data in the STL are represented with maps." + "A map is a directed relation, by using it you are representing " + "a mapping. In this directed relation, the first type is related to " + "the second type but it is not true that the inverse relationship " + "holds. This is useful in a lot of situations, but there are some " + "relationships that are bidirectional by nature."; + + // feed the text into the container + word_counter wc; + text_tokenizer tok(text,boost::char_separator<char>(" \t\n.,;:!?'\"-")); + + for( text_tokenizer::const_iterator it = tok.begin(), it_end = tok.end(); + it != it_end ; ++it ) + { + /*<< Because the right collection type is `list_of`, the right data + is not used a key and can be modified in the same way as with + standard maps. >>*/ + ++ wc.left[*it]; + } + + // list words with counters by order of appearance + /*<< When we insert the elements using the left map view, the element + is inserted at the end of the list. >>*/ + for( word_counter::right_const_iterator + wit = wc.right.begin(), wit_end = wc.right.end(); + + wit != wit_end; ++wit ) + { + std::cout << wit->second << ": " << wit->first; + } + //] + + return 0; +} + + diff --git a/libs/bimap/example/simple_bimap.cpp b/libs/bimap/example/simple_bimap.cpp new file mode 100644 index 0000000000..28d1e72d99 --- /dev/null +++ b/libs/bimap/example/simple_bimap.cpp @@ -0,0 +1,82 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +//[ code_simple_bimap + +#include <string> +#include <iostream> + +#include <boost/bimap.hpp> + +template< class MapType > +void print_map(const MapType & map, + const std::string & separator, + std::ostream & os ) +{ + typedef typename MapType::const_iterator const_iterator; + + for( const_iterator i = map.begin(), iend = map.end(); i != iend; ++i ) + { + os << i->first << separator << i->second << std::endl; + } +} + +int main() +{ + // Soccer World cup + + typedef boost::bimap< std::string, int > results_bimap; + typedef results_bimap::value_type position; + + results_bimap results; + results.insert( position("Argentina" ,1) ); + results.insert( position("Spain" ,2) ); + results.insert( position("Germany" ,3) ); + results.insert( position("France" ,4) ); + + std::cout << "The number of countries is " << results.size() + << std::endl; + + std::cout << "The winner is " << results.right.at(1) + << std::endl + << std::endl; + + std::cout << "Countries names ordered by their final position:" + << std::endl; + + // results.right works like a std::map< int, std::string > + + print_map( results.right, ") ", std::cout ); + + std::cout << std::endl + << "Countries names ordered alphabetically along with" + "their final position:" + << std::endl; + + // results.left works like a std::map< std::string, int > + + print_map( results.left, " ends in position ", std::cout ); + + return 0; +} +//] + diff --git a/libs/bimap/example/standard_map_comparison.cpp b/libs/bimap/example/standard_map_comparison.cpp new file mode 100644 index 0000000000..4a757f5e1f --- /dev/null +++ b/libs/bimap/example/standard_map_comparison.cpp @@ -0,0 +1,93 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <string> +#include <iostream> + +#include <map> +#include <boost/bimap/bimap.hpp> + +using namespace boost::bimaps; + +//[ code_standard_map_comparison + +template< class Map, class CompatibleKey, class CompatibleData > +void use_it( Map & m, + const CompatibleKey & key, + const CompatibleData & data ) +{ + typedef typename Map::value_type value_type; + typedef typename Map::const_iterator const_iterator; + + m.insert( value_type(key,data) ); + const_iterator iter = m.find(key); + if( iter != m.end() ) + { + assert( iter->first == key ); + assert( iter->second == data ); + + std::cout << iter->first << " --> " << iter->second; + } + m.erase(key); +} + +int main() +{ + typedef bimap< set_of<std::string>, set_of<int> > bimap_type; + bimap_type bm; + + // Standard map + { + typedef std::map< std::string, int > map_type; + map_type m; + + use_it( m, "one", 1 ); + } + + // Left map view + { + typedef bimap_type::left_map map_type; + map_type & m = bm.left; + + use_it( m, "one", 1 ); + } + + // Reverse standard map + { + typedef std::map< int, std::string > reverse_map_type; + reverse_map_type rm; + + use_it( rm, 1, "one" ); + } + + // Right map view + { + typedef bimap_type::right_map reverse_map_type; + reverse_map_type & rm = bm.right; + + use_it( rm, 1, "one" ); + } + + return 0; +} +//] + diff --git a/libs/bimap/example/step_by_step.cpp b/libs/bimap/example/step_by_step.cpp new file mode 100644 index 0000000000..bd8dd03b5f --- /dev/null +++ b/libs/bimap/example/step_by_step.cpp @@ -0,0 +1,102 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <iostream> +#include <cassert> + +// A convinience header is avaiable in the boost directory: +#include <boost/bimap.hpp> + +int main() +{ + //[ code_step_by_step_definition + + typedef boost::bimap< int, std::string > bm_type; + bm_type bm; + //] + + //[ code_step_by_step_set_of_relations_view + + bm.insert( bm_type::value_type(1, "one" ) ); + bm.insert( bm_type::value_type(2, "two" ) ); + + std::cout << "There are " << bm.size() << "relations" << std::endl; + + for( bm_type::const_iterator iter = bm.begin(), iend = bm.end(); + iter != iend; ++iter ) + { + // iter->left : data : int + // iter->right : data : std::string + + std::cout << iter->left << " <--> " << iter->right << std::endl; + } + //] + + //[ code_step_by_step_left_map_view + + /*<< The type of `bm.left` is `bm_type::left_map` and the type + of `bm.right` is `bm_type::right_map` >>*/ + typedef bm_type::left_map::const_iterator left_const_iterator; + + for( left_const_iterator left_iter = bm.left.begin(), iend = bm.left.end(); + left_iter != iend; ++left_iter ) + { + // left_iter->first : key : int + // left_iter->second : data : std::string + + std::cout << left_iter->first << " --> " << left_iter->second << std::endl; + } + + /*<< `bm_type::left_`\ -type- can be used as a shortcut for the more verbose + `bm_type::left_map::`\ -type- >>*/ + bm_type::left_const_iterator left_iter = bm.left.find(2); + assert( left_iter->second == "two" ); + + /*<< This line produces the same effect of + `bm.insert( bm_type::value_type(3,"three") );` >>*/ + bm.left.insert( bm_type::left_value_type( 3, "three" ) ); + //] + + + + //[ code_step_by_step_right_map_view + + bm_type::right_const_iterator right_iter = bm.right.find("two"); + + // right_iter->first : key : std::string + // right_iter->second : data : int + + assert( right_iter->second == 2 ); + + assert( bm.right.at("one") == 1 ); + + bm.right.erase("two"); + + /*<< This line produces the same effect of + `bm.insert( bm_type::value_type(4,"four") );` >>*/ + bm.right.insert( bm_type::right_value_type( "four", 4 ) ); + //] + + return 0; +} +//] + diff --git a/libs/bimap/example/tagged_simple_bimap.cpp b/libs/bimap/example/tagged_simple_bimap.cpp new file mode 100644 index 0000000000..b702bc87c0 --- /dev/null +++ b/libs/bimap/example/tagged_simple_bimap.cpp @@ -0,0 +1,86 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +//[ code_tagged_simple_bimap + +#include <iostream> + +#include <boost/bimap.hpp> + +struct country {}; +struct place {}; + +int main() +{ + using namespace boost::bimaps; + + // Soccer World cup. + + typedef bimap + < + tagged< std::string, country >, + tagged< int , place > + + > results_bimap; + + typedef results_bimap::value_type position; + + results_bimap results; + results.insert( position("Argentina" ,1) ); + results.insert( position("Spain" ,2) ); + results.insert( position("Germany" ,3) ); + results.insert( position("France" ,4) ); + + std::cout << "Countries names ordered by their final position:" + << std::endl; + + /*<< `results.by<place>()` is equivalent to `results.right` >>*/ + for( results_bimap::map_by<place>::const_iterator + i = results.by<place>().begin(), + iend = results.by<place>().end() ; + i != iend; ++i ) + { + /*<< `get<Tag>` works for each view of the bimap >>*/ + std::cout << i->get<place >() << ") " + << i->get<country>() << std::endl; + } + + std::cout << std::endl + << "Countries names ordered alfabetically along with" + "their final position:" + << std::endl; + + /*<< `results.by<country>()` is equivalent to `results.left` >>*/ + for( results_bimap::map_by<country>::const_iterator + i = results.by<country>().begin(), + iend = results.by<country>().end() ; + i != iend; ++i ) + { + std::cout << i->get<country>() << " ends " + << i->get<place >() << "º" + << std::endl; + } + + return 0; +} +//] + diff --git a/libs/bimap/example/tutorial_info_hook.cpp b/libs/bimap/example/tutorial_info_hook.cpp new file mode 100644 index 0000000000..92f8c74dd1 --- /dev/null +++ b/libs/bimap/example/tutorial_info_hook.cpp @@ -0,0 +1,163 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <string> +#include <iostream> + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/multiset_of.hpp> + +using namespace boost::bimaps; + + +void tutorial_about_info_hook() +{ + //[ code_tutorial_info_hook_first + + typedef bimap< + + multiset_of< std::string >, // author + set_of< std::string >, // title + + with_info< std::string > // abstract + + > bm_type; + typedef bm_type::value_type book; + + bm_type bm; + + bm.insert( + + book( "Bjarne Stroustrup" , "The C++ Programming Language", + + "For C++ old-timers, the first edition of this book is" + "the one that started it all—the font of our knowledge." ) + ); + + + // Print the author of the bible + std::cout << bm.right.at("The C++ Programming Language"); + + // Print the abstract of this book + bm_type::left_iterator i = bm.left.find("Bjarne Stroustrup"); + std::cout << i->info; + //] + + // Contrary to the two key types, the information will be mutable + // using iterators. + + //[ code_tutorial_info_hook_mutable + + i->info += "More details about this book"; + //] + + // A new function is included in unique map views: info_at(key), that + // mimics the standard at(key) function but returned the associated + // information instead of the data. + + //[ code_tutorial_info_hook_info_at + + // Print the new abstract + std::cout << bm.right.info_at("The C++ Programming Language"); + //] +} + +struct author {}; +struct title {}; +struct abstract {}; + +void tutorial_about_tagged_info_hook() +{ + //[ code_tutorial_info_hook_tagged_info + + typedef bimap< + + multiset_of< tagged< std::string, author > >, + set_of< tagged< std::string, title > >, + + with_info< tagged< std::string, abstract > > + + > bm_type; + typedef bm_type::value_type book; + + bm_type bm; + + bm.insert( + + book( "Bjarne Stroustrup" , "The C++ Programming Language", + + "For C++ old-timers, the first edition of this book is" + "the one that started it all—the font of our knowledge." ) + ); + + // Print the author of the bible + std::cout << bm.by<title>().at("The C++ Programming Language"); + + // Print the abstract of this book + bm_type::map_by<author>::iterator i = bm.by<author>().find("Bjarne Stroustrup"); + std::cout << i->get<abstract>(); + + // Contrary to the two key types, the information will be mutable + // using iterators. + + i->get<abstract>() += "More details about this book"; + + // Print the new abstract + std::cout << bm.by<title>().info_at("The C++ Programming Language"); + //] +} + + +void bimap_without_an_info_hook() +{ + //[ code_tutorial_info_hook_nothing + + typedef bimap< + + multiset_of< std::string >, // author + set_of< std::string > // title + + > bm_type; + typedef bm_type::value_type book; + + bm_type bm; + + bm.insert( book( "Bjarne Stroustrup" , "The C++ Programming Language" ) ); + bm.insert( book( "Scott Meyers" , "Effective C++" ) ); + bm.insert( book( "Andrei Alexandrescu" , "Modern C++ Design" ) ); + + // Print the author of Modern C++ + std::cout << bm.right.at( "Modern C++ Design" ); + //] +} + + +int main() +{ + tutorial_about_info_hook(); + tutorial_about_tagged_info_hook(); + bimap_without_an_info_hook(); + + return 0; +} + + diff --git a/libs/bimap/example/tutorial_modify_and_replace.cpp b/libs/bimap/example/tutorial_modify_and_replace.cpp new file mode 100644 index 0000000000..c9017cdd5d --- /dev/null +++ b/libs/bimap/example/tutorial_modify_and_replace.cpp @@ -0,0 +1,118 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <string> +#include <iostream> + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/support/lambda.hpp> + +using namespace boost::bimaps; + +void test_replace() +{ + //[ code_tutorial_replace + + typedef bimap< int, std::string > bm_type; + bm_type bm; + + bm.insert( bm_type::value_type(1,"one") ); + + // Replace (1,"one") with (1,"1") using the right map view + { + bm_type::right_iterator it = bm.right.find("one"); + + bool successful_replace = bm.right.replace_key( it, "1" ); + + assert( successful_replace ); + } + + bm.insert( bm_type::value_type(2,"two") ); + + // Fail to replace (1,"1") with (1,"two") using the left map view + { + assert( bm.size() == 2 ); + + bm_type::left_iterator it = bm.left.find(1); + + bool successful_replace = bm.left.replace_data( it, "two" ); + + /*<< `it` is still valid here, and the bimap was left unchanged >>*/ + assert( ! successful_replace ); + assert( bm.size() == 2 ); + } + //] +} + +void test_modify() +{ + //[ code_tutorial_modify + + typedef bimap< int, std::string > bm_type; + bm_type bm; + bm.insert( bm_type::value_type(1,"one") ); + + // Modify (1,"one") to (1,"1") using the right map view + { + bm_type::right_iterator it = bm.right.find("one"); + + bool successful_modify = bm.right.modify_key( it , _key = "1" ); + + assert( successful_modify ); + } + + bm.insert( bm_type::value_type(2,"two") ); + + // Fail to modify (1,"1") to (1,"two") using the left map view + { + assert( bm.size() == 2 ); + + bm_type::left_iterator it = bm.left.find(1); + + bool successful_modify = bm.left.modify_data( it, _data = "two" ); + + /*<< `it` is not longer valid and `(1,"1")` is removed from the bimap >>*/ + assert( ! successful_modify ); + assert( bm.size() == 1 ); + } + //] + + /* + // Modify (2,"two") to (3,"two") using the set of relations view + { + bm_type::iterator it = bm.begin(); + + bool successful_modify = bm.modify( it, ++_left ); + + assert( successful_modify ); + } + */ +} + +int main() +{ + test_replace(); + test_modify(); + return 0; +} +//] + diff --git a/libs/bimap/example/tutorial_range.cpp b/libs/bimap/example/tutorial_range.cpp new file mode 100644 index 0000000000..543ca96269 --- /dev/null +++ b/libs/bimap/example/tutorial_range.cpp @@ -0,0 +1,100 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <string> +#include <iostream> + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/support/lambda.hpp> + +using namespace boost::bimaps; + +void using_upper_and_lower_bound() +{ + //[ code_tutorial_range_standard_way + + typedef bimap<int,std::string> bm_type; + bm_type bm; + + // ... + + bm_type::left_iterator iter_first = bm.left.lower_bound(20); + bm_type::left_iterator iter_second = bm.left.upper_bound(50); + + // range [iter_first,iter_second) contains the elements in [20,50] + //] + + // Subtle changes + { + //[ code_tutorial_range_standard_way_subtle_changes + + bm_type::left_iterator iter_first = bm.left.upper_bound(20); + bm_type::left_iterator iter_second = bm.left.lower_bound(50); + + // range [iter_first,iter_second) contains the elements in (20,50) + //] + } +} + +void using_range() +{ + //[ code_tutorial_range + + typedef bimap<int,std::string> bm_type; + bm_type bm; + + // ... + + /*<< `range_type` is a handy typedef equal to `std::pair<iterator,iterator>`. + `const_range_type` is provided too, and it is equal to + `std::pair<const_iterator,const_iterator>` >>*/ + bm_type::left_range_type r; + + /*<< _key is a Boost.Lambda placeholder. To use it you have to include + `<boost/bimap/support/lambda.hpp>` >>*/ + r = bm.left.range( 20 <= _key, _key <= 50 ); // [20,50] + + r = bm.left.range( 20 < _key, _key < 50 ); // (20,50) + + r = bm.left.range( 20 <= _key, _key < 50 ); // [20,50) + //] + + //[ code_tutorial_range_unbounded + + r = bm.left.range( 20 <= _key, unbounded ); // [20,inf) + + r = bm.left.range( unbounded , _key < 50 ); // (-inf,50) + + /*<< This is equivalent to std::make_pair(s.begin(),s.end()) >>*/ + r = bm.left.range( unbounded , unbounded ); // (-inf,inf) + //] +} + +int main() +{ + using_upper_and_lower_bound(); + using_range(); + + return 0; +} + + diff --git a/libs/bimap/example/unconstrained_collection.cpp b/libs/bimap/example/unconstrained_collection.cpp new file mode 100644 index 0000000000..5248f74458 --- /dev/null +++ b/libs/bimap/example/unconstrained_collection.cpp @@ -0,0 +1,94 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <string> +#include <iostream> + +#include <map> +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/unconstrained_set_of.hpp> +#include <boost/bimap/support/lambda.hpp> + +using namespace boost::bimaps; + +int main() +{ + // Boost.Bimap + { + //[ code_unconstrained_collection_bimap + + typedef bimap< std::string, unconstrained_set_of<int> > bm_type; + typedef bm_type::left_map map_type; + + bm_type bm; + map_type & m = bm.left; + //] + + //[ code_unconstrained_collection_common + + m["one"] = 1; + + assert( m.find("one") != m.end() ); + + for( map_type::iterator i = m.begin(), iend = m.end(); i != iend; ++i ) + { + /*<< The right collection of the bimap is mutable so its elements + can be modified using iterators. >>*/ + ++(i->second); + } + + m.erase("one"); + //] + + m["one"] = 1; + m["two"] = 2; + + //[ code_unconstrained_collection_only_for_bimap + typedef map_type::const_iterator const_iterator; + typedef std::pair<const_iterator,const_iterator> const_range; + + /*<< This range is a model of BidirectionalRange, read the docs of + Boost.Range for more information. >>*/ + const_range r = m.range( "one" <= _key, _key <= "two" ); + for( const_iterator i = r.first; i != r.second; ++i ) + { + std::cout << i->first << "-->" << i->second << std::endl; + } + + m.modify_key( m.begin(), _key = "1" ); + //] + } + + // Standard map + { + //[ code_unconstrained_collection_map + + typedef std::map< std::string, int > map_type; + + map_type m; + //] + } + + return 0; +} + + diff --git a/libs/bimap/example/user_defined_names.cpp b/libs/bimap/example/user_defined_names.cpp new file mode 100644 index 0000000000..64952a0dbf --- /dev/null +++ b/libs/bimap/example/user_defined_names.cpp @@ -0,0 +1,142 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +// Boost.Bimap Example +//----------------------------------------------------------------------------- + +#include <boost/config.hpp> + +#include <string> +#include <iostream> + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/multiset_of.hpp> + +using namespace boost::bimaps; + +void untagged_version() +{ + //[ code_user_defined_names_untagged_version + + typedef bimap + < + multiset_of<std::string>, + int + + > People; + + People people; + + // ... + + int user_id; + std::cin >> user_id; + + // people.right : map<id,name> + + People::right_const_iterator id_iter = people.right.find(user_id); + if( id_iter != people.right.end() ) + { + // first : id + // second : name + + std::cout << "name: " << id_iter->second << std::endl + << "id: " << id_iter->first << std::endl; + } + else + { + std::cout << "Unknown id, users are:" << std::endl; + + // people.left : map<name,id> + + for( People::left_const_iterator + name_iter = people.left.begin(), + iend = people.left.end(); + + name_iter != iend; ++name_iter ) + { + // first : name + // second : id + + std::cout << "name: " << name_iter->first << std::endl + << "id: " << name_iter->second << std::endl; + } + } + //] +} + +struct id {}; +struct name {}; + +void tagged_version() +{ + //[ code_user_defined_names_tagged_version + + //<- + /* + //-> + struct id {}; // Tag for the identification number + struct name {}; // Tag for the name of the person + //<- + */ + //-> + + typedef bimap + < + tagged< int , id > , + multiset_of< tagged< std::string, name > > + + > People; + + People people; + + // ... + + int user_id; + std::cin >> user_id; + + People::map_by<id>::const_iterator id_iter = people.by<id>().find(user_id); + if( id_iter != people.by<id>().end() ) + { + std::cout << "name: " << id_iter->get<name>() << std::endl + << "id: " << id_iter->get<id>() << std::endl; + } + else + { + std::cout << "Unknown id, users are:" << std::endl; + + for( People::map_by<name>::const_iterator + name_iter = people.by<name>().begin(), + iend = people.by<name>().end(); + + name_iter != iend; ++name_iter ) + { + std::cout << "name: " << name_iter->get<name>() << std::endl + << "id: " << name_iter->get<id>() << std::endl; + } + } + //] +} + +int main() +{ + untagged_version(); + tagged_version(); + + return 0; +} + diff --git a/libs/bimap/index.html b/libs/bimap/index.html new file mode 100644 index 0000000000..f25c67266a --- /dev/null +++ b/libs/bimap/index.html @@ -0,0 +1,14 @@ +<html> +<head> +<meta http-equiv="refresh" content="0; URL=doc/html/index.html"> +</head> +<body> +Automatic redirection failed, please go to the +<a href="doc/html/index.html">Boost.Bimap documentation</a>. +<p>Copyright Matias Capeletto 2006-2007</p> +<p>Distributed under the Boost Software License, Version 1.0. (See accompanying file +<a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at +<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>). +</p> +</body> +</html> diff --git a/libs/bimap/test/Jamfile.v2 b/libs/bimap/test/Jamfile.v2 new file mode 100644 index 0000000000..091e875b72 --- /dev/null +++ b/libs/bimap/test/Jamfile.v2 @@ -0,0 +1,80 @@ +# Boost.Bimap +# +# Copyright (c) 2006-2007 Matias Capeletto +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# bring in rules for testing +import testing ; + + +test-suite "tagged_test" + : + [ run test_tagged.cpp ] + ; + + +test-suite "relation_test" + : + [ run test_structured_pair.cpp ] + [ run test_mutant.cpp ] + [ run test_mutant_relation.cpp ] + ; + + +test-suite "bimap_test" + : + + # Check library user interface + [ run test_bimap_set_of.cpp ] + [ run test_bimap_multiset_of.cpp ] + [ run test_bimap_unordered_set_of.cpp ] + [ run test_bimap_unordered_multiset_of.cpp ] + [ run test_bimap_list_of.cpp ] + [ run test_bimap_vector_of.cpp ] + + # Test bimap container + [ run test_bimap_ordered.cpp ] + [ run test_bimap_unordered.cpp ] + [ run test_bimap_sequenced.cpp ] + [ run test_bimap_unconstrained.cpp ] + [ run test_bimap_assign.cpp ] + [ run test_bimap_property_map.cpp ] + [ run test_bimap_modify.cpp ] + [ run test_bimap_range.cpp ] + [ run test_bimap_operator_bracket.cpp ] + [ run test_bimap_lambda.cpp ] + [ run test_bimap_mutable.cpp ] + [ run test_bimap_extra.cpp ] + [ run test_bimap_convenience_header.cpp ] + [ run test_bimap_project.cpp ] + [ run test_bimap_serialization.cpp + /boost/serialization//boost_serialization ] + [ run test_bimap_info.cpp ] + ; + +test-suite "compile_fail_test" + : + + [ compile-fail compile_fail/test_bimap_mutable_1.cpp ] + [ compile-fail compile_fail/test_bimap_mutable_2.cpp ] + [ compile-fail compile_fail/test_bimap_mutable_3.cpp ] + [ compile-fail compile_fail/test_bimap_info_1.cpp ] + [ compile-fail compile_fail/test_bimap_info_2.cpp ] + [ compile-fail compile_fail/test_bimap_info_3.cpp ] + ; + +test-suite "bimap_and_boost" + : + [ run ../example/bimap_and_boost/property_map.cpp ] + [ run ../example/bimap_and_boost/range.cpp ] + [ run ../example/bimap_and_boost/foreach.cpp ] + [ run ../example/bimap_and_boost/lambda.cpp ] + [ run ../example/bimap_and_boost/assign.cpp ] + [ run ../example/bimap_and_boost/xpressive.cpp ] + [ run ../example/bimap_and_boost/typeof.cpp ] + [ compile ../example/bimap_and_boost/serialization.cpp + /boost/serialization//boost_serialization ] + ; diff --git a/libs/bimap/test/compile_fail/test_bimap_info_1.cpp b/libs/bimap/test/compile_fail/test_bimap_info_1.cpp new file mode 100644 index 0000000000..e25361926b --- /dev/null +++ b/libs/bimap/test/compile_fail/test_bimap_info_1.cpp @@ -0,0 +1,49 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost.Bimap +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/list_of.hpp> + + +void test_bimap_info_1() +{ + using namespace boost::bimaps; + + typedef bimap< int, list_of<int>, with_info<int> > bm_type; + bm_type bm; + bm.insert( bm_type::value_type(1,1) ); + + // fail test + { + const bm_type & cbm = bm; + cbm.begin()->info = 10; + } +} + + +int test_main( int, char* [] ) +{ + test_bimap_info_1(); + return 0; +} + diff --git a/libs/bimap/test/compile_fail/test_bimap_info_2.cpp b/libs/bimap/test/compile_fail/test_bimap_info_2.cpp new file mode 100644 index 0000000000..339344e953 --- /dev/null +++ b/libs/bimap/test/compile_fail/test_bimap_info_2.cpp @@ -0,0 +1,48 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost.Bimap +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/list_of.hpp> + + +void test_bimap_info_2() +{ + using namespace boost::bimaps; + + typedef bimap< int, list_of<int> > bm_type; + bm_type bm; + bm.insert( bm_type::value_type(1,1) ); + + // fail test + { + bm.begin()->info; + } +} + + +int test_main( int, char* [] ) +{ + test_bimap_info_2(); + return 0; +} + diff --git a/libs/bimap/test/compile_fail/test_bimap_info_3.cpp b/libs/bimap/test/compile_fail/test_bimap_info_3.cpp new file mode 100644 index 0000000000..4dea3b57d3 --- /dev/null +++ b/libs/bimap/test/compile_fail/test_bimap_info_3.cpp @@ -0,0 +1,48 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost.Bimap +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/list_of.hpp> + + +void test_bimap_info_3() +{ + using namespace boost::bimaps; + + typedef bimap< int, list_of<int> > bm_type; + bm_type bm; + bm.insert( bm_type::value_type(1,1) ); + + // fail test + { + bm.left.info_at(1); + } +} + + +int test_main( int, char* [] ) +{ + test_bimap_info_3(); + return 0; +} + diff --git a/libs/bimap/test/compile_fail/test_bimap_mutable_1.cpp b/libs/bimap/test/compile_fail/test_bimap_mutable_1.cpp new file mode 100644 index 0000000000..03587e122e --- /dev/null +++ b/libs/bimap/test/compile_fail/test_bimap_mutable_1.cpp @@ -0,0 +1,49 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost.Bimap +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/list_of.hpp> + + +void test_bimap_mutable_1() +{ + using namespace boost::bimaps; + + typedef bimap< int, list_of<int> > bm_type; + bm_type bm; + bm.insert( bm_type::value_type(1,1) ); + + // fail test + { + const bm_type & cbm = bm; + cbm.begin()->right = 10; + } +} + + +int test_main( int, char* [] ) +{ + test_bimap_mutable_1(); + return 0; +} + diff --git a/libs/bimap/test/compile_fail/test_bimap_mutable_2.cpp b/libs/bimap/test/compile_fail/test_bimap_mutable_2.cpp new file mode 100644 index 0000000000..4693423bb2 --- /dev/null +++ b/libs/bimap/test/compile_fail/test_bimap_mutable_2.cpp @@ -0,0 +1,49 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost.Bimap +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/list_of.hpp> + + +void test_bimap_mutable_2() +{ + using namespace boost::bimaps; + + typedef bimap< int, list_of<int> > bm_type; + bm_type bm; + bm.insert( bm_type::value_type(1,1) ); + + // fail test + { + const bm_type & cbm = bm; + cbm.left.find(1)->second = 10; + } +} + + +int test_main( int, char* [] ) +{ + test_bimap_mutable_2(); + return 0; +} + diff --git a/libs/bimap/test/compile_fail/test_bimap_mutable_3.cpp b/libs/bimap/test/compile_fail/test_bimap_mutable_3.cpp new file mode 100644 index 0000000000..8b689905fc --- /dev/null +++ b/libs/bimap/test/compile_fail/test_bimap_mutable_3.cpp @@ -0,0 +1,48 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost.Bimap +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/list_of.hpp> + + +void test_bimap_mutable_3() +{ + using namespace boost::bimaps; + + typedef bimap< int, list_of<int> > bm_type; + bm_type bm; + bm.insert( bm_type::value_type(1,1) ); + + // fail test + { + bm.right.begin()->second = 10; + } +} + + +int test_main( int, char* [] ) +{ + test_bimap_mutable_3(); + return 0; +} + diff --git a/libs/bimap/test/test_bimap.hpp b/libs/bimap/test/test_bimap.hpp new file mode 100644 index 0000000000..5f9298c3b5 --- /dev/null +++ b/libs/bimap/test/test_bimap.hpp @@ -0,0 +1,488 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef LIBS_BIMAP_TEST_BIMAP_TEST_HPP +#define LIBS_BIMAP_TEST_BIMAP_TEST_HPP + +#if defined(_MSC_VER) && (_MSC_VER>=1200) +#pragma once +#endif + +#include <boost/config.hpp> + +// std +#include <cassert> +#include <algorithm> + +#include <boost/lambda/lambda.hpp> + +template< class Container, class Data > +void test_container(Container & c, const Data & d) +{ + assert( d.size() > 2 ); + + c.clear(); + + BOOST_CHECK( c.size() == 0 ); + BOOST_CHECK( c.empty() ); + + c.insert( *d.begin() ); + + c.insert( ++d.begin(),d.end() ); + + BOOST_CHECK( c.size() == d.size() ); + + BOOST_CHECK( c.size() <= c.max_size() ); + BOOST_CHECK( ! c.empty() ); + + c.erase( c.begin() ); + + BOOST_CHECK( c.size() == d.size() - 1 ); + + c.erase( c.begin(), c.end() ); + + BOOST_CHECK( c.empty() ); + + c.insert( *d.begin() ); + + BOOST_CHECK( c.size() == 1 ); + + c.insert( c.begin(), *(++d.begin()) ); + + BOOST_CHECK( c.size() == 2 ); + + BOOST_CHECK( c.begin() != c.end() ); + +} + +template< class Container, class Data > +void test_sequence_container(Container & c, const Data & d) +{ + assert( d.size() > 2 ); + + c.clear(); + + BOOST_CHECK( c.size() == 0 ); + BOOST_CHECK( c.empty() ); + + c.push_front( * d.begin() ); + c.push_back ( *(++d.begin()) ); + + BOOST_CHECK( c.front() == * c.begin() ); + BOOST_CHECK( c.back () == *(++c.begin()) ); + + BOOST_CHECK( c.size() == 2 ); + + BOOST_CHECK( c.size() <= c.max_size() ); + BOOST_CHECK( ! c.empty() ); + + c.erase( c.begin() ); + + BOOST_CHECK( c.size() == 1 ); + + c.insert( c.begin(), *(++d.begin()) ); + + c.erase( c.begin(), c.end() ); + + BOOST_CHECK( c.empty() ); + + c.push_front( *d.begin() ); + + BOOST_CHECK( c.size() == 1 ); + + BOOST_CHECK( c.begin() != c.end() ); + +} + +template< class Container, class Data > +void test_associative_container(Container & c, const Data & d) +{ + assert( d.size() > 2 ); + + c.clear(); + c.insert(d.begin(),d.end()); + + for( typename Data::const_iterator di = d.begin(), de = d.end(); + di != de; ++di ) + { + BOOST_CHECK( c.find(*di) != c.end() ); + } + + typename Data::const_iterator da = d.begin(); + typename Data::const_iterator db = ++d.begin(); + + c.erase(*da); + + BOOST_CHECK( c.size() == d.size()-1 ); + + BOOST_CHECK( c.count(*da) == 0 ); + BOOST_CHECK( c.count(*db) == 1 ); + + BOOST_CHECK( c.find(*da) == c.end() ); + BOOST_CHECK( c.find(*db) != c.end() ); + + BOOST_CHECK( c.equal_range(*db).first != c.end() ); + + c.clear(); + + BOOST_CHECK( c.equal_range(*da).first == c.end() ); +} + + +template< class Container, class Data > +void test_pair_associative_container(Container & c, const Data & d) +{ + assert( d.size() > 2 ); + + c.clear(); + c.insert(d.begin(),d.end()); + + for( typename Data::const_iterator di = d.begin(), de = d.end(); + di != de; ++di ) + { + BOOST_CHECK( c.find(di->first) != c.end() ); + } + + typename Data::const_iterator da = d.begin(); + typename Data::const_iterator db = ++d.begin(); + + c.erase(da->first); + + BOOST_CHECK( c.size() == d.size()-1 ); + + BOOST_CHECK( c.count(da->first) == 0 ); + BOOST_CHECK( c.count(db->first) == 1 ); + + BOOST_CHECK( c.find(da->first) == c.end() ); + BOOST_CHECK( c.find(db->first) != c.end() ); + + BOOST_CHECK( c.equal_range(db->first).first != c.end() ); + + c.clear(); + + BOOST_CHECK( c.equal_range(da->first).first == c.end() ); +} + + +template< class Container, class Data > +void test_simple_ordered_associative_container_equality(Container & c, const Data & d) +{ + BOOST_CHECK( std::equal( c. begin(), c. end(), d. begin() ) ); + BOOST_CHECK( std::equal( c.rbegin(), c.rend(), d.rbegin() ) ); + + BOOST_CHECK( c.lower_bound( *d.begin() ) == c.begin() ); + BOOST_CHECK( c.upper_bound( *d.begin() ) == ++c.begin() ); +} + +template< class Container, class Data > +void test_simple_ordered_associative_container(Container & c, const Data & d) +{ + assert( d.size() > 2 ); + + c.clear(); + c.insert(d.begin(),d.end()); + + for( typename Data::const_iterator di = d.begin(), de = d.end(); + di != de; ++di ) + { + typename Container::const_iterator ci = c.find(*di); + BOOST_CHECK( ci != c.end() ); + + BOOST_CHECK( ! c.key_comp()(*ci,*di) ); + BOOST_CHECK( ! c.value_comp()(*ci,*di) ); + } + + test_simple_ordered_associative_container_equality(c, d); + + const Container & cr = c; + + test_simple_ordered_associative_container_equality(cr, d); + + /* + BOOST_CHECK( c.range( *c.begin() <= ::boost::lambda::_1, + ::boost::lambda::_1 <= *(++c.begin()) ). + first == c.begin() + ); + */ +} + +template< class Container, class Data > +void test_simple_unordered_associative_container(Container & c, const Data & d) +{ + c.clear(); + c.insert( d.begin(), d.end() ); + + BOOST_CHECK( c.bucket_count() * c.max_load_factor() >= d.size() ); + BOOST_CHECK( c.max_bucket_count() >= c.bucket_count() ); + + for( typename Data::const_iterator di = d.begin(), de = d.end() ; + di != de ; ++di ) + { + // non const + { + typename Container::size_type nb = c.bucket(*c.find(*di)); + + BOOST_CHECK( c.begin(nb) != c.end(nb) ); + } + + // const + { + const Container & const_c = c; + + BOOST_CHECK( + const_c.bucket_size(const_c.bucket(*di)) == 1 + ); + + typename Container::size_type nb = + const_c.bucket(*const_c.find(*di)); + + BOOST_CHECK( + const_c.begin(nb) != const_c.end(nb) + ); + } + } + + + BOOST_CHECK( c.load_factor() < c.max_load_factor() ); + + c.max_load_factor(0.75); + + BOOST_CHECK( c.max_load_factor() == 0.75 ); + + c.rehash(10); +} + + +template< class Container, class Data > +void test_pair_ordered_associative_container_equality(Container & c, const Data & d) +{ + BOOST_CHECK( std::equal( c. begin(), c. end(), d. begin() ) ); + BOOST_CHECK( std::equal( c.rbegin(), c.rend(), d.rbegin() ) ); + + BOOST_CHECK( c.lower_bound( d.begin()->first ) == c.begin() ); + BOOST_CHECK( c.upper_bound( d.begin()->first ) == ++c.begin() ); +} + +template< class Container, class Data > +void test_pair_ordered_associative_container(Container & c, const Data & d) +{ + assert( d.size() > 2 ); + + c.clear(); + c.insert(d.begin(),d.end()); + + for( typename Container::const_iterator ci = c.begin(), ce = c.end(); + ci != ce; ++ci ) + { + typename Data::const_iterator di = d.find(ci->first); + BOOST_CHECK( di != d.end() ); + BOOST_CHECK( ! c.key_comp()(di->first,ci->first) ); + BOOST_CHECK( ! c.value_comp()(*ci,*di) ); + } + + test_pair_ordered_associative_container_equality(c, d); + + const Container & cr = c; + + test_pair_ordered_associative_container_equality(cr, d); + + BOOST_CHECK( c.range( c.begin()->first <= ::boost::lambda::_1, + ::boost::lambda::_1 <= (++c.begin())->first ). + first == c.begin() + ); +} + + +template< class Container, class Data > +void test_pair_unordered_associative_container(Container & c, const Data & d) +{ + c.clear(); + c.insert( d.begin(), d.end() ); + + BOOST_CHECK( c.bucket_count() * c.max_load_factor() >= d.size() ); + BOOST_CHECK( c.max_bucket_count() >= c.bucket_count() ); + + for( typename Data::const_iterator di = d.begin(), de = d.end() ; + di != de ; ++di ) + { + // non const + { + typename Container::size_type nb = + c.bucket(c.find(di->first)->first); + + BOOST_CHECK( c.begin(nb) != c.end(nb) ); + } + + // const + { + const Container & const_c = c; + + BOOST_CHECK( const_c.bucket_size(const_c.bucket(di->first)) == 1 ); + + typename Container::size_type nb = + const_c.bucket(const_c.find(di->first)->first); + + BOOST_CHECK( const_c.begin(nb) != const_c.end(nb) ); + } + } + + + BOOST_CHECK( c.load_factor() < c.max_load_factor() ); + + c.max_load_factor(0.75); + + BOOST_CHECK( c.max_load_factor() == 0.75 ); + + c.rehash(10); +} + + +template< class Container, class Data > +void test_unique_container(Container & c, Data & d) +{ + c.clear(); + c.insert(d.begin(),d.end()); + c.insert(*d.begin()); + BOOST_CHECK( c.size() == d.size() ); +} + +template< class Container, class Data > +void test_non_unique_container(Container & c, Data & d) +{ + c.clear(); + c.insert(d.begin(),d.end()); + c.insert(*d.begin()); + BOOST_CHECK( c.size() == (d.size()+1) ); +} + + + +template< class Bimap, class Data, class LeftData, class RightData > +void test_basic_bimap( Bimap & b, + const Data & d, + const LeftData & ld, const RightData & rd) +{ + using namespace boost::bimaps; + + test_container(b,d); + + BOOST_CHECK( & b.left == & b.template by<member_at::left >() ); + BOOST_CHECK( & b.right == & b.template by<member_at::right>() ); + + test_container(b.left , ld); + test_container(b.right, rd); +} + +template< class LeftTag, class RightTag, class Bimap, class Data > +void test_tagged_bimap(Bimap & b, + const Data & d) +{ + using namespace boost::bimaps; + + BOOST_CHECK( &b.left == & b.template by<LeftTag >() ); + BOOST_CHECK( &b.right == & b.template by<RightTag>() ); + + b.clear(); + b.insert( *d.begin() ); + + BOOST_CHECK( + b.begin()->template get<LeftTag>() == + b.template by<RightTag>().begin()->template get<LeftTag>() + ); + + BOOST_CHECK( + b.begin()->template get<RightTag>() == + b.template by<LeftTag>().begin()->template get<RightTag>() + ); + + // const test + { + + const Bimap & bc = b; + + BOOST_CHECK( &bc.left == & bc.template by<LeftTag>() ); + BOOST_CHECK( &bc.right == & bc.template by<RightTag>() ); + + BOOST_CHECK( bc.begin()->template get<LeftTag>() == + bc.template by<RightTag>().begin()->template get<LeftTag>() ); + + BOOST_CHECK( bc.begin()->template get<RightTag>() == + bc.template by<LeftTag>().begin()->template get<RightTag>() ); + } +} + + +template< class Bimap, class Data, class LeftData, class RightData > +void test_set_set_bimap(Bimap & b, + const Data & d, + const LeftData & ld, const RightData & rd) +{ + using namespace boost::bimaps; + + test_basic_bimap(b,d,ld,rd); + + test_associative_container(b,d); + test_simple_ordered_associative_container(b,d); + + test_pair_associative_container(b.left, ld); + test_pair_ordered_associative_container(b.left, ld); + test_unique_container(b.left, ld); + + test_pair_associative_container(b.right, rd); + test_pair_ordered_associative_container(b.right, rd); + test_unique_container(b.right, rd); + +} + + +template< class Bimap, class Data, class LeftData, class RightData > +void test_multiset_multiset_bimap(Bimap & b, + const Data & d, + const LeftData & ld, const RightData & rd) +{ + using namespace boost::bimaps; + + test_basic_bimap(b,d,ld,rd); + test_associative_container(b,d); + test_simple_ordered_associative_container(b,d); + + test_pair_associative_container(b.left, ld); + test_pair_ordered_associative_container(b.left, ld); + test_non_unique_container(b.left, ld); + + test_pair_associative_container(b.right, rd); + test_pair_ordered_associative_container(b.right, rd); + test_non_unique_container(b.right, rd); +} + +template< class Bimap, class Data, class LeftData, class RightData > +void test_unordered_set_unordered_multiset_bimap(Bimap & b, + const Data & d, + const LeftData & ld, + const RightData & rd) +{ + using namespace boost::bimaps; + + test_basic_bimap(b,d,ld,rd); + test_associative_container(b,d); + test_simple_unordered_associative_container(b,d); + + test_pair_associative_container(b.left, ld); + test_pair_unordered_associative_container(b.left, ld); + test_unique_container(b.left, ld); + + test_pair_associative_container(b.right, rd); + test_pair_unordered_associative_container(b.right, rd); + + // Caution, this side is a non unique container, but the other side is a + // unique container so, the overall bimap is a unique one. + test_unique_container(b.right, rd); +} + +#endif // LIBS_BIMAP_TEST_BIMAP_TEST_HPP + diff --git a/libs/bimap/test/test_bimap_assign.cpp b/libs/bimap/test/test_bimap_assign.cpp new file mode 100644 index 0000000000..2d8f372723 --- /dev/null +++ b/libs/bimap/test/test_bimap_assign.cpp @@ -0,0 +1,89 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// std +#include <sstream> +#include <algorithm> +#include <set> + +// Boost +#include <boost/assign/list_of.hpp> +#include <boost/assign/list_inserter.hpp> + +// Boost.Bimap +#include <boost/bimap/list_of.hpp> +#include <boost/bimap/unordered_multiset_of.hpp> +#include <boost/bimap/vector_of.hpp> +#include <boost/bimap/bimap.hpp> + +namespace ba = boost::assign; + + +void test_bimap_assign() +{ + using namespace boost::bimaps; + + // test + { + typedef bimap< list_of<int>, double > bm_type; + bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3); + ba::push_back( bm )(4,0.4)(5,0.5); + ba::insert( bm.right )(0.5,5)(0.6,6); + ba::push_back( bm.left )(6,0.6)(7,0.7); + } + + // test + { + typedef bimap< unordered_multiset_of<int>, vector_of<double>, + list_of_relation > bm_type; + bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3); + ba::push_front( bm )(4,0.4)(5,0.5); + ba::push_back( bm.right )(0.6,6)(0.7,7); + ba::insert( bm.left )(8,0.8)(9,0.9); + } + + // test + { + typedef bimap< int, vector_of<double>, right_based > bm_type; + bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3); + ba::push_back( bm )(4,0.4)(5,0.5); + ba::push_back( bm.right )(0.6,6)(0.7,7); + ba::insert( bm.left )(8,0.8)(9,0.9); + } + + // test + { + typedef bimap< int, vector_of<double>, set_of_relation<> > bm_type; + bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3); + ba::insert( bm )(4,0.4)(5,0.5); + ba::push_back( bm.right )(0.6,6)(0.7,7); + ba::insert( bm.left )(8,0.8)(9,0.9); + } +} + + +int test_main( int, char* [] ) +{ + test_bimap_assign(); + return 0; +} + diff --git a/libs/bimap/test/test_bimap_convenience_header.cpp b/libs/bimap/test/test_bimap_convenience_header.cpp new file mode 100644 index 0000000000..b6667ab9fc --- /dev/null +++ b/libs/bimap/test/test_bimap_convenience_header.cpp @@ -0,0 +1,38 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +#include <boost/bimap.hpp> + +void test_bimap_convenience_header() +{ + typedef boost::bimap< int, double > bm_type; + bm_type bm; + bm.insert( bm_type::value_type(1,0.1) ); + BOOST_CHECK( bm.right.at(0.1) == 1 ); +} + +int test_main( int, char* [] ) +{ + test_bimap_convenience_header(); + return 0; +} + diff --git a/libs/bimap/test/test_bimap_extra.cpp b/libs/bimap/test/test_bimap_extra.cpp new file mode 100644 index 0000000000..61492c702f --- /dev/null +++ b/libs/bimap/test/test_bimap_extra.cpp @@ -0,0 +1,89 @@ + // Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +#include <boost/static_assert.hpp> +#include <boost/type_traits/is_same.hpp> + +// Boost.Bimap +#include <boost/bimap/support/lambda.hpp> +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/list_of.hpp> + +// Support metafunctions +#include <boost/bimap/support/data_type_by.hpp> +#include <boost/bimap/support/key_type_by.hpp> +#include <boost/bimap/support/map_type_by.hpp> +#include <boost/bimap/support/value_type_by.hpp> +#include <boost/bimap/support/iterator_type_by.hpp> + +using namespace boost::bimaps; +using namespace boost::bimaps::support; + +typedef bimap<int, unconstrained_set_of<double> > bm_type; + + +namespace support_metafunctions_test { + + typedef boost::is_same + < + data_type_by< member_at::left , bm_type >::type, + key_type_by < member_at::right, bm_type >::type + + >::type test_metafunction_1; + BOOST_STATIC_ASSERT(test_metafunction_1::value); + + typedef boost::is_same + < + data_type_by< member_at::right, bm_type >::type, + key_type_by < member_at::left , bm_type >::type + + >::type test_metafunction_2; + BOOST_STATIC_ASSERT(test_metafunction_2::value); + + typedef boost::is_same + < + map_type_by < member_at::left , bm_type >::type::value_type, + value_type_by< member_at::left , bm_type >::type + + >::type test_metafunction_3; + BOOST_STATIC_ASSERT(test_metafunction_3::value); + +} // namespace support_metafunctions_test + +void test_bimap_extra() +{ + // extra tests + // --------------------------------------------------------------- + // This section test small things... when a group of this checks + // can be related it is moved to a separate unit test file. + + + +} + + +int test_main( int, char* [] ) +{ + test_bimap_extra(); + return 0; +} + diff --git a/libs/bimap/test/test_bimap_info.cpp b/libs/bimap/test/test_bimap_info.cpp new file mode 100644 index 0000000000..c1ef47974b --- /dev/null +++ b/libs/bimap/test/test_bimap_info.cpp @@ -0,0 +1,126 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +#include <boost/config.hpp> + +#include <string> + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/unordered_set_of.hpp> + + +int test_bimap_info() +{ + using namespace boost::bimaps; + + typedef bimap< double, unordered_set_of<int>, with_info<std::string> > bm_type; + + bm_type bm; + const bm_type & cbm = bm; + + // Insertion with info + bm .insert( bm_type:: value_type(1.1 , 1, "one" ) ); + bm.left .insert( bm_type:: left_value_type(2.2 , 2, "two" ) ); + bm.right.insert( bm_type::right_value_type( 3 , 3.3, "three" ) ); + + bm.begin()->info = "1"; + BOOST_CHECK( bm.right.find(1)->info == "1" ); + + bm.left.find(2.2)->info = "2"; + BOOST_CHECK( bm.right.find(2)->info == "2" ); + + bm.right.find(3)->info = "3"; + BOOST_CHECK( bm.right.find(3)->info == "3" ); + + // Empty info insert + bm .insert( bm_type:: value_type(4.4 , 4) ); + bm. left.insert( bm_type:: left_value_type(5.5 , 5) ); + bm.right.insert( bm_type::right_value_type( 6 , 6.6) ); + + BOOST_CHECK( bm.right.find(4)->info == "" ); + + bm.left.info_at(4.4) = "4"; + BOOST_CHECK( bm.right.info_at(4) == "4" ); + BOOST_CHECK( cbm.right.info_at(4) == "4" ); + + bm.right.info_at(5) = "5"; + BOOST_CHECK( bm.left.info_at(5.5) == "5" ); + BOOST_CHECK( cbm.left.info_at(5.5) == "5" ); + + return 0; +} + + +struct left {}; +struct right {}; +struct info {}; + +int test_tagged_bimap_info() +{ + using namespace boost::bimaps; + + typedef bimap< tagged<int,left>, + tagged<int,right>, + with_info<tagged<int,info> > > bm_type; + + bm_type bm; + const bm_type & cbm = bm; + + bm .insert( bm_type:: value_type(1,1,1) ); + bm.left .insert( bm_type:: left_value_type(2,2,2) ); + bm.right.insert( bm_type::right_value_type(3,3,3) ); + + bm.begin()->get<info>() = 10; + BOOST_CHECK( bm.right.find(1)->get<info>() == 10 ); + BOOST_CHECK( cbm.right.find(1)->get<info>() == 10 ); + + bm.left.find(2)->get<info>() = 20; + BOOST_CHECK( bm.right.find(2)->get<info>() == 20 ); + BOOST_CHECK( cbm.right.find(2)->get<info>() == 20 ); + + bm.right.find(3)->get<info>() = 30; + BOOST_CHECK( bm.right.find(3)->get<info>() == 30 ); + BOOST_CHECK( cbm.right.find(3)->get<info>() == 30 ); + + // Empty info insert + bm .insert( bm_type:: value_type(4,4) ); + bm. left.insert( bm_type:: left_value_type(5,5) ); + bm.right.insert( bm_type::right_value_type(6,6) ); + + bm.left.info_at(4) = 4; + BOOST_CHECK( bm.right.info_at(4) == 4 ); + BOOST_CHECK( cbm.right.info_at(4) == 4 ); + + bm.right.info_at(5) = 5; + BOOST_CHECK( bm.left.info_at(5) == 5 ); + BOOST_CHECK( cbm.left.info_at(5) == 5 ); + + return 0; +} + +int test_main( int, char* [] ) +{ + test_bimap_info(); + test_tagged_bimap_info(); + return 0; +} + diff --git a/libs/bimap/test/test_bimap_lambda.cpp b/libs/bimap/test/test_bimap_lambda.cpp new file mode 100644 index 0000000000..81b1e73d53 --- /dev/null +++ b/libs/bimap/test/test_bimap_lambda.cpp @@ -0,0 +1,47 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost.Bimap +#include <boost/bimap/support/lambda.hpp> +#include <boost/bimap/bimap.hpp> + +void test_bimap_lambda() +{ + using namespace boost::bimaps; + + typedef bimap<int,double> bm; + + bm b; + b.insert( bm::value_type(1,0.1) ); + + BOOST_CHECK( b.size() == 1 ); + BOOST_CHECK( b.left.modify_key ( b.left.begin(), _key = 2 ) ); + BOOST_CHECK( b.left.modify_data( b.left.begin(), _data = 0.2 ) ); + BOOST_CHECK( b.left.range( _key >= 1, _key < 3 ).first == b.left.begin() ); +} + +int test_main( int, char* [] ) +{ + test_bimap_lambda(); + return 0; +} + diff --git a/libs/bimap/test/test_bimap_list_of.cpp b/libs/bimap/test/test_bimap_list_of.cpp new file mode 100644 index 0000000000..e01569a993 --- /dev/null +++ b/libs/bimap/test/test_bimap_list_of.cpp @@ -0,0 +1,32 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +#include <boost/bimap/list_of.hpp> + +int test_main( int, char* [] ) +{ + typedef boost::bimaps::list_of<int> set_type; + typedef boost::bimaps::list_of_relation set_type_of_relation; + + return 0; +} + diff --git a/libs/bimap/test/test_bimap_modify.cpp b/libs/bimap/test/test_bimap_modify.cpp new file mode 100644 index 0000000000..ed0d15efbf --- /dev/null +++ b/libs/bimap/test/test_bimap_modify.cpp @@ -0,0 +1,183 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost.Bimap +#include <boost/bimap/support/lambda.hpp> +#include <boost/bimap/bimap.hpp> + +struct id{}; + +void test_bimap_modify() +{ + using namespace boost::bimaps; + + typedef bimap<int,long> bm; + + bm b; + b.insert( bm::value_type(2,200) ); + + BOOST_CHECK( b.left.at(2) == 200 ); + + bool result; + + // replace + //---------------------------------------------------------------------- + + // successful replace in left map view + { + bm::left_iterator i = b.left.begin(); + + result = b.left.replace( i, bm::left_value_type(1,100) ); + + BOOST_CHECK( result ); + BOOST_CHECK( b.size() == 1 ); + BOOST_CHECK( i->first == 1 && i->second == 100 ); + BOOST_CHECK( b.left.at(1) == 100 ); + + result = b.left.replace_key( i, 2 ); + + BOOST_CHECK( result ); + BOOST_CHECK( b.size() == 1 ); + BOOST_CHECK( i->first == 2 && i->second == 100 ); + BOOST_CHECK( b.left.at(2) == 100 ); + + result = b.left.replace_data( i, 200 ); + + BOOST_CHECK( result ); + BOOST_CHECK( b.size() == 1 ); + BOOST_CHECK( i->first == 2 && i->second == 200 ); + BOOST_CHECK( b.left.at(2) == 200 ); + } + + // successful replace in right map view + { + bm::right_iterator i = b.right.begin(); + + result = b.right.replace( i, bm::right_value_type(100,1) ); + + BOOST_CHECK( result ); + BOOST_CHECK( b.size() == 1 ); + BOOST_CHECK( i->first == 100 && i->second == 1 ); + BOOST_CHECK( b.right.at(100) == 1 ); + + result = b.right.replace_key( i, 200 ); + + BOOST_CHECK( result ); + BOOST_CHECK( b.size() == 1 ); + BOOST_CHECK( i->first == 200 && i->second == 1 ); + BOOST_CHECK( b.right.at(200) == 1 ); + + result = b.right.replace_data( i, 2 ); + + BOOST_CHECK( result ); + BOOST_CHECK( b.size() == 1 ); + BOOST_CHECK( i->first == 200 && i->second == 2 ); + BOOST_CHECK( b.right.at(200) == 2 ); + } + + // successful replace in set of relations view + { + bm::iterator i = b.begin(); + + result = b.replace( i, bm::value_type(1,100) ); + + BOOST_CHECK( result ); + BOOST_CHECK( b.size() == 1 ); + BOOST_CHECK( i->left == 1 && i->right == 100 ); + BOOST_CHECK( b.left.at(1) == 100 ); + + result = b.replace_left( i, 2 ); + + BOOST_CHECK( result ); + BOOST_CHECK( b.size() == 1 ); + BOOST_CHECK( i->left == 2 && i->right == 100 ); + BOOST_CHECK( b.left.at(2) == 100 ); + + result = b.replace_right( b.begin(), 200 ); + + BOOST_CHECK( result ); + BOOST_CHECK( b.size() == 1 ); + BOOST_CHECK( i->left == 2 && i->right == 200 ); + BOOST_CHECK( b.left.at(2) == 200 ); + + } + + b.clear(); + b.insert( bm::value_type(1,100) ); + b.insert( bm::value_type(2,200) ); + + // fail to replace in left map view + { + bm::left_iterator i = b.left.begin(); + + result = b.left.replace( i, bm::left_value_type(2,100) ); + + BOOST_CHECK( ! result ); + BOOST_CHECK( b.size() == 2 ); + BOOST_CHECK( i->first == 1 && i->second == 100 ); + BOOST_CHECK( b.left.at(1) == 100 ); + BOOST_CHECK( b.left.at(2) == 200 ); + + + // Add checks for replace_key and replace_data + } + + // Add checks for fail to replace in right map view + + // Add checks for fail to replace in set of relations view + + + // modify + // ---------------------------------------------------------------------- + + b.clear(); + b.insert( bm::value_type(1,100) ); + + // successful modify in left map view + { + result = b.left.modify_key( b.left.begin(), _key = 2 ); + + BOOST_CHECK( result ); + BOOST_CHECK( b.size() == 1 ); + BOOST_CHECK( b.left.at(2) == 100 ); + + result = b.left.modify_data( b.left.begin() , _data = 200 ); + + BOOST_CHECK( result ); + BOOST_CHECK( b.size() == 1 ); + BOOST_CHECK( b.left.at(2) == 200 ); + } + + // Add checks for successful modify in right map view + + // Add checks for fails to modify in left map view + + +} + +int test_main( int, char* [] ) +{ + test_bimap_modify(); + + return 0; +} + diff --git a/libs/bimap/test/test_bimap_multiset_of.cpp b/libs/bimap/test/test_bimap_multiset_of.cpp new file mode 100644 index 0000000000..5b86bd628f --- /dev/null +++ b/libs/bimap/test/test_bimap_multiset_of.cpp @@ -0,0 +1,32 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +#include <boost/bimap/multiset_of.hpp> + +int test_main( int, char* [] ) +{ + typedef boost::bimaps::multiset_of<int> set_type; + typedef boost::bimaps::multiset_of_relation<> set_type_of_relation; + + return 0; +} + diff --git a/libs/bimap/test/test_bimap_mutable.cpp b/libs/bimap/test/test_bimap_mutable.cpp new file mode 100644 index 0000000000..4a04f7bc62 --- /dev/null +++ b/libs/bimap/test/test_bimap_mutable.cpp @@ -0,0 +1,109 @@ + // Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost.Bimap +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/list_of.hpp> +#include <boost/bimap/vector_of.hpp> +#include <boost/bimap/unconstrained_set_of.hpp> + +using namespace boost::bimaps; + +template< class BimapType > +void test_bimap_mutable() +{ + typedef BimapType bm_type; + + bm_type bm; + bm.insert( BOOST_DEDUCED_TYPENAME bm_type::value_type(1,0.1) ); + + const bm_type & cbm = bm; + + // Map Mutable Iterator test + { + + BOOST_DEDUCED_TYPENAME bm_type::left_iterator iter = bm.left.begin(); + iter->second = 0.2; + BOOST_CHECK( iter->second == bm.left.begin()->second ); + + BOOST_DEDUCED_TYPENAME bm_type::left_const_iterator citer = bm.left.begin(); + BOOST_CHECK( citer->second == bm.left.begin()->second ); + + BOOST_DEDUCED_TYPENAME bm_type::left_const_iterator cciter = cbm.left.begin(); + BOOST_CHECK( cciter->second == cbm.left.begin()->second ); + + } + + // Set Mutable Iterator test + { + + BOOST_DEDUCED_TYPENAME bm_type::iterator iter = bm.begin(); + iter->right = 0.1; + BOOST_CHECK( iter->right == bm.begin()->right ); + + BOOST_DEDUCED_TYPENAME bm_type::const_iterator citer = bm.begin(); + BOOST_CHECK( citer->right == bm.begin()->right ); + + BOOST_DEDUCED_TYPENAME bm_type::const_iterator cciter = cbm.begin(); + BOOST_CHECK( cciter->left == cbm.begin()->left ); + + } + + // Map Assignable Reference test + { + + BOOST_DEDUCED_TYPENAME bm_type::left_reference r = *bm.left.begin(); + r.second = 0.2; + BOOST_CHECK( r == *bm.left.begin() ); + + BOOST_DEDUCED_TYPENAME bm_type::left_const_reference cr = *bm.left.begin(); + BOOST_CHECK( cr == *bm.left.begin() ); + + BOOST_DEDUCED_TYPENAME bm_type::left_const_reference ccr = *cbm.left.begin(); + BOOST_CHECK( ccr == *cbm.left.begin() ); + + } + + // Set Assignable Reference test + { + + BOOST_DEDUCED_TYPENAME bm_type::reference r = *bm.begin(); + r.right = 0.1; + BOOST_CHECK( r == *bm.begin() ); + + BOOST_DEDUCED_TYPENAME bm_type::const_reference cr = *bm.begin(); + BOOST_CHECK( cr == *bm.begin() ); + + BOOST_DEDUCED_TYPENAME bm_type::const_reference ccr = *cbm.begin(); + BOOST_CHECK( ccr == *bm.begin() ); + + } +} + +int test_main( int, char* [] ) +{ + test_bimap_mutable< bimap< int, list_of<double> > >(); + test_bimap_mutable< bimap< int, vector_of<double> > >(); + test_bimap_mutable< bimap< int, unconstrained_set_of<double> > >(); + return 0; +} + diff --git a/libs/bimap/test/test_bimap_operator_bracket.cpp b/libs/bimap/test/test_bimap_operator_bracket.cpp new file mode 100644 index 0000000000..6a39d1737f --- /dev/null +++ b/libs/bimap/test/test_bimap_operator_bracket.cpp @@ -0,0 +1,193 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost.Bimap +#include <boost/bimap/support/lambda.hpp> +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/unordered_set_of.hpp> +#include <boost/bimap/list_of.hpp> +#include <boost/bimap/vector_of.hpp> +#include <boost/bimap/unconstrained_set_of.hpp> + + +void test_bimap_operator_bracket() +{ + using namespace boost::bimaps; + + // Simple test + { + typedef bimap< int, std::string > bm; + + bm b; + b.insert( bm::value_type(0,"0") ); + b.insert( bm::value_type(1,"1") ); + b.insert( bm::value_type(2,"2") ); + b.insert( bm::value_type(3,"3") ); + + BOOST_CHECK( b.left.at(1) == "1" ); + + // Out of range test + { + bool value_not_found_test_passed = false; + b.clear(); + try + { + bool comp; + comp = b.left.at(2) < "banana"; + } + catch( std::out_of_range & ) + { + value_not_found_test_passed = true; + } + + BOOST_CHECK( value_not_found_test_passed ); + } + } + + // Mutable data test (1) + { + typedef bimap<int, list_of<std::string> > bm; + bm b; + + // Out of range test + { + bool value_not_found_test_passed = false; + b.clear(); + try + { + bool comp; + comp = b.left.at(1) < "banana"; + } + catch( std::out_of_range & ) + { + value_not_found_test_passed = true; + } + + BOOST_CHECK( value_not_found_test_passed ); + + } + + // Out of range test (const version) + { + bool value_not_found_test_passed = false; + b.clear(); + try + { + const bm & cb(b); + bool comp; + comp = cb.left.at(1) < "banana"; + } + catch( std::out_of_range & ) + { + value_not_found_test_passed = true; + } + + BOOST_CHECK( value_not_found_test_passed ); + } + + BOOST_CHECK( b.left[1] == "" ); + BOOST_CHECK( b.left.at(1) == "" ); + b.left[2] = "two"; + BOOST_CHECK( b.left.at(2) == "two" ); + b.left[2] = "<<two>>"; + BOOST_CHECK( b.left.at(2) == "<<two>>" ); + b.left.at(2) = "two"; + BOOST_CHECK( b.left.at(2) == "two" ); + + } + + // Mutable data test (2) + { + typedef bimap< vector_of<int>, unordered_set_of<std::string> > bm; + bm b; + + // Out of range test + { + bool value_not_found_test_passed = false; + b.clear(); + try + { + bool comp; + comp = b.right.at("banana") < 1; + } + catch( std::out_of_range & ) + { + value_not_found_test_passed = true; + } + BOOST_CHECK( value_not_found_test_passed ); + } + + // Out of range test (const version) + { + bool value_not_found_test_passed = false; + b.clear(); + try + { + const bm & cb(b); + bool comp; + comp = cb.right.at("banana") < 1; + } + catch( std::out_of_range & ) + { + value_not_found_test_passed = true; + } + + BOOST_CHECK( value_not_found_test_passed ); + } + + b.right["one"]; + BOOST_CHECK( b.size() == 1 ); + b.right["two"] = 2; + BOOST_CHECK( b.right.at("two") == 2 ); + b.right["two"] = -2; + BOOST_CHECK( b.right.at("two") == -2 ); + b.right.at("two") = 2; + BOOST_CHECK( b.right.at("two") == 2 ); + } + + // Mutable data test (3) + { + typedef bimap< unconstrained_set_of<int>, + unordered_set_of<std::string>, + right_based > bm; + + bm b; + + b.right["one"]; + BOOST_CHECK( b.size() == 1 ); + b.right["two"] = 2; + BOOST_CHECK( b.right.at("two") == 2 ); + b.right["two"] = -2; + BOOST_CHECK( b.right.at("two") == -2 ); + b.right.at("two") = 2; + BOOST_CHECK( b.right.at("two") == 2 ); + } + +} + +int test_main( int, char* [] ) +{ + test_bimap_operator_bracket(); + + return 0; +} + diff --git a/libs/bimap/test/test_bimap_ordered.cpp b/libs/bimap/test/test_bimap_ordered.cpp new file mode 100644 index 0000000000..4b8fb82b85 --- /dev/null +++ b/libs/bimap/test/test_bimap_ordered.cpp @@ -0,0 +1,176 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +#define BOOST_BIMAP_DISABLE_SERIALIZATION + +// Boost.Test +#include <boost/test/minimal.hpp> + +// std +#include <set> +#include <map> +#include <string> +#include <functional> + +// Set type specifications +#include <boost/bimap/set_of.hpp> +#include <boost/bimap/multiset_of.hpp> + +// bimap container +#include <boost/bimap/bimap.hpp> + +#include <libs/bimap/test/test_bimap.hpp> + +struct left_tag {}; +struct right_tag {}; + +void test_bimap() +{ + using namespace boost::bimaps; + + typedef std::map<int,double> left_data_type; + left_data_type left_data; + left_data.insert( left_data_type::value_type(1,0.1) ); + left_data.insert( left_data_type::value_type(2,0.2) ); + left_data.insert( left_data_type::value_type(3,0.3) ); + left_data.insert( left_data_type::value_type(4,0.4) ); + + typedef std::map<double,int> right_data_type; + right_data_type right_data; + right_data.insert( right_data_type::value_type(0.1,1) ); + right_data.insert( right_data_type::value_type(0.2,2) ); + right_data.insert( right_data_type::value_type(0.3,3) ); + right_data.insert( right_data_type::value_type(0.4,4) ); + + + //-------------------------------------------------------------------- + { + typedef bimap< int, double > bm_type; + + std::set< bm_type::value_type > data; + data.insert( bm_type::value_type(1,0.1) ); + data.insert( bm_type::value_type(2,0.2) ); + data.insert( bm_type::value_type(3,0.3) ); + data.insert( bm_type::value_type(4,0.4) ); + + bm_type bm; + test_set_set_bimap(bm,data,left_data,right_data); + } + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + { + typedef bimap + < + multiset_of< tagged<int, left_tag > >, + multiset_of< tagged<double, right_tag > >, + multiset_of_relation< std::less< _relation > > + + > bm_type; + + std::set< bm_type::value_type > data; + data.insert( bm_type::value_type(1,0.1) ); + data.insert( bm_type::value_type(2,0.2) ); + data.insert( bm_type::value_type(3,0.3) ); + data.insert( bm_type::value_type(4,0.4) ); + + bm_type bm; + + test_multiset_multiset_bimap(bm,data,left_data,right_data); + test_tagged_bimap<left_tag,right_tag>(bm,data); + } + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + { + typedef bimap<int,double,right_based> bm_type; + + std::set< bm_type::value_type > data; + data.insert( bm_type::value_type(1,0.1) ); + data.insert( bm_type::value_type(2,0.2) ); + data.insert( bm_type::value_type(3,0.3) ); + data.insert( bm_type::value_type(4,0.4) ); + + bm_type bm; + + test_set_set_bimap(bm,data,left_data,right_data); + } + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + { + typedef bimap + < + multiset_of< int, std::greater<int> >, set_of<std::string> , + multiset_of_relation< std::greater< _relation > > + + > bimap_type; + + bimap_type b1; + + b1.insert( bimap_type::value_type(1,"one") ); + + bimap_type b2( b1 ); + + BOOST_CHECK( b1 == b2 ); + BOOST_CHECK( ! ( b1 != b2 ) ); + BOOST_CHECK( b1 <= b2 ); + BOOST_CHECK( b1 >= b2 ); + BOOST_CHECK( ! ( b1 < b2 ) ); + BOOST_CHECK( ! ( b1 > b2 ) ); + + b1.insert( bimap_type::value_type(2,"two") ); + + b2 = b1; + BOOST_CHECK( b2 == b1 ); + + b1.insert( bimap_type::value_type(3,"three") ); + + b2.left = b1.left; + BOOST_CHECK( b2 == b1 ); + + b1.insert( bimap_type::value_type(4,"four") ); + + b2.right = b1.right; + BOOST_CHECK( b2 == b1 ); + + b1.clear(); + b2.swap(b1); + BOOST_CHECK( b2.empty() && !b1.empty() ); + + b1.left.swap( b2.left ); + BOOST_CHECK( b1.empty() && !b2.empty() ); + + b1.right.swap( b2.right ); + BOOST_CHECK( b2.empty() && !b1.empty() ); + } + //-------------------------------------------------------------------- + +} + + +int test_main( int, char* [] ) +{ + test_bimap(); + return 0; +} + diff --git a/libs/bimap/test/test_bimap_project.cpp b/libs/bimap/test/test_bimap_project.cpp new file mode 100644 index 0000000000..0f7e7676b7 --- /dev/null +++ b/libs/bimap/test/test_bimap_project.cpp @@ -0,0 +1,143 @@ + // Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +#include <string> + +// Boost.Bimap +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/list_of.hpp> + +using namespace boost::bimaps; + +struct left_tag {}; +struct right_tag {}; + +void test_bimap_project() +{ + typedef bimap + < + tagged< int , left_tag >, + list_of< tagged< std::string, right_tag > > + + > bm_type; + + bm_type bm; + + bm.insert( bm_type::value_type(1,"1") ); + bm.insert( bm_type::value_type(2,"2") ); + + bm_type:: iterator iter = bm.begin(); + bm_type:: left_iterator left_iter = bm.left.find(1); + bm_type::right_iterator right_iter = bm.right.begin(); + + const bm_type & cbm = bm; + + bm_type:: const_iterator citer = cbm.begin(); + bm_type:: left_const_iterator left_citer = cbm.left.find(1); + bm_type::right_const_iterator right_citer = cbm.right.begin(); + + // non const projection + + BOOST_CHECK( bm.project_up (bm.end()) == bm.end() ); + BOOST_CHECK( bm.project_left (bm.end()) == bm.left.end() ); + BOOST_CHECK( bm.project_right(bm.end()) == bm.right.end() ); + + BOOST_CHECK( bm.project_up (iter) == iter ); + BOOST_CHECK( bm.project_left (iter) == left_iter ); + BOOST_CHECK( bm.project_right(iter) == right_iter ); + + BOOST_CHECK( bm.project_up (left_iter) == iter ); + BOOST_CHECK( bm.project_left (left_iter) == left_iter ); + BOOST_CHECK( bm.project_right(left_iter) == right_iter ); + + BOOST_CHECK( bm.project_up (right_iter) == iter ); + BOOST_CHECK( bm.project_left (right_iter) == left_iter ); + BOOST_CHECK( bm.project_right(right_iter) == right_iter ); + + bm.project_up ( left_iter)->right = "u"; + bm.project_left (right_iter)->second = "l"; + bm.project_right( iter)->first = "r"; + + // const projection + + BOOST_CHECK( cbm.project_up (cbm.end()) == cbm.end() ); + BOOST_CHECK( cbm.project_left (cbm.end()) == cbm.left.end() ); + BOOST_CHECK( cbm.project_right(cbm.end()) == cbm.right.end() ); + + BOOST_CHECK( cbm.project_up (citer) == citer ); + BOOST_CHECK( cbm.project_left (citer) == left_citer ); + BOOST_CHECK( cbm.project_right(citer) == right_citer ); + + BOOST_CHECK( cbm.project_up (left_citer) == citer ); + BOOST_CHECK( cbm.project_left (left_citer) == left_citer ); + BOOST_CHECK( cbm.project_right(left_citer) == right_citer ); + + BOOST_CHECK( cbm.project_up (right_citer) == citer ); + BOOST_CHECK( cbm.project_left (right_citer) == left_citer ); + BOOST_CHECK( cbm.project_right(right_citer) == right_citer ); + + // mixed projection + + BOOST_CHECK( bm.project_up (left_citer) == iter ); + BOOST_CHECK( bm.project_left (left_citer) == left_iter ); + BOOST_CHECK( bm.project_right(left_citer) == right_iter ); + + BOOST_CHECK( cbm.project_up (right_iter) == citer ); + BOOST_CHECK( cbm.project_left (right_iter) == left_citer ); + BOOST_CHECK( cbm.project_right(right_iter) == right_citer ); + + bm.project_up ( left_citer)->right = "u"; + bm.project_left (right_citer)->second = "l"; + bm.project_right( citer)->first = "r"; + + // Support for tags + + BOOST_CHECK( bm.project< left_tag>(iter) == left_iter ); + BOOST_CHECK( bm.project<right_tag>(iter) == right_iter ); + + BOOST_CHECK( bm.project< left_tag>(left_iter) == left_iter ); + BOOST_CHECK( bm.project<right_tag>(left_iter) == right_iter ); + + BOOST_CHECK( bm.project< left_tag>(right_iter) == left_iter ); + BOOST_CHECK( bm.project<right_tag>(right_iter) == right_iter ); + + BOOST_CHECK( cbm.project< left_tag>(citer) == left_citer ); + BOOST_CHECK( cbm.project<right_tag>(citer) == right_citer ); + + BOOST_CHECK( cbm.project< left_tag>(left_citer) == left_citer ); + BOOST_CHECK( cbm.project<right_tag>(left_citer) == right_citer ); + + BOOST_CHECK( cbm.project< left_tag>(right_citer) == left_citer ); + BOOST_CHECK( cbm.project<right_tag>(right_citer) == right_citer ); + + bm.project< left_tag>(right_citer)->second = "l"; + bm.project<right_tag>( left_citer)->first = "r"; + +} + + +int test_main( int, char* [] ) +{ + test_bimap_project(); + return 0; +} + diff --git a/libs/bimap/test/test_bimap_property_map.cpp b/libs/bimap/test/test_bimap_property_map.cpp new file mode 100644 index 0000000000..9a2b422c39 --- /dev/null +++ b/libs/bimap/test/test_bimap_property_map.cpp @@ -0,0 +1,76 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// std +#include <set> +#include <map> +#include <cstddef> +#include <cassert> +#include <algorithm> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost.Bimap + +#include <boost/bimap/set_of.hpp> +#include <boost/bimap/property_map/set_support.hpp> + +#include <boost/bimap/unordered_set_of.hpp> +#include <boost/bimap/property_map/unordered_set_support.hpp> + +#include <boost/bimap/bimap.hpp> + + +template <class Map> +void test_readable_property_map( + Map m, + typename boost::property_traits<Map>:: key_type const & key, + typename boost::property_traits<Map>::value_type const & value +) +{ + // TODO Add STATIC_ASSERT( + // boost::property_traits<Map>::category is readable ) + + BOOST_CHECK( get(m,key) == value ); + //BOOST_CHECK( m[key] == value ); +} + + +void test_bimap_property_map() +{ + using namespace boost::bimaps; + + typedef bimap< set_of<int>, unordered_set_of<double> > bm; + + bm b; + b.insert( bm::value_type(1,0.1) ); + b.insert( bm::value_type(2,0.2) ); + b.insert( bm::value_type(3,0.3) ); + + test_readable_property_map(b.left , 1,0.1); + test_readable_property_map(b.right,0.1, 1); +} + +int test_main( int, char* [] ) +{ + test_bimap_property_map(); + return 0; +} + diff --git a/libs/bimap/test/test_bimap_range.cpp b/libs/bimap/test/test_bimap_range.cpp new file mode 100644 index 0000000000..d005cd8318 --- /dev/null +++ b/libs/bimap/test/test_bimap_range.cpp @@ -0,0 +1,134 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +#include <boost/config.hpp> + +#include <algorithm> + +#include <boost/range/functions.hpp> +#include <boost/range/metafunctions.hpp> + +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/multiset_of.hpp> +#include <boost/bimap/support/lambda.hpp> + + +template< class ForwardReadableRange, class UnaryFunctor > +UnaryFunctor for_each(const ForwardReadableRange & r, UnaryFunctor func) +{ + typedef typename + boost::range_const_iterator<ForwardReadableRange>::type const_iterator; + + for(const_iterator i= boost::begin(r), iend= boost::end(r); i!=iend; ++i ) + { + func(*i); + } + + return func; +} + +struct do_something_with_a_pair +{ + template< class Pair > + void operator()(const Pair & p) + { + BOOST_CHECK( p.first && p.second ); + } +}; + +int test_bimap_range() +{ + using namespace boost::bimaps; + + typedef bimap< double, multiset_of<int> > bm_type; + + + bm_type bm; + bm.insert( bm_type::value_type(1.1 , 1) ); + bm.insert( bm_type::value_type(2.2 , 2) ); + bm.insert( bm_type::value_type(3.3 , 3) ); + bm.insert( bm_type::value_type(4.4 , 4) ); + + + for_each( bm.left.range( 1.0 < _key, _key < 5.0 ), + do_something_with_a_pair() ); + + for_each( bm.right.range( unbounded, _key <= 2 ), + do_something_with_a_pair() ); + + + // left range + { + + bm_type::left_range_type r = bm.left.range( 2.0 < _key, _key < 4.0 ); + BOOST_CHECK( ! boost::empty(r) ); + BOOST_CHECK( boost::begin(r) == bm.left.upper_bound(2.0) ); + BOOST_CHECK( boost::end(r) == bm.left.lower_bound(4.0) ); + + } + + // right range + { + + bm_type::right_range_type r = bm.right.range( 2 <= _key, _key <= 3 ); + BOOST_CHECK( ! boost::empty(r) ); + BOOST_CHECK( boost::begin(r) == bm.right.lower_bound(2) ); + BOOST_CHECK( boost::end(r) == bm.right.upper_bound(3) ); + + } + + // const range from range + { + + bm_type:: left_const_range_type lr = bm. left.range( unbounded, _key < 4.0 ); + bm_type::right_const_range_type rr = bm.right.range( 2 < _key , unbounded ); + + } + + const bm_type & cbm = bm; + + // left const range + { + bm_type:: left_const_range_type r = cbm.left.range( unbounded, unbounded ); + BOOST_CHECK( ! boost::empty(r) ); + BOOST_CHECK( boost::begin(r) == cbm.left.begin() ); + + } + + // right const range + { + + bm_type::right_const_range_type r = cbm.right.range( 1 < _key, _key < 1 ); + BOOST_CHECK( boost::empty(r) ); + + } + + return 0; +} +//] + +int test_main( int, char* [] ) +{ + test_bimap_range(); + return 0; +} + diff --git a/libs/bimap/test/test_bimap_sequenced.cpp b/libs/bimap/test/test_bimap_sequenced.cpp new file mode 100644 index 0000000000..ad4c46fcc6 --- /dev/null +++ b/libs/bimap/test/test_bimap_sequenced.cpp @@ -0,0 +1,297 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +#define BOOST_BIMAP_DISABLE_SERIALIZATION + +// Boost.Test +#include <boost/test/minimal.hpp> + +// std +#include <set> +#include <map> +#include <algorithm> +#include <string> +#include <functional> + + +// Set type specifications +#include <boost/bimap/list_of.hpp> +#include <boost/bimap/vector_of.hpp> + +// bimap container +#include <boost/bimap/bimap.hpp> +#include <boost/bimap/support/lambda.hpp> + +#include <libs/bimap/test/test_bimap.hpp> + +struct left_tag {}; +struct right_tag {}; + +void test_bimap() +{ + using namespace boost::bimaps; + + typedef std::map<std::string,long> left_data_type; + left_data_type left_data; + left_data.insert( left_data_type::value_type("1",1) ); + left_data.insert( left_data_type::value_type("2",2) ); + left_data.insert( left_data_type::value_type("3",3) ); + left_data.insert( left_data_type::value_type("4",4) ); + + typedef std::map<long,std::string> right_data_type; + right_data_type right_data; + right_data.insert( right_data_type::value_type(1,"1") ); + right_data.insert( right_data_type::value_type(2,"2") ); + right_data.insert( right_data_type::value_type(3,"3") ); + right_data.insert( right_data_type::value_type(4,"4") ); + + + //-------------------------------------------------------------------- + { + typedef bimap< + list_of< std::string >, vector_of< long > + + > bm_type; + + std::set< bm_type::value_type > data; + data.insert( bm_type::value_type("1",1) ); + data.insert( bm_type::value_type("2",2) ); + data.insert( bm_type::value_type("3",3) ); + data.insert( bm_type::value_type("4",4) ); + + bm_type b; + + test_sequence_container(b,data); + test_sequence_container(b.left , left_data); + test_sequence_container(b.right,right_data); + + bm_type c; + + // Test assign + + b.clear(); + BOOST_CHECK( b.empty() ); + + b.left.assign(left_data.begin(),left_data.end()); + BOOST_CHECK( b.size() == left_data.size() ); + + b.right.assign(right_data.begin(),right_data.end()); + BOOST_CHECK( b.size() == right_data.size() ); + + b.assign(data.begin(),data.end()); + BOOST_CHECK( b.size() == data.size() ); + + // Test splice and merge + + b.clear(); + + c.left.insert(c.left.begin(),left_data.begin(),left_data.end()); + b.left.splice(b.left.begin(),c.left); + + BOOST_CHECK( c.size() == 0 ); + BOOST_CHECK( b.size() == 4 ); + + c.left.splice(c.left.begin(),b.left,++b.left.begin()); + + BOOST_CHECK( c.size() == 1 ); + + c.splice(c.begin(),b,b.begin(),b.end()); + + BOOST_CHECK( b.size() == 0 ); + + b.left.merge(c.left); + c.left.merge(b.left,std::less<std::string>()); + + b.left.sort(); + b.left.sort(std::less<std::string>()); + + b.left.unique(); + b.left.unique(std::equal_to<std::string>()); + + b.assign( data.begin(), data.end() ); + + BOOST_CHECK( std::equal( b.begin(), b.end(), data.begin() ) ); + b.reverse(); + BOOST_CHECK( std::equal( b.rbegin(), b.rend(), data.begin() ) ); + + b.sort(); + + BOOST_CHECK( std::equal( b.begin(), b.end(), data.begin() ) ); + + b.push_back( bm_type::value_type("4",4) ); + BOOST_CHECK( b.size() == 5 ); + b.unique(); + BOOST_CHECK( b.size() == 4 ); + b.remove_if( _key < bm_type::value_type("2",2) ); + BOOST_CHECK( b.size() == 3 ); + + b.merge(c); + + b.left.remove_if( _key < "3" ); + + // Test splice and merge + + b.clear(); c.clear(); + + c.left.insert(c.left.begin(),left_data.begin(),left_data.end()); + b.right.splice(b.right.begin(),c.right); + + BOOST_CHECK( c.size() == 0 ); + BOOST_CHECK( b.size() == 4 ); + + c.right.splice(c.right.begin(),b.right,++b.right.begin()); + + b.right.merge(c.right); + c.right.merge(b.right,std::less<long>()); + + b.right.sort(); + b.right.sort(std::less<long>()); + + b.right.unique(); + b.right.unique(std::equal_to<long>()); + + b.right.remove_if( _key < 3 ); + + b.clear(); + b.left.insert(b.left.begin(),left_data.begin(),left_data.end()); + + b.left.relocate(b.left.begin(), ++b.left.begin() ); + b.left.relocate(b.left.end(), b.left.begin(), ++b.left.begin() ); + + b.right.relocate(b.right.begin(), ++b.right.begin() ); + b.right.relocate(b.right.end(), b.right.begin(), ++b.right.begin() ); + + b.relocate(b.begin(), ++b.begin() ); + b.relocate(b.end(), b.begin(), ++b.begin() ); + } + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + { + typedef bimap + < + list_of<std::string>, list_of<long>, + vector_of_relation + + > bm_type; + + std::set< bm_type::value_type > data; + data.insert( bm_type::value_type("1",1) ); + data.insert( bm_type::value_type("2",2) ); + data.insert( bm_type::value_type("3",3) ); + data.insert( bm_type::value_type("4",4) ); + + bm_type b; + b.push_back( bm_type::value_type("1",1) ); + b.push_back( bm_type::value_type("2",2) ); + b.push_back( bm_type::value_type("3",3) ); + b.push_back( bm_type::value_type("4",4) ); + + BOOST_CHECK( std::equal( b.begin(), b.end(), data.begin() ) ); + b.reverse(); + BOOST_CHECK( std::equal( b.rbegin(), b.rend(), data.begin() ) ); + + b.sort(); + + BOOST_CHECK( std::equal( b.begin(), b.end(), data.begin() ) ); + + b.push_back( bm_type::value_type("4",4) ); + BOOST_CHECK( b.size() == 5 ); + b.unique(); + BOOST_CHECK( b.size() == 4 ); + b.remove_if( _key < bm_type::value_type("2",2) ); + BOOST_CHECK( b.size() == 3 ); + + b.relocate( b.begin(), ++b.begin() ); + b.relocate( b.end(), b.begin(), ++b.begin() ); + + b.clear(); + BOOST_CHECK( b.empty() ); + + b.left.assign(left_data.begin(),left_data.end()); + BOOST_CHECK( b.size() == left_data.size() ); + + b.right.assign(right_data.begin(),right_data.end()); + BOOST_CHECK( b.size() == right_data.size() ); + + b.assign(data.begin(),data.end()); + BOOST_CHECK( b.size() == data.size() ); + } + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + { + typedef bimap + < + vector_of< short >, list_of< short >, + vector_of_relation + + > bimap_type; + + bimap_type b1; + + b1.push_back( bimap_type::value_type(1,2) ); + + bimap_type b2( b1 ); + + BOOST_CHECK( b1 == b2 ); + BOOST_CHECK( ! ( b1 != b2 ) ); + BOOST_CHECK( b1 <= b2 ); + BOOST_CHECK( b1 >= b2 ); + BOOST_CHECK( ! ( b1 < b2 ) ); + BOOST_CHECK( ! ( b1 > b2 ) ); + + b1.push_back( bimap_type::value_type(2,3) ); + + b2 = b1; + BOOST_CHECK( b2 == b1 ); + + b1.push_back( bimap_type::value_type(3,4) ); + + b2.left = b1.left; + BOOST_CHECK( b2 == b1 ); + + b1.push_back( bimap_type::value_type(4,5) ); + + b2.right = b1.right; + BOOST_CHECK( b2 == b1 ); + + b1.clear(); + b2.swap(b1); + BOOST_CHECK( b2.empty() && !b1.empty() ); + + b1.left.swap( b2.left ); + BOOST_CHECK( b1.empty() && !b2.empty() ); + + b1.right.swap( b2.right ); + BOOST_CHECK( b2.empty() && !b1.empty() ); + } + //-------------------------------------------------------------------- + +} + + +int test_main( int, char* [] ) +{ + test_bimap(); + return 0; +} + diff --git a/libs/bimap/test/test_bimap_serialization.cpp b/libs/bimap/test/test_bimap_serialization.cpp new file mode 100644 index 0000000000..dafa6e468d --- /dev/null +++ b/libs/bimap/test/test_bimap_serialization.cpp @@ -0,0 +1,114 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// std +#include <set> +#include <map> +#include <cstddef> +#include <cassert> +#include <algorithm> +#include <sstream> +#include <algorithm> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/text_iarchive.hpp> + +// Boost.Bimap +#include <boost/bimap/bimap.hpp> + + +template< class Bimap, class Archive > +void save_bimap(const Bimap & b, Archive & ar) +{ + using namespace boost::bimaps; + + ar << b; + + const typename Bimap::left_const_iterator left_iter = b.left.begin(); + ar << left_iter; + + const typename Bimap::const_iterator iter = ++b.begin(); + ar << iter; +} + + + + +void test_bimap_serialization() +{ + using namespace boost::bimaps; + + typedef bimap<int,double> bm; + + std::set< bm::value_type > data; + data.insert( bm::value_type(1,0.1) ); + data.insert( bm::value_type(2,0.2) ); + data.insert( bm::value_type(3,0.3) ); + data.insert( bm::value_type(4,0.4) ); + + std::ostringstream oss; + + // Save it + { + bm b; + + b.insert(data.begin(),data.end()); + + boost::archive::text_oarchive oa(oss); + + save_bimap(b,oa); + } + + // Reload it + { + bm b; + + std::istringstream iss(oss.str()); + boost::archive::text_iarchive ia(iss); + + ia >> b; + + BOOST_CHECK( std::equal( b.begin(), b.end(), data.begin() ) ); + + bm::left_const_iterator left_iter; + + ia >> left_iter; + + BOOST_CHECK( left_iter == b.left.begin() ); + + bm::const_iterator iter; + + ia >> iter; + + BOOST_CHECK( iter == ++b.begin() ); + } + +} + + +int test_main( int, char* [] ) +{ + test_bimap_serialization(); + return 0; +} + diff --git a/libs/bimap/test/test_bimap_set_of.cpp b/libs/bimap/test/test_bimap_set_of.cpp new file mode 100644 index 0000000000..c51eef823c --- /dev/null +++ b/libs/bimap/test/test_bimap_set_of.cpp @@ -0,0 +1,32 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +#include <boost/bimap/set_of.hpp> + +int test_main( int, char* [] ) +{ + typedef boost::bimaps::set_of<int> set_type; + typedef boost::bimaps::set_of_relation<> set_type_of_relation; + + return 0; +} + diff --git a/libs/bimap/test/test_bimap_unconstrained.cpp b/libs/bimap/test/test_bimap_unconstrained.cpp new file mode 100644 index 0000000000..fd086d9c3e --- /dev/null +++ b/libs/bimap/test/test_bimap_unconstrained.cpp @@ -0,0 +1,109 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost.Bimap +#include <boost/bimap/support/lambda.hpp> +#include <boost/bimap/bimap.hpp> + + +void test_bimap_unconstrained() +{ + using namespace boost::bimaps; + + { + typedef bimap<int,double,unconstrained_set_of_relation> bm; + bm b; + b.left.insert( bm::left_value_type(2,34.4) ); + b.right.insert( bm::right_value_type(2.2,3) ); + } + + { + typedef bimap<int,unconstrained_set_of<double> > bm; + bm b; + b.insert( bm::value_type(2,34.4) ); + BOOST_CHECK( b.size() == 1 ); + } + + { + typedef bimap<unconstrained_set_of<int>, double > bm; + bm b; + b.right[2.4] = 34; + BOOST_CHECK( b.right.size() == 1 ); + } + + { + typedef bimap<unconstrained_set_of<int>, double, right_based > bm; + bm b; + b.right[2.4] = 34; + BOOST_CHECK( b.right.size() == 1 ); + } + + { + typedef bimap + < + int, + unconstrained_set_of<double>, + unconstrained_set_of_relation + + > bm; + + bm b; + b.left[2] = 34.4; + BOOST_CHECK( b.left.size() == 1 ); + } + + { + typedef bimap + < + unconstrained_set_of<int>, + double, + unconstrained_set_of_relation + + > bm; + + bm b; + b.right[2.4] = 34; + BOOST_CHECK( b.right.size() == 1 ); + } + + { + typedef bimap + < + unconstrained_set_of<int>, + unconstrained_set_of<double>, + set_of_relation<> + + > bm; + + bm b; + b.insert( bm::value_type(1,2.3) ); + BOOST_CHECK( b.size() == 1 ); + } +} + + +int test_main( int, char* [] ) +{ + test_bimap_unconstrained(); + return 0; +} + diff --git a/libs/bimap/test/test_bimap_unordered.cpp b/libs/bimap/test/test_bimap_unordered.cpp new file mode 100644 index 0000000000..6cba88b7a5 --- /dev/null +++ b/libs/bimap/test/test_bimap_unordered.cpp @@ -0,0 +1,167 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +#define BOOST_BIMAP_DISABLE_SERIALIZATION + +// Boost.Test +#include <boost/test/minimal.hpp> + +// std +#include <set> +#include <map> +#include <string> +#include <functional> + +// Set type specifications +#include <boost/bimap/unordered_set_of.hpp> +#include <boost/bimap/unordered_multiset_of.hpp> + +// bimap container +#include <boost/bimap/bimap.hpp> + +#include <libs/bimap/test/test_bimap.hpp> + +struct left_tag {}; +struct right_tag {}; + +void test_bimap() +{ + using namespace boost::bimaps; + + + typedef std::map<char,std::string> left_data_type; + left_data_type left_data; + left_data.insert( left_data_type::value_type('a',"a") ); + left_data.insert( left_data_type::value_type('b',"b") ); + left_data.insert( left_data_type::value_type('c',"c") ); + left_data.insert( left_data_type::value_type('d',"e") ); + + typedef std::map<std::string,char> right_data_type; + right_data_type right_data; + right_data.insert( right_data_type::value_type("a",'a') ); + right_data.insert( right_data_type::value_type("b",'b') ); + right_data.insert( right_data_type::value_type("c",'c') ); + right_data.insert( right_data_type::value_type("d",'e') ); + + + + //-------------------------------------------------------------------- + { + typedef bimap< + unordered_set_of<char>, unordered_multiset_of<std::string> + + > bm_type; + + std::set< bm_type::value_type > data; + data.insert( bm_type::value_type('a',"a") ); + data.insert( bm_type::value_type('b',"b") ); + data.insert( bm_type::value_type('c',"c") ); + data.insert( bm_type::value_type('d',"d") ); + + bm_type bm; + + test_unordered_set_unordered_multiset_bimap( + bm,data,left_data,right_data + ); + } + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + { + typedef bimap< + unordered_set_of< tagged< char , left_tag > >, + unordered_multiset_of< tagged< std::string, right_tag > > + + > bm_type; + + std::set< bm_type::value_type > data; + data.insert( bm_type::value_type('a',"a") ); + data.insert( bm_type::value_type('b',"b") ); + data.insert( bm_type::value_type('c',"c") ); + data.insert( bm_type::value_type('d',"d") ); + + bm_type bm; + + test_unordered_set_unordered_multiset_bimap( + bm,data,left_data,right_data + ); + test_tagged_bimap<left_tag,right_tag>(bm,data); + } + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + { + typedef bimap + < + set_of< char, std::greater<char> >, + unordered_multiset_of<std::string>, + unordered_set_of_relation<> + + > bm_type; + + std::set< bm_type::value_type > data; + data.insert( bm_type::value_type('a',"a") ); + data.insert( bm_type::value_type('b',"b") ); + data.insert( bm_type::value_type('c',"c") ); + data.insert( bm_type::value_type('d',"d") ); + + bm_type bm; + + test_basic_bimap(bm,data,left_data,right_data); + test_associative_container(bm,data); + test_simple_unordered_associative_container(bm,data); + } + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + { + typedef bimap + < + unordered_multiset_of< char >, + unordered_multiset_of< std::string >, + unordered_multiset_of_relation<> + + > bm_type; + + std::set< bm_type::value_type > data; + data.insert( bm_type::value_type('a',"a") ); + data.insert( bm_type::value_type('b',"b") ); + data.insert( bm_type::value_type('c',"c") ); + data.insert( bm_type::value_type('d',"d") ); + + bm_type bm; + + test_basic_bimap(bm,data,left_data,right_data); + test_associative_container(bm,data); + test_simple_unordered_associative_container(bm,data); + + } + //-------------------------------------------------------------------- +} + + +int test_main( int, char* [] ) +{ + test_bimap(); + return 0; +} + diff --git a/libs/bimap/test/test_bimap_unordered_multiset_of.cpp b/libs/bimap/test/test_bimap_unordered_multiset_of.cpp new file mode 100644 index 0000000000..27a07645b8 --- /dev/null +++ b/libs/bimap/test/test_bimap_unordered_multiset_of.cpp @@ -0,0 +1,34 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +#include <boost/bimap/unordered_multiset_of.hpp> + +int test_main( int, char* [] ) +{ + typedef boost::bimaps::unordered_multiset_of<int> set_type; + + typedef boost::bimaps:: + unordered_multiset_of_relation<> set_type_of_relation; + + return 0; +} + diff --git a/libs/bimap/test/test_bimap_unordered_set_of.cpp b/libs/bimap/test/test_bimap_unordered_set_of.cpp new file mode 100644 index 0000000000..f3aafe8354 --- /dev/null +++ b/libs/bimap/test/test_bimap_unordered_set_of.cpp @@ -0,0 +1,32 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +#include <boost/bimap/unordered_set_of.hpp> + +int test_main( int, char* [] ) +{ + typedef boost::bimaps::unordered_set_of<int> set_type; + typedef boost::bimaps::unordered_set_of_relation<> set_type_of_relation; + + return 0; +} + diff --git a/libs/bimap/test/test_bimap_vector_of.cpp b/libs/bimap/test/test_bimap_vector_of.cpp new file mode 100644 index 0000000000..01da850737 --- /dev/null +++ b/libs/bimap/test/test_bimap_vector_of.cpp @@ -0,0 +1,32 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +#include <boost/bimap/vector_of.hpp> + +int test_main( int, char* [] ) +{ + typedef boost::bimaps::vector_of<int> set_type; + typedef boost::bimaps::vector_of_relation set_type_of_relation; + + return 0; +} + diff --git a/libs/bimap/test/test_mutant.cpp b/libs/bimap/test/test_mutant.cpp new file mode 100644 index 0000000000..f422d57a07 --- /dev/null +++ b/libs/bimap/test/test_mutant.cpp @@ -0,0 +1,103 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost.MPL +#include <boost/mpl/list.hpp> +#include <boost/type_traits/is_same.hpp> + +// Boost.Bimap +#include <boost/bimap/relation/detail/mutant.hpp> + +using namespace boost::bimaps::relation::detail; + +// The mutant idiom is standard if only POD types are used. + +typedef double type_a; +typedef int type_b; + +const type_a value_a = 1.4; +const type_b value_b = 3; + +struct Data +{ + type_a a; + type_b b; +}; + +struct StdPairView +{ + typedef type_a first_type; + typedef type_b second_type; + type_a first; + type_b second; +}; + +struct ReverseStdPairView +{ + typedef type_a second_type; + typedef type_b first_type; + type_a second; + type_b first; +}; + + +struct MutantData +{ + typedef boost::mpl::list< StdPairView, ReverseStdPairView > mutant_views; + + MutantData(type_a ap, type_b bp) : a(ap), b(bp) {} + type_a a; + type_b b; +}; + + +void test_mutant_basic() +{ + + // mutant test + { + MutantData m(value_a,value_b); + + BOOST_CHECK( sizeof( MutantData ) == sizeof( StdPairView ) ); + + BOOST_CHECK( mutate<StdPairView>(m).first == value_a ); + BOOST_CHECK( mutate<StdPairView>(m).second == value_b ); + BOOST_CHECK( mutate<ReverseStdPairView>(m).first == value_b ); + BOOST_CHECK( mutate<ReverseStdPairView>(m).second == value_a ); + + ReverseStdPairView & rpair = mutate<ReverseStdPairView>(m); + rpair.first = value_b; + rpair.second = value_a; + + BOOST_CHECK( mutate<StdPairView>(m).first == value_a ); + BOOST_CHECK( mutate<StdPairView>(m).second == value_b ); + + BOOST_CHECK( &mutate<StdPairView>(m).first == &m.a ); + BOOST_CHECK( &mutate<StdPairView>(m).second == &m.b ); + } +} + +int test_main( int, char* [] ) +{ + test_mutant_basic(); + return 0; +} diff --git a/libs/bimap/test/test_mutant_relation.cpp b/libs/bimap/test/test_mutant_relation.cpp new file mode 100644 index 0000000000..8e7c8f8903 --- /dev/null +++ b/libs/bimap/test/test_mutant_relation.cpp @@ -0,0 +1,241 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// std +#include <string> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost.MPL +#include <boost/mpl/assert.hpp> +#include <boost/type_traits/is_same.hpp> + +// Boost.Bimap +#include <boost/bimap/detail/test/check_metadata.hpp> +#include <boost/bimap/tags/tagged.hpp> + +// Boost.Bimap.Relation +#include <boost/bimap/relation/mutant_relation.hpp> +#include <boost/bimap/relation/member_at.hpp> +#include <boost/bimap/relation/support/get.hpp> +#include <boost/bimap/relation/support/pair_by.hpp> +#include <boost/bimap/relation/support/pair_type_by.hpp> +#include <boost/bimap/relation/support/value_type_of.hpp> +#include <boost/bimap/relation/support/member_with_tag.hpp> +#include <boost/bimap/relation/support/is_tag_of_member_at.hpp> + +// Bimap Test Utilities +#include "test_relation.hpp" + +BOOST_BIMAP_TEST_STATIC_FUNCTION( untagged_static_test ) +{ + using namespace boost::bimaps::relation::member_at; + using namespace boost::bimaps::relation; + using namespace boost::bimaps::tags; + + struct left_data {}; + struct right_data {}; + + typedef mutant_relation< left_data, right_data > rel; + + BOOST_BIMAP_CHECK_METADATA(rel,left_value_type ,left_data); + BOOST_BIMAP_CHECK_METADATA(rel,right_value_type,right_data); + + BOOST_BIMAP_CHECK_METADATA(rel,left_tag ,left ); + BOOST_BIMAP_CHECK_METADATA(rel,right_tag,right); + + typedef tagged<left_data ,left > desired_tagged_left_type; + BOOST_BIMAP_CHECK_METADATA(rel,tagged_left_type,desired_tagged_left_type); + + typedef tagged<right_data,right> desired_tagged_right_type; + BOOST_BIMAP_CHECK_METADATA(rel,tagged_right_type,desired_tagged_right_type); + +} + +BOOST_BIMAP_TEST_STATIC_FUNCTION( tagged_static_test) +{ + using namespace boost::bimaps::relation::member_at; + using namespace boost::bimaps::relation; + using namespace boost::bimaps::tags; + + struct left_data {}; + struct right_data {}; + + struct left_tag {}; + struct right_tag {}; + + typedef mutant_relation< + tagged<left_data,left_tag>, tagged<right_data,right_tag> > rel; + + BOOST_BIMAP_CHECK_METADATA(rel,left_value_type ,left_data); + BOOST_BIMAP_CHECK_METADATA(rel,right_value_type,right_data); + + BOOST_BIMAP_CHECK_METADATA(rel,left_tag ,left_tag ); + BOOST_BIMAP_CHECK_METADATA(rel,right_tag,right_tag ); + + typedef tagged<left_data ,left_tag > desired_tagged_left_type; + BOOST_BIMAP_CHECK_METADATA(rel,tagged_left_type,desired_tagged_left_type); + + typedef tagged<right_data,right_tag> desired_tagged_right_type; + BOOST_BIMAP_CHECK_METADATA(rel,tagged_right_type,desired_tagged_right_type); +} + +struct mutant_relation_builder +{ + template< class LeftType, class RightType > + struct build + { + typedef boost::bimaps::relation:: + mutant_relation<LeftType,RightType,::boost::mpl::na,true> type; + }; +}; + +// Complex classes + +class cc1 +{ + public: + cc1(int s = 0) : a(s+100), b(s+101) {} + static int sd; + int a; + const int b; +}; + +bool operator==(const cc1 & da, const cc1 & db) +{ + return da.a == db.a && da.b == db.b; +} + +int cc1::sd = 102; + +class cc2_base +{ + public: + cc2_base(int s) : a(s+200) {} + int a; +}; + +class cc2 : public cc2_base +{ + public: + cc2(int s = 0) : cc2_base(s), b(s+201) {} + int b; +}; + +bool operator==(const cc2 & da, const cc2 & db) +{ + return da.a == db.a && da.b == db.b; +} + +class cc3_base +{ + public: + cc3_base(int s = 0) : a(s+300) {} + const int a; +}; + +class cc3 : virtual public cc3_base +{ + public: + cc3(int s = 0) : cc3_base(s), b(s+301) {} + int b; +}; + +bool operator==(const cc3 & da, const cc3 & db) +{ + return da.a == db.a && da.b == db.b; +} + +class cc4_base +{ + public: + cc4_base(int s) : a(s+400) {} + virtual ~cc4_base() {} + const int a; +}; + +class cc4 : public cc4_base +{ + public: + cc4(int s = 0) : cc4_base(s), b(s+401) {} + int b; +}; + +bool operator==(const cc4 & da, const cc4 & db) +{ + return da.a == db.a && da.b == db.b; +} + +class cc5 : public cc1, public cc3, public cc4 +{ + public: + cc5(int s = 0) : cc1(s), cc3(s), cc4(s) {} +}; + +bool operator==(const cc5 & da, const cc5 & db) +{ + return da.cc1::a == db.cc1::a && da.cc1::b == db.cc1::b && + da.cc3::a == db.cc3::a && da.cc3::b == db.cc3::b && + da.cc4::a == db.cc4::a && da.cc4::b == db.cc4::b; +} + +class cc6 +{ + public: + cc6(int s = 0) : a(s+600), b(a) {} + int a; + int & b; +}; + +bool operator==(const cc6 & da, const cc6 & db) +{ + return da.a == db.a && da.b == db.b; +} + +void test_mutant_relation() +{ + test_relation< mutant_relation_builder, char , double >( 'l', 2.5 ); + test_relation< mutant_relation_builder, double, char >( 2.5, 'r' ); + + test_relation<mutant_relation_builder, int , int >( 1 , 2 ); + + test_relation<mutant_relation_builder, std::string, int* >("left value",0); + + test_relation<mutant_relation_builder, cc1, cc2>(0,0); + test_relation<mutant_relation_builder, cc2, cc3>(0,0); + test_relation<mutant_relation_builder, cc3, cc4>(0,0); + test_relation<mutant_relation_builder, cc4, cc5>(0,0); +} + +int test_main( int, char* [] ) +{ + + // Test metadata correctness with untagged relation version + BOOST_BIMAP_CALL_TEST_STATIC_FUNCTION( tagged_static_test ); + + // Test metadata correctness with tagged relation version + BOOST_BIMAP_CALL_TEST_STATIC_FUNCTION( untagged_static_test ); + + // Test basic + test_mutant_relation(); + + return 0; +} + diff --git a/libs/bimap/test/test_relation.hpp b/libs/bimap/test/test_relation.hpp new file mode 100644 index 0000000000..65da6b9e5f --- /dev/null +++ b/libs/bimap/test/test_relation.hpp @@ -0,0 +1,191 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_BIMAP_TEST_TEST_RELATION_HPP +#define BOOST_BIMAP_TEST_TEST_RELATION_HPP + +#if defined(_MSC_VER) && (_MSC_VER>=1200) +#pragma once +#endif + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// Boost.MPL +#include <boost/mpl/assert.hpp> +#include <boost/type_traits/is_same.hpp> + +// Boost.Bimap +#include <boost/bimap/detail/test/check_metadata.hpp> +#include <boost/bimap/tags/tagged.hpp> + +// Boost.Bimap.Relation +#include <boost/bimap/relation/member_at.hpp> +#include <boost/bimap/relation/support/get.hpp> +#include <boost/bimap/relation/support/pair_by.hpp> +#include <boost/bimap/relation/support/pair_type_by.hpp> +#include <boost/bimap/relation/support/value_type_of.hpp> +#include <boost/bimap/relation/support/member_with_tag.hpp> +#include <boost/bimap/relation/support/is_tag_of_member_at.hpp> + + + +template< class Relation > +void test_relation_with_default_tags(Relation & rel, + const typename Relation::left_value_type & lv, + const typename Relation::right_value_type & rv) +{ + + using namespace boost::bimaps::relation::support; + using namespace boost::bimaps::relation; + using namespace boost::bimaps::tags; + + // It must work with normal tags + + BOOST_CHECK( pair_by<member_at::left >(rel).first == lv ); + BOOST_CHECK( pair_by<member_at::left >(rel).second == rv ); + + BOOST_CHECK( pair_by<member_at::right>(rel).first == rv ); + BOOST_CHECK( pair_by<member_at::right>(rel).second == lv ); + + BOOST_CHECK( get<member_at::left >(rel) == rel.left ); + BOOST_CHECK( get<member_at::right>(rel) == rel.right ); + + BOOST_CHECK( + get<member_at::left >(pair_by<member_at::left >(rel)) == rel.left + ); + + BOOST_CHECK( + get<member_at::right>(pair_by<member_at::left >(rel)) == rel.right + ); + + BOOST_CHECK( + get<member_at::left >(pair_by<member_at::right>(rel)) == rel.left + ); + + BOOST_CHECK( + get<member_at::right>(pair_by<member_at::right>(rel)) == rel.right + ); + +} + +template< class Relation, class LeftTag, class RightTag > +void test_relation_with_user_tags(Relation & rel, + const typename Relation::left_value_type & lv, + const typename Relation::right_value_type & rv) +{ + + using namespace boost::bimaps::relation::support; + using namespace boost::bimaps::relation; + using namespace boost::bimaps::tags; + + // And with users ones + + BOOST_CHECK( pair_by<LeftTag >(rel).first == lv ); + BOOST_CHECK( pair_by<LeftTag >(rel).second == rv ); + + BOOST_CHECK( pair_by<RightTag>(rel).first == rv ); + BOOST_CHECK( pair_by<RightTag>(rel).second == lv ); + + BOOST_CHECK( get<LeftTag >(rel) == rel.left ); + BOOST_CHECK( get<RightTag>(rel) == rel.right ); + + BOOST_CHECK( get<LeftTag >(pair_by<LeftTag >(rel)) == rel.left ); + BOOST_CHECK( get<RightTag>(pair_by<LeftTag >(rel)) == rel.right ); + + BOOST_CHECK( get<LeftTag >(pair_by<RightTag>(rel)) == rel.left ); + BOOST_CHECK( get<RightTag>(pair_by<RightTag>(rel)) == rel.right ); + + //---------------------------------------------------------------- + + BOOST_CHECK( rel.template get<LeftTag >() == rel.left ); + BOOST_CHECK( rel.template get<RightTag>() == rel.right ); + + BOOST_CHECK( pair_by<LeftTag >(rel).template get<LeftTag >()== rel.left ); + BOOST_CHECK( pair_by<LeftTag >(rel).template get<RightTag>()== rel.right); + + BOOST_CHECK( pair_by<RightTag>(rel).template get<LeftTag >()== rel.left ); + BOOST_CHECK( pair_by<RightTag>(rel).template get<RightTag>()== rel.right); +} + +struct left_user_tag {}; +struct right_user_tag {}; + +template< class RelationBuilder, class LeftData, class RightData > +void test_relation(const LeftData & lv, const RightData & rv) +{ + using namespace boost::bimaps::relation::support; + using namespace boost::bimaps::relation; + using boost::bimaps::tags::tagged; + + // Untagged test + { + typedef typename RelationBuilder::template build + < + LeftData, + RightData + + >::type rel_type; + + rel_type rel( lv, rv ); + + test_relation_with_default_tags( rel, lv, rv); + } + + // Tagged test + { + typedef typename RelationBuilder::template build + < + tagged<LeftData , left_user_tag >, + tagged<RightData, right_user_tag > + + >::type rel_type; + + rel_type rel( lv, rv ); + + test_relation_with_default_tags(rel, lv, rv ); + test_relation_with_user_tags + < + rel_type, + left_user_tag,right_user_tag + + >(rel,lv,rv); + } + + // Default Constructor, Constructor from views and some operators + { +/* + typedef typename RelationBuilder::template build + < + tagged<LeftData , left_user_tag >, + tagged<RightData, right_user_tag > + + >::type rel_type; + + typedef typename pair_type_by< left_user_tag,rel_type>::type left_pair; + typedef typename pair_type_by<right_user_tag,rel_type>::type right_pair; + + rel_type rel_from_left ( left_pair(lv,rv) ); + rel_type rel_from_right( right_pair(rv,lv) ); + + BOOST_CHECK( rel_from_left == rel_from_right ); + BOOST_CHECK( rel_from_left == rel_type(lv,rv) ); + + rel_type rel; + + rel = rel_from_left; + + BOOST_CHECK( rel == rel_from_left ); +*/ + } + +} + +#endif // BOOST_BIMAP_TEST_TEST_RELATION_HPP diff --git a/libs/bimap/test/test_structured_pair.cpp b/libs/bimap/test/test_structured_pair.cpp new file mode 100644 index 0000000000..776661c1da --- /dev/null +++ b/libs/bimap/test/test_structured_pair.cpp @@ -0,0 +1,98 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +// std +#include <utility> +#include <cstddef> + +// Boost.Static_assert +#include <boost/static_assert.hpp> + +// Boost.Bimap +#include <boost/bimap/detail/test/check_metadata.hpp> + +#include <boost/bimap/relation/structured_pair.hpp> + + +BOOST_BIMAP_TEST_STATIC_FUNCTION( static_metadata_test ) +{ + using namespace boost::bimaps::relation; + + struct data_a { char data; }; + struct data_b { double data; }; + + typedef structured_pair + < + data_a, + data_b, + normal_layout + + > sp_ab; + + typedef structured_pair + < + data_b, + data_a, + mirror_layout + + > sp_ba; + + BOOST_BIMAP_CHECK_METADATA(sp_ab, first_type , data_a); + BOOST_BIMAP_CHECK_METADATA(sp_ab, second_type, data_b); + + BOOST_BIMAP_CHECK_METADATA(sp_ba, first_type , data_b); + BOOST_BIMAP_CHECK_METADATA(sp_ba, second_type, data_a); + +} + + +void test_basic() +{ + + using namespace boost::bimaps::relation; + + // Instanciate two pairs and test the storage alignmentDataData + + typedef structured_pair< short, double, normal_layout > pair_type; + typedef structured_pair< double, short, mirror_layout > mirror_type; + + pair_type pa( 2, 3.1416 ); + mirror_type pb( 3.1416, 2 ); + + BOOST_CHECK( pa.first == pb.second ); + BOOST_CHECK( pa.second == pb.first ); + +} + + +int test_main( int, char* [] ) +{ + + BOOST_BIMAP_CALL_TEST_STATIC_FUNCTION( static_are_storage_compatible_test ); + + BOOST_BIMAP_CALL_TEST_STATIC_FUNCTION( static_metadata_test ); + + test_basic(); + + return 0; +} + diff --git a/libs/bimap/test/test_tagged.cpp b/libs/bimap/test/test_tagged.cpp new file mode 100644 index 0000000000..334fac8030 --- /dev/null +++ b/libs/bimap/test/test_tagged.cpp @@ -0,0 +1,108 @@ +// Boost.Bimap +// +// Copyright (c) 2006-2007 Matias Capeletto +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// VC++ 8.0 warns on usage of certain Standard Library and API functions that +// can be cause buffer overruns or other possible security issues if misused. +// See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx +// But the wording of the warning is misleading and unsettling, there are no +// portable alternative functions, and VC++ 8.0's own libraries use the +// functions in question. So turn off the warnings. +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_DEPRECATE + +#include <boost/config.hpp> + +// Boost.Test +#include <boost/test/minimal.hpp> + +#include <boost/static_assert.hpp> + +// Boost.MPL +#include <boost/type_traits/is_same.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/type_traits/add_const.hpp> + +// Boost.Bimap +#include <boost/bimap/detail/test/check_metadata.hpp> + +// Boost.Bimap.Tags +#include <boost/bimap/tags/tagged.hpp> +#include <boost/bimap/tags/support/default_tagged.hpp> +#include <boost/bimap/tags/support/is_tagged.hpp> +#include <boost/bimap/tags/support/overwrite_tagged.hpp> +#include <boost/bimap/tags/support/tag_of.hpp> +#include <boost/bimap/tags/support/value_type_of.hpp> +#include <boost/bimap/tags/support/apply_to_value_type.hpp> + + + + +BOOST_BIMAP_TEST_STATIC_FUNCTION( test_metafunctions ) +{ + using namespace boost::bimaps::tags::support; + using namespace boost::bimaps::tags; + using namespace boost::mpl::placeholders; + using namespace boost; + + struct tag {}; + struct value {}; + + // Test apply_to_value_type metafunction + // tagged<value,tag> ----(add_const<_>)----> tagged<value const,tag> + typedef tagged< value, tag > ttype; + typedef apply_to_value_type< add_const<_>,ttype>::type result; + typedef is_same<tagged<value const,tag>,result> compare; + BOOST_MPL_ASSERT_MSG(compare::value,tag,(result)); +} + +struct tag_a {}; +struct tag_b {}; +struct data {}; + +void test_function() +{ + + using namespace boost::bimaps::tags::support; + using namespace boost::bimaps::tags; + using boost::is_same; + + typedef tagged< data, tag_a > data_a; + typedef tagged< data, tag_b > data_b; + + BOOST_CHECK(( is_same< data_a::value_type , data >::value )); + BOOST_CHECK(( is_same< data_a::tag , tag_a >::value )); + + BOOST_CHECK(( + is_same< overwrite_tagged < data_a, tag_b >::type, data_b >::value + )); + BOOST_CHECK(( + is_same< default_tagged < data_a, tag_b >::type, data_a >::value + )); + BOOST_CHECK(( + is_same< default_tagged < data , tag_b >::type, data_b >::value + )); + + BOOST_CHECK(( is_tagged< data >::value == false )); + BOOST_CHECK(( is_tagged< data_a >::value == true )); + + BOOST_CHECK(( is_same< value_type_of<data_a>::type, data >::value )); + BOOST_CHECK(( is_same< tag_of <data_a>::type, tag_a >::value )); + +} + +int test_main( int, char* [] ) +{ + test_function(); + + // Test metanfunctions + BOOST_BIMAP_CALL_TEST_STATIC_FUNCTION( test_metafunctions ); + + return 0; +} + |