mirror of
https://github.com/boostorg/multi_index.git
synced 2026-07-21 13:23:43 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c810e19fc |
-47
@@ -1,47 +0,0 @@
|
||||
# Use, modification, and distribution are
|
||||
# subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE.txt)
|
||||
#
|
||||
# Copyright Rene Rivera 2020.
|
||||
|
||||
# For Drone CI we use the Starlark scripting language to reduce duplication.
|
||||
# As the yaml syntax for Drone CI is rather limited.
|
||||
#
|
||||
#
|
||||
globalenv={}
|
||||
linuxglobalimage="cppalliance/droneubuntu1404:1"
|
||||
windowsglobalimage="cppalliance/dronevs2019"
|
||||
|
||||
def main(ctx):
|
||||
return [
|
||||
linux_cxx("TOOLSET=gcc COMPILER=g++ CXXSTD=03,11 Job 0", "g++", packages="", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'b6589fc6ab'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x Job 1", "g++", packages="g++-4.4", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.4', 'CXXSTD': '98,0x', 'DRONE_JOB_UUID': '356a192b79'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x Job 2", "g++", packages="g++-4.6", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.6', 'CXXSTD': '03,0x', 'DRONE_JOB_UUID': 'da4b9237ba'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11 Job 3", "g++-4.7", packages="g++-4.7", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.7', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '77de68daec'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11 Job 4", "g++-4.8", packages="g++-4.8", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.8', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '1b64538924'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11 Job 5", "g++-4.9", packages="g++-4.9", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.9', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'ac3478d69a'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z Job 6", "g++-5", packages="g++-5", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-5', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'c1dfd96eea'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z Job 7", "g++-6", packages="g++-6", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-6', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '902ba3cda1'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 Job 8", "g++-7", packages="g++-7", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-7', 'CXXSTD': '03,11,14,17', 'DRONE_JOB_UUID': 'fe5dbbcea5'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17 Job 9", "g++-8", packages="g++-8", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-8', 'CXXSTD': '03,11,14,17,2a', 'DRONE_JOB_UUID': '0ade7c2cf9'}, globalenv=globalenv),
|
||||
linux_cxx("UBSAN=1 TOOLSET=gcc COMPILER=g++-7 CXXSTD=03, Job 10", "g++-7", packages="g++-7", buildtype="boost", image=linuxglobalimage, environment={'UBSAN': '1', 'TOOLSET': 'gcc', 'COMPILER': 'g++-7', 'CXXSTD': '03,11,14,17', 'UBSAN_OPTIONS': 'print_stacktrace=1', 'LINKFLAGS': '-fuse-ld=gold', 'DRONE_JOB_UUID': 'b1d5781111'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 Job 11", "clang++", packages="", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '17ba079149'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=clang COMPILER=/usr/bin/clang++ CXXST Job 12", "/usr/bin/clang++", packages="clang-3.3", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': '/usr/bin/clang++', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '7b52009b64'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=clang COMPILER=/usr/bin/clang++ CXXST Job 13", "/usr/bin/clang++", packages="clang-3.4", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': '/usr/bin/clang++', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'bd307a3ec3'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03, Job 14", "clang++", packages="clang-3.5 libstdc++-4.9-dev", llvm_os="precise", llvm_ver="3.5", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.5', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'fa35e19212'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03, Job 15", "clang++", packages="clang-3.6", llvm_os="precise", llvm_ver="3.6", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.6', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'f1abd67035'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03, Job 16", "clang++", packages="clang-3.7", llvm_os="precise", llvm_ver="3.7", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.7', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '1574bddb75'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03, Job 17", "clang++-3.8", packages="clang-3.8 libstdc++-4.9-dev", llvm_os="precise", llvm_ver="3.8", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.8', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '0716d9708d'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03, Job 18", "clang++-3.9", packages="clang-3.9 libstdc++-4.9-dev", llvm_os="precise", llvm_ver="3.9", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.9', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '9e6a55b6b4'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03, Job 19", "clang++-4.0", packages="clang-4.0", llvm_os="trusty", llvm_ver="4.0", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-4.0', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'b3f0c7f6bb'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03, Job 20", "clang++-5.0", packages="clang-5.0", llvm_os="trusty", llvm_ver="5.0", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-5.0', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '91032ad7bb'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03, Job 21", "clang++-6.0", packages="clang-6.0", llvm_os="trusty", llvm_ver="6.0", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-6.0', 'CXXSTD': '03,11,14,17,2a', 'DRONE_JOB_UUID': '472b07b9fc'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11 Job 22", "clang++-7", packages="clang-7", llvm_os="trusty", llvm_ver="7", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-7', 'CXXSTD': '03,11,14,17,2a', 'DRONE_JOB_UUID': '12c6fc06c9'}, globalenv=globalenv),
|
||||
linux_cxx("UBSAN=1 TOOLSET=clang COMPILER=clang++-7 CXXS Job 23", "clang++-7", packages="clang-7 libstdc++-5-dev", llvm_os="trusty", llvm_ver="7", buildtype="boost", image=linuxglobalimage, environment={'UBSAN': '1', 'TOOLSET': 'clang', 'COMPILER': 'clang++-7', 'CXXSTD': '03,11,14,17,2a', 'UBSAN_OPTIONS': 'print_stacktrace=1', 'DRONE_JOB_UUID': 'd435a6cdd7'}, globalenv=globalenv),
|
||||
linux_cxx("TOOLSET=clang COMPILER=clang++-libc++ CXXSTD= Job 24", "clang++-libc++", packages="libc++-dev", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-libc++', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '4d134bc072'}, globalenv=globalenv),
|
||||
linux_cxx("UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ Job 25", "clang++-libc++", packages="libc++-dev", buildtype="boost", image=linuxglobalimage, environment={'UBSAN': '1', 'TOOLSET': 'clang', 'COMPILER': 'clang++-libc++', 'CXXSTD': '03,11,14,1z', 'UBSAN_OPTIONS': 'print_stacktrace=1', 'DRONE_JOB_UUID': 'f6e1126ced'}, globalenv=globalenv),
|
||||
osx_cxx("TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,1 Job 26", "clang++", packages="", buildtype="boost", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_OS_NAME': 'osx', 'DRONE_JOB_UUID': '887309d048'}, globalenv=globalenv),
|
||||
]
|
||||
|
||||
# from https://github.com/boostorg/boost-ci
|
||||
load("@boost_ci//ci/drone/:functions.star", "linux_cxx","windows_cxx","osx_cxx","freebsd_cxx")
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
export TRAVIS_BUILD_DIR=$(pwd)
|
||||
export DRONE_BUILD_DIR=$(pwd)
|
||||
export TRAVIS_BRANCH=$DRONE_BRANCH
|
||||
export VCS_COMMIT_ID=$DRONE_COMMIT
|
||||
export GIT_COMMIT=$DRONE_COMMIT
|
||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
||||
|
||||
echo '==================================> BEFORE_INSTALL'
|
||||
|
||||
. .drone/before-install.sh
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
cd ..
|
||||
git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
git submodule update --init
|
||||
git rm --ignore-unmatch libs/multi_index/
|
||||
./bootstrap.sh
|
||||
./b2 headers
|
||||
mkdir libs/multi_index
|
||||
cp -r $TRAVIS_BUILD_DIR/* libs/multi_index
|
||||
|
||||
echo '==================================> BEFORE_SCRIPT'
|
||||
|
||||
. $DRONE_BUILD_DIR/.drone/before-script.sh
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
./b2 libs/multi_index/test toolset=$TOOLSET cxxstd=$CXXSTD
|
||||
|
||||
echo '==================================> AFTER_SUCCESS'
|
||||
|
||||
. $DRONE_BUILD_DIR/.drone/after-success.sh
|
||||
-275
@@ -1,275 +0,0 @@
|
||||
# Copyright 2003-2019 Joaquín M López Muñoz.
|
||||
# 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)
|
||||
#
|
||||
# See http://www.boost.org/libs/multi_index for library home page.
|
||||
|
||||
sudo: false
|
||||
|
||||
language: cpp
|
||||
|
||||
os: linux
|
||||
|
||||
dist: trusty
|
||||
|
||||
branches:
|
||||
only:
|
||||
- develop
|
||||
- master
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BOGUS_JOB=true
|
||||
|
||||
matrix:
|
||||
exclude: # workaround for https://github.com/travis-ci/travis-ci/issues/4681
|
||||
- env: BOGUS_JOB=true
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
|
||||
- os: linux
|
||||
compiler: g++-4.4
|
||||
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.4
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- os: linux
|
||||
compiler: g++-4.6
|
||||
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- os: linux
|
||||
compiler: g++-4.7
|
||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- os: linux
|
||||
compiler: g++-4.8
|
||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- os: linux
|
||||
compiler: g++-4.9
|
||||
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
||||
- os: linux
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.3
|
||||
- os: linux
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.4
|
||||
- os: linux
|
||||
compiler: clang++-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.5
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.5
|
||||
- os: linux
|
||||
compiler: clang++-3.6
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.6
|
||||
- os: linux
|
||||
compiler: clang++-3.7
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.7
|
||||
- os: linux
|
||||
compiler: clang++-3.8
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
- os: linux
|
||||
compiler: clang++-3.9
|
||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.9
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.9
|
||||
- os: linux
|
||||
compiler: clang++-4.0
|
||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-4.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-4.0
|
||||
- os: linux
|
||||
compiler: clang++-5.0
|
||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-5.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-5.0
|
||||
- os: linux
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-6.0
|
||||
- os: linux
|
||||
compiler: clang++-7
|
||||
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-7
|
||||
- os: linux
|
||||
compiler: clang++-7
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-7
|
||||
- libstdc++-5-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-7
|
||||
- os: linux
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
- os: linux
|
||||
compiler: clang++-libc++
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
|
||||
install:
|
||||
- cd ..
|
||||
- git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule update --init
|
||||
- git rm --ignore-unmatch libs/multi_index/
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
- mkdir libs/multi_index
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/multi_index
|
||||
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 libs/multi_index/test toolset=$TOOLSET cxxstd=$CXXSTD
|
||||
@@ -1,10 +0,0 @@
|
||||
# Boost Multi-index Containers Library
|
||||
|
||||
Branch | Travis | Drone | AppVeyor | Regression tests
|
||||
---------|--------|-------|----------|-----------------
|
||||
develop | [](https://travis-ci.com/boostorg/multi_index) | [](https://drone.cpp.al/boostorg/multi_index) | [](https://ci.appveyor.com/project/joaquintides/multi-index) | [](https://www.boost.org/development/tests/develop/developer/multi_index.html)
|
||||
master | [](https://travis-ci.com/boostorg/multi_index) | [](https://drone.cpp.al/boostorg/multi_index) | [](https://ci.appveyor.com/project/joaquintides/multi-index) | [](https://www.boost.org/development/tests/master/developer/multi_index.html)
|
||||
|
||||
[Boost.MultiIndex](http://boost.org/libs/multi_index) provides a class template
|
||||
named `multi_index_container` which enables the construction of containers
|
||||
maintaining one or more indices with different sorting and access semantics.
|
||||
@@ -1,37 +0,0 @@
|
||||
# Copyright 2003-2021 Joaquín M López Muñoz.
|
||||
# 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)
|
||||
#
|
||||
# See http://www.boost.org/libs/multi_index for library home page.
|
||||
|
||||
version: 1.0.{build}-{branch}
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0,msvc-14.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17
|
||||
|
||||
install:
|
||||
- cd ..
|
||||
- git clone -b %APPVEYOR_REPO_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule update --init
|
||||
- git rm --ignore-unmatch libs/multi_index/
|
||||
- bootstrap
|
||||
- b2 headers
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\multi_index\
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- b2 address-model=32 libs/multi_index/test toolset=%TOOLSET% %CXXSTD%
|
||||
@@ -148,37 +148,6 @@ codebase.
|
||||
<br style="clear:all;">
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_35">Boost 1.35 release</a></h2>
|
||||
|
||||
<p>
|
||||
<a href="tutorial/key_extraction.html#global_fun"><code>global_fun</code></a>
|
||||
was included after a proposal by Markus Werle. Bruno Martínez Aguerre
|
||||
suggested the inclusion of
|
||||
<a href="tutorial/indices.html#iterator_to"><code>iterator_to</code></a>. The
|
||||
rollback versions of <code>modify</code> and <code>modify_key</code> arose
|
||||
from discussions with Matías Capeletto. Steven Watanabe spotted an
|
||||
include guard bug present from the first release of the library.
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_36">Boost 1.36 release</a></h2>
|
||||
|
||||
<p>
|
||||
Thanks to Amit Jain for reporting a problem with allocator management.
|
||||
Michael Fawcett proposed the addition of an allocator constructor to
|
||||
<code>multi_index_container</code>.
|
||||
A report from Zachary Zhou has led to
|
||||
<a href="release_notes.html#stable_update">enhancing the behavior of
|
||||
hashed indices update functions</a> so that they meet some intuitive expectations.
|
||||
Grzegorz Jakacki spotted some internal dead code.
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_56">Boost 1.56 release</a></h2>
|
||||
|
||||
<p>
|
||||
Stephen Kelly has contributed the removal of workaround code for old compilers
|
||||
no longer supported.
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="prev_link"><a href="release_notes.html"><img src="prev.gif" alt="release notes" border="0"><br>
|
||||
@@ -192,9 +161,9 @@ Index
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised October 9th 2013</p>
|
||||
<p>Revised December 21st 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2013 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
+843
-161
File diff suppressed because it is too large
Load Diff
+16
-40
@@ -31,7 +31,7 @@ Tests
|
||||
|
||||
<ul>
|
||||
<li><a href="#example1">Example 1: basic usage</a></li>
|
||||
<li><a href="#example2">Example 2: using functions as keys</a></li>
|
||||
<li><a href="#example2">Example 2: using member functions as keys</a></li>
|
||||
<li><a href="#example3">Example 3: constructing <code>multi_index_container</code>s
|
||||
with <code>ctor_args_list</code></a></li>
|
||||
<li><a href="#example4">Example 4: bidirectional map</a></li>
|
||||
@@ -42,7 +42,6 @@ Tests
|
||||
<li><a href="#example9">Example 9: serialization and MRU lists</a></li>
|
||||
<li><a href="#example10">Example 10: random access indices</a></li>
|
||||
<li><a href="#example11">Example 11: index rearrangement</a></li>
|
||||
<li><a href="#example12">Example 12: using Boost.Interprocess allocators</a></li>
|
||||
</ul>
|
||||
|
||||
<h2><a name="example1">Example 1: basic usage</a></h2>
|
||||
@@ -56,23 +55,23 @@ Basic program showing the multi-indexing capabilities of Boost.MultiIndex
|
||||
with an admittedly boring set of <code>employee</code> records.
|
||||
</p>
|
||||
|
||||
<h2><a name="example2">Example 2: using functions as keys</a></h2>
|
||||
<h2><a name="example2">Example 2: using member functions as keys</a></h2>
|
||||
|
||||
<p>
|
||||
See <a href="../example/fun_key.cpp">source code</a>.
|
||||
See <a href="../example/memfun_key.cpp">source code</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Usually keys assigned to an index are based on a member variable of the
|
||||
element, but key extractors can be defined which take their value from
|
||||
a member function or a global function. This has some similarity with the concept of
|
||||
a member function. This has some similarity with the concept of
|
||||
<i>calculated keys</i> supported by some relational database engines.
|
||||
The example shows how to use the predefined <code>const_mem_fun</code>
|
||||
and <code>global_fun</code> key extractors to deal with this situation.
|
||||
key extractor to deal with this situation.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Keys based on functions usually will not be actual references,
|
||||
Keys based on member functions usually will not be actual references,
|
||||
but rather the temporary values resulting from the invocation of the
|
||||
member function used. This implies that <code>modify_key</code> cannot be
|
||||
applied to this type of extractors, which is a perfectly logical
|
||||
@@ -104,20 +103,14 @@ See <a href="../example/bimap.cpp">source code</a>.
|
||||
<p>
|
||||
This example shows how to construct a bidirectional map with
|
||||
<code>multi_index_container</code>. By a <i>bidirectional map</i> we mean
|
||||
a container of <code>(const FromType,const ToType)</code> pairs
|
||||
such that no two elements exists with the same first
|
||||
<i>or</i> second component (<code>std::map</code> only
|
||||
guarantees uniqueness of the first component). Fast lookup is provided
|
||||
a container of elements of <code>std::pair<const FromType,const ToType></code>
|
||||
such that no two elements exists with the same <code>first</code>
|
||||
<i>or</i> <code>second</code> value (<code>std::map</code> 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.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
This bidirectional map can be considered as a primitive precursor
|
||||
to the full-fledged container provided by
|
||||
<a href="../../bimap/index.html">Boost.Bimap</a>.
|
||||
</p>
|
||||
|
||||
<h2><a name="example5">Example 5: sequenced indices</a></h2>
|
||||
|
||||
<p>
|
||||
@@ -174,9 +167,9 @@ involves having the manufactures stored in a separate
|
||||
|
||||
<span class=keyword>struct</span> <span class=identifier>car_model</span>
|
||||
<span class=special>{</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>model</span><span class=special>;</span>
|
||||
<span class=keyword>const</span> <span class=identifier>car_manufacturer</span><span class=special>*</span> <span class=identifier>manufacturer</span><span class=special>;</span>
|
||||
<span class=keyword>int</span> <span class=identifier>price</span><span class=special>;</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>model</span><span class=special>;</span>
|
||||
<span class=identifier>car_manufacturer</span><span class=special>*</span> <span class=identifier>manufacturer</span><span class=special>;</span>
|
||||
<span class=keyword>int</span> <span class=identifier>price</span><span class=special>;</span>
|
||||
<span class=special>};</span>
|
||||
</pre></blockquote>
|
||||
|
||||
@@ -222,7 +215,7 @@ of its associated <code>car_manufacturer</code> can be accomplished with
|
||||
<blockquote><pre>
|
||||
<span class=identifier>key_from_key</span><span class=special><</span>
|
||||
<span class=identifier>member</span><span class=special><</span><span class=identifier>car_manufacturer</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>car_manufacturer</span><span class=special>::</span><span class=identifier>name</span><span class=special>>,</span>
|
||||
<span class=identifier>member</span><span class=special><</span><span class=identifier>car_model</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>car_manufacturer</span> <span class=special>*,&</span><span class=identifier>car_model</span><span class=special>::</span><span class=identifier>manufacturer</span><span class=special>></span>
|
||||
<span class=identifier>member</span><span class=special><</span><span class=identifier>car_model</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>car_manufacturer</span> <span class=special>*,</span><span class=identifier>car_model</span><span class=special>::</span><span class=identifier>manufacturer</span><span class=special>></span>
|
||||
<span class=special>></span>
|
||||
</pre></blockquote>
|
||||
|
||||
@@ -419,23 +412,6 @@ is used to apply to the deck a shuffle performed externally on an
|
||||
auxiliary data structure.
|
||||
</p>
|
||||
|
||||
<h2><a name="example12">Example 12: using Boost.Interprocess allocators</a></h2>
|
||||
|
||||
<p>
|
||||
See <a href="../example/ip_allocator.cpp">source code</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Boost.MultiIndex supports special allocators such as those provided by
|
||||
<a href="../../interprocess/index.html">Boost.Interprocess</a>,
|
||||
which allows for <code>multi_index_container</code>s to be placed in shared
|
||||
memory. The example features a front-end to a small book database
|
||||
implemented by means of a <code>multi_index_container</code> stored
|
||||
in a Boost.Interprocess memory mapped file. The reader can verify that several
|
||||
instances of the program correctly work simultaneously and immediately see
|
||||
the changes to the database performed by any other instance.
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="prev_link"><a href="performance.html"><img src="prev.gif" alt="performance" border="0"><br>
|
||||
@@ -450,9 +426,9 @@ Tests
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised November 18th 2019</p>
|
||||
<p>Revised March 3rd 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2019 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
+56
-2
@@ -37,12 +37,28 @@ principle driving the current internal design of <code>multi_index_container</co
|
||||
<h2>Contents</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="#ranked_indices">Ranked indices</a></li>
|
||||
<li><a href="#notifying">Notifying indices</a></li>
|
||||
<li><a href="#constraints">Constraints</a></li>
|
||||
<li><a href="#user_defined_indices">User-defined indices</a></li>
|
||||
<li><a href="#bimap">Bidirectional map</a></li>
|
||||
<li><a href="#indexed_maps">Indexed maps</a></li>
|
||||
<li><a href="#move_semantics">Move semantics</a></li>
|
||||
</ul>
|
||||
|
||||
<h2><a name="ranked_indices">Ranked indices</a></h2>
|
||||
|
||||
<p>
|
||||
Ordered indices are implemented using red-black trees; these trees
|
||||
can be augmented with additional information to obtain a type
|
||||
of data structure called
|
||||
<a href="http://pine.cs.yale.edu/pinewiki/OrderStatisticsTree"><i>order-statistics
|
||||
trees</i></a>, allowing for logarithmic search of the <i>n</i>-th element. It
|
||||
has been proposed that order-statistics trees be used to devise a new type of
|
||||
<i>ranked indices</i> that support <code>operator[]</code> while retaining
|
||||
the functionality of ordered indices.
|
||||
</p>
|
||||
|
||||
<h2><a name="notifying">Notifying indices</a></h2>
|
||||
|
||||
<p>
|
||||
@@ -134,6 +150,19 @@ simple enough to make them worth documenting so that the (bold)
|
||||
user can write implementations for her own indices.
|
||||
</p>
|
||||
|
||||
<h2><a name="bimap">Bidirectional map</a></h2>
|
||||
|
||||
<p>
|
||||
<a href="examples.html#example4">Example 4</a> in the examples section
|
||||
features a <i>bidirectional map</i>, implemented as a
|
||||
<code>multi_index_container</code> with two unique ordered indices. This particular
|
||||
structure is deemed important enough as to provide it as a separate
|
||||
class template, relying internally in <code>multi_index_container</code>. As
|
||||
feedback is collected from the users of Boost.MultiIndex, other singular
|
||||
instantiations of <code>multi_index_container</code> might be encapsulated
|
||||
to form a component library of ready to use containers.
|
||||
</p>
|
||||
|
||||
<h2><a name="indexed_maps">Indexed maps</a></h2>
|
||||
|
||||
<p>
|
||||
@@ -172,6 +201,31 @@ a careful study when designing the interface of a potential
|
||||
indexed map.
|
||||
</p>
|
||||
|
||||
<h2><a name="move_semantics">Move semantics</a></h2>
|
||||
|
||||
<p>
|
||||
Andrei Alexandrescu introduced a technique for simulating move
|
||||
constructors called Mojo (see his article in C/C++ User Journal
|
||||
<a href="http://www.cuj.com/documents/s=8246/cujcexp2102alexandr/">
|
||||
"Generic<Programming>: Move Constructors"</a>.) Move semantics
|
||||
alleviates the computational load involved in the creation and copying
|
||||
of temporary objects, specially for heavy classes as
|
||||
<code>multi_index_container</code>s are. David Abrahams and Gary Powell provide
|
||||
an alternative implementation of move semantics in their paper
|
||||
<a href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2004/n1610.html">
|
||||
"Clarification of Initialization of Class Objects by rvalues"</a> for
|
||||
the C++ Evolution Working Group.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Adding move semantics to <code>multi_index_container</code> is particularly
|
||||
beneficial when the container is used as an internal building block in other
|
||||
libraries (vg. relational database frameworks), enabling the efficient
|
||||
development of functions returning <code>multi_index_container</code>s. Without support
|
||||
for move semantics, this scheme is impractical and less elegant syntaxes
|
||||
should be resorted to.
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="prev_link"><a href="tests.html"><img src="prev.gif" alt="tests" border="0"><br>
|
||||
@@ -186,9 +240,9 @@ Release notes
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised April 19th 2015</p>
|
||||
<p>Revised February 6th 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2015 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
+8
-9
@@ -13,8 +13,8 @@
|
||||
<h1><img src="../../../boost.png" alt="boost.png (6897 bytes)" align=
|
||||
"middle" width="277" height="86">Boost Multi-index Containers Library</h1>
|
||||
|
||||
<div class="prev_link"> </div>
|
||||
<div class="up_link"> </div>
|
||||
<div class="prev_link"></div>
|
||||
<div class="up_link"></div>
|
||||
<div class="next_link"><a href="tutorial/index.html"><img src="next.gif" alt="tutorial" border="0"><br>
|
||||
Tutorial
|
||||
</a></div><br clear="all" style="clear: all;">
|
||||
@@ -31,13 +31,12 @@ borrowed from relational database terminology and allows for the specification o
|
||||
complex data structures in the spirit of multiply indexed relational tables where
|
||||
simple sets and maps are not enough. A wide selection of indices is provided,
|
||||
modeled after analogous STL containers like <code>std::set</code>,
|
||||
<code>std::list</code> and <code>std::unordered_set</code>.
|
||||
<code>std::list</code> and hashed sets.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Boost.MultiIndex features additional functionalities, like subobject searching,
|
||||
range querying, in-place updating of elements and calculation of ranks,
|
||||
which make it a convenient replacement
|
||||
range querying and in-place updating of elements, which make it a convenient replacement
|
||||
for <code>std::set</code> and <code>set::multiset</code> even when no multi-indexing
|
||||
capabilities are needed.
|
||||
</p>
|
||||
@@ -78,17 +77,17 @@ examples of use developed in the documentation:
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="prev_link"> </div>
|
||||
<div class="up_link"> </div>
|
||||
<div class="prev_link"></div>
|
||||
<div class="up_link"></div>
|
||||
<div class="next_link"><a href="tutorial/index.html"><img src="next.gif" alt="tutorial" border="0"><br>
|
||||
Tutorial
|
||||
</a></div><br clear="all" style="clear: all;">
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised April 19th 2015</p>
|
||||
<p>Revised February 6th 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2015 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
+11
-11
@@ -111,7 +111,7 @@ Consider the following instantiation of <code>multi_index_container</code>:
|
||||
<span class=keyword>int</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>identity</span><span class=special><</span><span class=keyword>int</span><span class=special>></span> <span class=special>>,</span>
|
||||
<span class=identifier>ordered_non_unique</span><span class=special><</span><span class=identifier>identity</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=identifier>ordered_non_unique</span><span class=special><</span><span class=identifier>identity</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=special>></span>
|
||||
<span class=special>></span> <span class=identifier>indexed_t</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
@@ -208,7 +208,7 @@ equivalent to those of <code>indexed_t</code>:
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
The construction can be extended in a straightforward manner to
|
||||
The construction can be extended in a straightworward manner to
|
||||
handle more than two indices. In what follows, we will compare
|
||||
instantiations of <code>multi_index_container</code> against this sort of
|
||||
manual simulations.
|
||||
@@ -230,7 +230,7 @@ each index. Thus the node size is
|
||||
</p>
|
||||
|
||||
<blockquote>
|
||||
<i>S<sub>I</sub></i> = <i>e</i> + <i>h</i><sub>0</sub> + ··· +
|
||||
<i>S<sub>I</sub></i> = <i>e</i> + <i>h</i><sub>0</sub> + ··· +
|
||||
<i>h</i><sub><i>N</i>-1</sub>, where<br>
|
||||
<i>e</i> = size of the element,<br>
|
||||
<i>h</i><sub><i>i</i></sub> = size of the <i>i</i>-th header.
|
||||
@@ -247,7 +247,7 @@ the space allocated per element in a manual simulation is
|
||||
|
||||
<blockquote>
|
||||
<i>S<sub>M</sub></i> = (<i>e</i> + <i>h</i><sub>0</sub>) +
|
||||
(<i>p</i> + <i>h</i><sub>1</sub>) + ··· +
|
||||
(<i>p</i> + <i>h</i><sub>1</sub>) + ··· +
|
||||
(<i>p</i> + <i>h</i><sub><i>N</i>-1</sub>) =
|
||||
<i>S<sub>I</sub></i> + (<i>N</i>-1)<i>p</i>, where<br>
|
||||
<i>p</i> = size of a pointer.<br>
|
||||
@@ -527,7 +527,7 @@ ordered indices.</b>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
These results coincide with the theoretical formula for
|
||||
These results concinde with the theoretical formula for
|
||||
<i>S<sub>I</sub></i> = 28, <i>N</i> = <i>O</i> = 2 and <i>p</i> = <i>w</i> = 4.
|
||||
</p>
|
||||
|
||||
@@ -583,7 +583,7 @@ ordered index + 1 sequenced index.</b>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
These results coincide with the theoretical formula for
|
||||
These results concinde with the theoretical formula for
|
||||
<i>S<sub>I</sub></i> = 24, <i>N</i> = 2, <i>O</i> = 1 and <i>p</i> = <i>w</i> = 4.
|
||||
</p>
|
||||
|
||||
@@ -604,7 +604,7 @@ improvement of 50-65% with respect to the STL-based manual simulation.
|
||||
Curiously enough, this speedup gets even higher when
|
||||
<i>n</i>=10<sup>5</sup> for two of the compilers, namely GCC and ICC.
|
||||
In order to rule out spurious results, the tests
|
||||
have been run many times, yielding similar outcomes. Both test environments
|
||||
have been run many times, yielding similar outcoumes. Both test environments
|
||||
are deployed on the same machine, which points to some OS-related reason for
|
||||
this phenomenon.
|
||||
</p>
|
||||
@@ -646,7 +646,7 @@ ordered indices.</b>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
These results coincide with the theoretical formula for
|
||||
These results concinde with the theoretical formula for
|
||||
<i>S<sub>I</sub></i> = 40, <i>N</i> = <i>O</i> = 3 and <i>p</i> = <i>w</i> = 4.
|
||||
</p>
|
||||
|
||||
@@ -700,7 +700,7 @@ ordered indices + 1 sequenced index.</b>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
These results coincide with the theoretical formula for
|
||||
These results concinde with the theoretical formula for
|
||||
<i>S<sub>I</sub></i> = 36, <i>N</i> = 3, <i>O</i> = 2 and <i>p</i> = <i>w</i> = 4.
|
||||
</p>
|
||||
|
||||
@@ -749,9 +749,9 @@ Examples
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised April 18th 2020</p>
|
||||
<p>Revised May 9th 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2020 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
+135
-477
@@ -15,8 +15,8 @@
|
||||
<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
|
||||
"middle" width="277" height="86">Boost.MultiIndex Hashed indices reference</h1>
|
||||
|
||||
<div class="prev_link"><a href="rnk_indices.html"><img src="../prev.gif" alt="ranked indices" border="0"><br>
|
||||
Ranked indices
|
||||
<div class="prev_link"><a href="ord_indices.html"><img src="../prev.gif" alt="ordered indices" border="0"><br>
|
||||
Ordered indices
|
||||
</a></div>
|
||||
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.MultiIndex reference" border="0"><br>
|
||||
Boost.MultiIndex reference
|
||||
@@ -44,13 +44,10 @@ Sequenced indices
|
||||
<li><a href="#instantiation_types">Instantiation types</a></li>
|
||||
<li><a href="#types">Nested types</a></li>
|
||||
<li><a href="#constructors">Constructors, copy and assignment</a></li>
|
||||
<li><a href="#iterators">Iterators</a></li>
|
||||
<li><a href="#modifiers">Modifiers</a></li>
|
||||
<li><a href="#observers">Observers</a></li>
|
||||
<li><a href="#lookup">Lookup</a></li>
|
||||
<li><a href="#bucket_interface">Bucket interface</a></li>
|
||||
<li><a href="#hash_policy">Hash policy</a></li>
|
||||
<li><a href="#comparison">Comparison</a></li>
|
||||
<li><a href="#serialization">Serialization</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -100,8 +97,6 @@ their associated <a href="#hash_indices">hashed index</a> classes.
|
||||
<code>"boost/multi_index/hashed_index.hpp"</code></a> synopsis</a></h2>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=preprocessor>#include</span> <span class=special><</span><span class=identifier>initializer_list</span><span class=special>></span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>multi_index</span><span class=special>{</span>
|
||||
@@ -119,13 +114,6 @@ their associated <a href="#hash_indices">hashed index</a> classes.
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>implementation defined</b><span class=special>></span> <span class=keyword>class</span> <b>index class name implementation defined</b><span class=special>;</span>
|
||||
|
||||
<span class=comment>// index comparison:</span>
|
||||
|
||||
<span class=comment>// <b>OP</b> is any of ==,!=</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>implementation defined</b><span class=special>></span>
|
||||
<span class=keyword>bool</span> <span class=keyword>operator</span> <b><i>OP</i></b><span class=special>(</span><span class=keyword>const</span> <b>index class name</b><span class=special>&</span> <span class=identifier>x</span><span class=special>,</span><span class=keyword>const</span> <b>index class name</b><span class=special>&</span> <span class=identifier>y</span><span class=special>);</span>
|
||||
|
||||
<span class=comment>// index specialized algorithms:</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>implementation defined</b><span class=special>></span>
|
||||
@@ -180,8 +168,11 @@ explanations on their acceptable type values.
|
||||
|
||||
<p>
|
||||
A hashed index provides fast retrieval of elements of a <code>multi_index_container</code>
|
||||
through hashing techniques.
|
||||
A hashed index is particularized according to a given
|
||||
through hashing tecnhiques. The interface and semantics of hashed indices are modeled according
|
||||
to the proposal for unordered associative containers given in the C++
|
||||
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1836.pdf">Proposed
|
||||
Draft Tecnhical Report on Standard Library Extensions</a>, also known as TR1. A hashed
|
||||
index is particularized according to a given
|
||||
<a href="key_extraction.html#key_extractors"><code>Key Extractor</code></a>
|
||||
that retrieves keys from elements of <code>multi_index_container</code>, a <code>Hash</code>
|
||||
function object which returns hash values for the keys and a binary predicate <code>Pred</code>
|
||||
@@ -197,18 +188,13 @@ together, with minor differences explicitly stated when they exist.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Except where noted or if the corresponding interface does not exist, hashed indices
|
||||
(both unique and non-unique) satisfy the C++ requirements for unordered associative
|
||||
containers at <b>[unord.req]</b> (supporting unique and equivalent keys, respectively.)
|
||||
Iterators (including to the end of the index) and pointers and references to an element
|
||||
remain valid during the lifetime of the associated container (which can change
|
||||
upon swapping), or until the referred-to element is erased or extracted;
|
||||
pointers and references to an extracted element, but not so for iterators,
|
||||
become valid again once the element is re-inserted.
|
||||
Occasionally, the exception safety guarantees provided
|
||||
are actually stronger than required by the standard. We only provide descriptions of
|
||||
those types and operations that do not exactly conform to or are not mandated by the standard
|
||||
requirements.
|
||||
Except where noted, hashed indices (both unique and non-unique) are models of
|
||||
<code>Unordered Associative Container</code>, in the spirit of
|
||||
<code>std::tr1::unordered_set</code>s. 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>
|
||||
|
||||
<blockquote><pre>
|
||||
@@ -230,9 +216,8 @@ requirements.
|
||||
<span class=keyword>typedef</span> <span class=identifier>KeyFromValue</span> <span class=identifier>key_from_value</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>Hash</span> <span class=identifier>hasher</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>Pred</span> <span class=identifier>key_equal</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>tuple</span><span class=special><</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>tuple</span><span class=special><</span>
|
||||
<span class=identifier>size_type</span><span class=special>,</span><span class=identifier>key_from_value</span><span class=special>,</span><span class=identifier>hasher</span><span class=special>,</span><span class=identifier>key_equal</span><span class=special>></span> <span class=identifier>ctor_args</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>TagList</span> <span class=identifier>tag_list</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>Allocator</span> <span class=identifier>allocator_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>Allocator</span><span class=special>::</span><span class=identifier>pointer</span> <span class=identifier>pointer</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>Allocator</span><span class=special>::</span><span class=identifier>const_pointer</span> <span class=identifier>const_pointer</span><span class=special>;</span>
|
||||
@@ -244,68 +229,42 @@ requirements.
|
||||
<span class=keyword>typedef</span> <b>implementation defined </b><span class=identifier>const_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined </b><span class=identifier>local_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined </b><span class=identifier>const_local_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>same as owning container </b><span class=identifier>node_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>following [container.insert.return] spec </b><span class=identifier>insert_return_type</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// construct/destroy/copy:</span>
|
||||
|
||||
<b>index class name</b><span class=special>&</span> <span class=keyword>operator</span><span class=special>=(</span><span class=keyword>const</span> <b>index class name</b><span class=special>&</span> <span class=identifier>x</span><span class=special>);</span>
|
||||
<b>index class name</b><span class=special>&</span> <span class=keyword>operator</span><span class=special>=(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special><</span><span class=identifier>value_type</span><span class=special>></span> <span class=identifier>list</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=keyword>noexcept</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=keyword>noexcept</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=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</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=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>iterator</span> <span class=identifier>end</span><span class=special>()</span><span class=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_iterator</span> <span class=identifier>cbegin</span><span class=special>()</span><span class=keyword>const</span><span class=special>;</span>
|
||||
<span class=identifier>const_iterator</span> <span class=identifier>cend</span><span class=special>()</span><span class=keyword>const</span><span class=special>;</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>iterator</span> <span class=identifier>iterator_to</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>const_iterator</span> <span class=identifier>iterator_to</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>const</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// modifiers:</span>
|
||||
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span><span class=special>...</span> <span class=identifier>Args</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> <span class=identifier>emplace</span><span class=special>(</span><span class=identifier>Args</span><span class=special>&&...</span> <span class=identifier>args</span><span class=special>);</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span><span class=special>...</span> <span class=identifier>Args</span><span class=special>></span>
|
||||
<span class=identifier>iterator</span> <span class=identifier>emplace_hint</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Args</span><span class=special>&&...</span> <span class=identifier>args</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> <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>
|
||||
<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>value_type</span><span class=special>&&</span> <span class=identifier>x</span><span class=special>);</span>
|
||||
<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>
|
||||
<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=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>typename</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>
|
||||
<span class=keyword>void</span> <span class=identifier>insert</span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special><</span><span class=identifier>value_type</span><span class=special>></span> <span class=identifier>list</span><span class=special>);</span>
|
||||
<span class=identifier>insert_return_type</span> <span class=identifier>insert</span><span class=special>(</span><span class=identifier>node_type</span><span class=special>&&</span> <span class=identifier>nh</span><span class=special>);</span>
|
||||
<span class=identifier>iterator</span> <span class=identifier>insert</span><span class=special>(</span><span class=identifier>const_iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>node_type</span><span class=special>&&</span> <span class=identifier>nh</span><span class=special>);</span>
|
||||
|
||||
<span class=identifier>node_type</span> <span class=identifier>extract</span><span class=special>(</span><span class=identifier>const_iterator</span> <span class=identifier>position</span><span class=special>);</span>
|
||||
<span class=identifier>node_type</span> <span class=identifier>extract</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=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>
|
||||
<span class=identifier>size_type</span> <span class=identifier>erase</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=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>
|
||||
|
||||
<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>
|
||||
<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=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>typename</span> <span class=identifier>Modifier</span><span class=special>></span> <span class=keyword>bool</span> <span class=identifier>modify</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Modifier</span> <span class=identifier>mod</span><span class=special>);</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Modifier</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Rollback</span><span class=special>></span>
|
||||
<span class=keyword>bool</span> <span class=identifier>modify</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Modifier</span> <span class=identifier>mod</span><span class=special>,</span><span class=identifier>Rollback</span> <span class=identifier>back</span><span class=special>);</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Modifier</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>Modifier</span> <span class=identifier>mod</span><span class=special>);</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Modifier</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Rollback</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>Modifier</span> <span class=identifier>mod</span><span class=special>,</span><span class=identifier>Rollback</span> <span class=identifier>back</span><span class=special>);</span>
|
||||
|
||||
<span class=keyword>void</span> <span class=identifier>clear</span><span class=special>()</span><span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=keyword>void</span> <span class=identifier>clear</span><span class=special>();</span>
|
||||
<span class=keyword>void</span> <span class=identifier>swap</span><span class=special>(</span><b>index class name</b><span class=special>&</span> <span class=identifier>x</span><span class=special>);</span>
|
||||
|
||||
<span class=comment>// observers:</span>
|
||||
@@ -345,8 +304,8 @@ requirements.
|
||||
|
||||
<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=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</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>
|
||||
|
||||
@@ -354,32 +313,15 @@ requirements.
|
||||
<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=identifier>const_local_iterator</span> <span class=identifier>cbegin</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_local_iterator</span> <span class=identifier>cend</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>local_iterator_to</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>const_local_iterator</span> <span class=identifier>local_iterator_to</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>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=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</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> <span class=identifier>rehash</span><span class=special>(</span><span class=identifier>size_type</span> <span class=identifier>n</span><span class=special>);</span>
|
||||
<span class=keyword>void</span> <span class=identifier>reserve</span><span class=special>(</span><span class=identifier>size_type</span> <span class=identifier>n</span><span class=special>);</span>
|
||||
<span class=special>};</span>
|
||||
|
||||
<span class=comment>// index comparison:</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>implementation defined</b><span class=special>></span>
|
||||
<span class=keyword>bool</span> <span class=keyword>operator</span><span class=special>==(</span><span class=keyword>const</span> <b>index class name</b><span class=special>&</span> <span class=identifier>x</span><span class=special>,</span><span class=keyword>const</span> <b>index class name</b><span class=special>&</span> <span class=identifier>y</span><span class=special>)</span><span class=special>;</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>implementation defined</b><span class=special>></span>
|
||||
<span class=keyword>bool</span> <span class=keyword>operator</span><span class=special>!=(</span><span class=keyword>const</span> <b>index class name</b><span class=special>&</span> <span class=identifier>x</span><span class=special>,</span><span class=keyword>const</span> <b>index class name</b><span class=special>&</span> <span class=identifier>y</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</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=comment>// index specialized algorithms:</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>implementation defined</b><span class=special>></span>
|
||||
@@ -401,22 +343,21 @@ scheme outlined in the
|
||||
section</a>. The complexity signature of hashed indices is:
|
||||
<ul>
|
||||
<li>copying: <code>c(n)=n*log(n)</code>,</li>
|
||||
<li>insertion: average case <code>i(n)=1</code> (amortized constant),
|
||||
worst case <code>i(n)=n<sub>dist</sub></code>,</li>
|
||||
<li>hinted insertion: average case <code>h(n)=1</code> (amortized constant),
|
||||
worst case <code>h(n)=n<sub>dist</sub></code>,</li>
|
||||
<li>deletion: <code>d(n)=1</code> (constant),</li>
|
||||
<li>insertion: average case <code>i(n)=1</code> (constant),
|
||||
worst case <code>i(n)=n</code>,</li>
|
||||
<li>hinted insertion: average case <code>h(n)=1</code> (constant),
|
||||
worst case <code>h(n)=n</code>,</li>
|
||||
<li>deletion: average case <code>d(n)=1</code> (constant),
|
||||
worst case <code>d(n)=n</code>,</li>
|
||||
<li>replacement:
|
||||
<ul>
|
||||
<li>if the new element key is equivalent to the original, <code>r(n)=1</code> (constant),</li>
|
||||
<li>otherwise, average case <code>r(n)=1</code> (constant),
|
||||
worst case <code>r(n)=n<sub>dist</sub></code>,</li>
|
||||
worst case <code>r(n)=n</code>,</li>
|
||||
</ul></li>
|
||||
<li>modifying: average case <code>m(n)=1</code> (constant),
|
||||
worst case <code>m(n)=n<sub>dist</sub></code>,</li>
|
||||
worst case <code>m(n)=n</code>.</li>
|
||||
</ul>
|
||||
where <code>n<sub>dist</sub></code> is the number of non-equivalent elements out of
|
||||
the total <code>n</code>.
|
||||
</p>
|
||||
|
||||
<h4><a name="instantiation_types">Instantiation types</a></h4>
|
||||
@@ -429,7 +370,7 @@ following types:
|
||||
<ul>
|
||||
<li><code>Value</code> from <code>multi_index_container</code>,</li>
|
||||
<li><code>Allocator</code> from <code>multi_index_container</code>,</li>
|
||||
<li><code>TagList</code> from the index specifier (if provided, otherwise <code>tag<></code> is assumed),</li>
|
||||
<li><code>TagList</code> from the index specifier (if provided),</li>
|
||||
<li><code>KeyFromValue</code> from the index specifier,</li>
|
||||
<li><code>Hash</code> from the index specifier,</li>
|
||||
<li><code>Pred</code> from the index specifier.</li>
|
||||
@@ -439,11 +380,13 @@ following types:
|
||||
which determines the mechanism for extracting a key from <code>Value</code>,
|
||||
must be a model of <a href="key_extraction.html#key_extractors">
|
||||
<code>Key Extractor</code></a> from <code>Value</code>. <code>Hash</code> is a
|
||||
<code>CopyConstructible</code>unary function object
|
||||
<a href="http://www.sgi.com/tech/stl/UnaryFunction.html"><code>Unary Function</code></a>
|
||||
taking a single argument of type <code>KeyFromValue::result_type</code> and returning a
|
||||
value of type <code>std::size_t</code> in the range
|
||||
<code>[0, std::numeric_limits<std::size_t>::max())</code>.
|
||||
<code>Pred</code> is a <code>CopyConstructible</code> binary predicate inducing an equivalence relation
|
||||
<code>Pred</code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/BinaryPredicate.html">
|
||||
<code>Binary Predicate</code></a> inducing an equivalence relation
|
||||
on elements of <code>KeyFromValue::result_type</code>. It is required that
|
||||
the <code>Hash</code> object return the same value for keys
|
||||
equivalent under <code>Pred</code>.
|
||||
@@ -465,7 +408,9 @@ local_iterator<br>
|
||||
const_local_iterator</code>
|
||||
|
||||
<blockquote>
|
||||
These types are forward iterators.
|
||||
These types are models of
|
||||
<a href="http://www.sgi.com/tech/stl/ForwardIterator.html"><code>Forward
|
||||
Iterator</code></a>.
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="constructors">Constructors, copy and assignment</a></h4>
|
||||
@@ -489,90 +434,11 @@ objects to which <code>*this</code> and <code>x</code> belong, respectively.<br>
|
||||
<b>Returns:</b> <code>*this</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code><b>index class name</b>& operator=(std::initializer_list<value_type> list);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>a</span><span class=special>=</span><span class=identifier>list</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
where <code>a</code> is the <code>multi_index_container</code>
|
||||
object to which <code>*this</code> belongs.<br>
|
||||
<b>Returns:</b> <code>*this</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="iterators">Iterators</a></h4>
|
||||
|
||||
<code>iterator iterator_to(const value_type& x);<br>
|
||||
const_iterator iterator_to(const value_type& x)const;</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>x</code> is a reference to an element of the container.<br>
|
||||
<b>Returns:</b> An iterator to <code>x</code>.<br>
|
||||
<b>Complexity:</b> Constant.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="modifiers">Modifiers</a></h4>
|
||||
|
||||
<code>template<typename... Args><br>
|
||||
std::pair<iterator,bool> emplace(Args&&... args);</code>
|
||||
<code>std::pair<iterator,bool> insert(const value_type& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>value_type</code> is <code>EmplaceConstructible</code>
|
||||
into <code>multi_index_container</code> from <code>args</code>.<br>
|
||||
<b>Effects:</b> Inserts a <code>value_type</code> object constructed with
|
||||
<code>std::forward<Args>(args)...</code> into the <code>multi_index_container</code> to which
|
||||
the index belongs if
|
||||
<ul>
|
||||
<li>the index is non-unique OR no other element exists with
|
||||
equivalent key,</li>
|
||||
<li>AND insertion is allowed by all other indices of the
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
<b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
|
||||
is <code>true</code> if and only if insertion took place. On successful insertion,
|
||||
<code>p.first</code> points to the element inserted; otherwise, <code>p.first</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.<br>
|
||||
<b>Complexity:</b> <code>O(I(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong, except that rehashing may occur even if the operation fails.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename... Args><br>
|
||||
iterator emplace_hint(iterator position, Args&&... args);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>value_type</code> is <code>EmplaceConstructible</code>
|
||||
into <code>multi_index_container</code> from <code>args</code>.
|
||||
<code>position</code> is a valid iterator of the index.<br>
|
||||
<b>Effects:</b> Inserts a <code>value_type</code> object constructed with
|
||||
<code>std::forward<Args>(args)...</code> into the <code>multi_index_container</code> to which
|
||||
the index belongs if
|
||||
<ul>
|
||||
<li>the index is non-unique OR no other element exists with
|
||||
equivalent key,</li>
|
||||
<li>AND insertion is allowed by all other indices of the
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
<code>position</code> is used as a hint to improve the efficiency of the
|
||||
operation.<br>
|
||||
<b>Returns:</b> 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.<br>
|
||||
<b>Complexity:</b> <code>O(H(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong, except that rehashing may occur even if the operation fails.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>std::pair<iterator,bool> insert(const value_type& x);</code><br>
|
||||
<code>std::pair<iterator,bool> insert(value_type&& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires (first version):</b> <code>value_type</code> is <code>CopyInsertable</code>
|
||||
into <code>multi_index_container</code>.<br>
|
||||
<b>Requires (second version):</b> <code>value_type</code> is <code>MoveInsertable</code>
|
||||
into <code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> Inserts <code>x</code> into the <code>multi_index_container</code> to which
|
||||
the index belongs if
|
||||
<ul>
|
||||
@@ -587,19 +453,13 @@ is <code>true</code> if and only if insertion took place. On successful insertio
|
||||
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.<br>
|
||||
<b>Complexity:</b> <code>O(I(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong, except that rehashing may occur even if the operation fails.<br>
|
||||
<b>Exception safety:</b> Strong.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>iterator insert(iterator position,const value_type& x);</code><br>
|
||||
<code>iterator insert(iterator position,value_type&& x);</code>
|
||||
<code>iterator insert(iterator position,const value_type& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires (first version):</b> <code>value_type</code> is <code>CopyInsertable</code>
|
||||
into <code>multi_index_container</code>.
|
||||
<code>position</code> is a valid iterator of the index.<br>
|
||||
<b>Requires (second version):</b> <code>value_type</code> is <code>MoveInsertable</code>
|
||||
into <code>multi_index_container</code>.
|
||||
<code>position</code> is a valid iterator of the index.<br>
|
||||
<b>Requires:</b> <code>position</code> is a valid iterator of the index.</br>
|
||||
<b>Effects:</b> Inserts <code>x</code> into the <code>multi_index_container</code> to which
|
||||
the index belongs if
|
||||
<ul>
|
||||
@@ -615,130 +475,36 @@ 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.<br>
|
||||
<b>Complexity:</b> <code>O(H(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong, except that rehashing may occur even if the operation fails.<br>
|
||||
<b>Exception safety:</b> Strong.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename InputIterator><br>
|
||||
void insert(InputIterator first,InputIterator last);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>InputIterator</code> is an input iterator.
|
||||
<code>value_type</code> is
|
||||
<code>EmplaceConstructible</code> into
|
||||
<code>multi_index_container</code> from <code>*first</code>.
|
||||
<b>Requires:</b> <code>InputIterator</code> is a model of
|
||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">
|
||||
<code>Input Iterator</code></a> over elements of type
|
||||
<code>value_type</code> or a type convertible to <code>value_type</code>.
|
||||
<code>first</code> and <code>last</code> are not iterators into any
|
||||
index of the <code>multi_index_container</code> to which this index belongs.
|
||||
<code>last</code> is reachable from <code>first</code>.<br>
|
||||
<code>last</code> is reachable from <code>first</code>.</br>
|
||||
<b>Effects:</b>
|
||||
For each element of [<code>first</code>, <code>last</code>), in this
|
||||
order, inserts it into the <code>multi_index_container</code>
|
||||
to which this index belongs if
|
||||
<ul>
|
||||
<li>the index is non-unique OR no other element exists with
|
||||
equivalent key,</li>
|
||||
<li>AND insertion is allowed by all other indices of the
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
<b>Complexity:</b> <code>O(m*I(n+m))</code>, where
|
||||
<blockquote><pre>
|
||||
<span class=identifier>iterator</span> <span class=identifier>hint</span><span class=special>=</span><span class=identifier>end</span><span class=special>();</span>
|
||||
<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=identifier>first</span><span class=special>++);</span>
|
||||
</pre></blockquote>
|
||||
<b>Complexity:</b> <code>O(m*H(n+m))</code>, where
|
||||
<code>m</code> is the number of elements in [<code>first</code>,
|
||||
<code>last</code>).<br>
|
||||
<b>Exception safety:</b> Basic.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>void insert(std::initializer_list<value_type> list);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>insert</span><span class=special>(</span><span class=identifier>list</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>list</span><span class=special>.</span><span class=identifier>end</span><span class=special>())</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
</blockquote>
|
||||
|
||||
<code>insert_return_type insert(node_type&& nh);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>nh.empty() || get_allocator()==nh.get_allocator()</code>.<br>
|
||||
<b>Effects:</b> Does nothing if <code>nh</code> is empty; otherwise,
|
||||
inserts the node owned by <code>nh</code> into the
|
||||
<code>multi_index_container</code> to which the index belongs if
|
||||
<ul>
|
||||
<li>the index is non-unique OR no other element exists with
|
||||
equivalent key,</li>
|
||||
<li>AND insertion is allowed by all other indices of the
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
<b>Postconditions:</b> <code>nh</code> is empty.<br>
|
||||
<b>Returns:</b> A value <code>p</code> of type <code>insert_return_type</code>.
|
||||
If <code>nh</code> is empty, <code>p.position</code> is <code>end()</code>,
|
||||
<code>p.inserted</code> is <code>false</code> and <code>p.node</code> is empty;
|
||||
on successful insertion, <code>p.position</code> points to the element inserted,
|
||||
<code>p.inserted</code> is <code>true</code> and <code>p.node</code>
|
||||
is empty;
|
||||
if the insertion failed, <code>p.position</code> points to an element that caused
|
||||
the insertion to be banned, <code>p.inserted</code> is <code>false</code> and
|
||||
<code>p.node</code> owns the original node.
|
||||
Note that more than one element can be causing insertion not to be allowed.<br>
|
||||
<b>Complexity:</b> <code>O(I(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong, except that rehashing may occur even if the
|
||||
operation fails. If an exception is thrown, <code>nh</code> is not changed.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>iterator insert(const_iterator position,node_type&& nh);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>nh.empty() || get_allocator()==nh.get_allocator()</code>.
|
||||
<code>position</code> is a valid iterator of the index.<br>
|
||||
<b>Effects:</b> Does nothing if <code>nh</code> is empty; otherwise,
|
||||
inserts the node owned by <code>nh</code> into the
|
||||
<code>multi_index_container</code> to which the index belongs if
|
||||
<ul>
|
||||
<li>the index is non-unique OR no other element exists with
|
||||
equivalent key,</li>
|
||||
<li>AND insertion is allowed by all other indices of the
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
<code>position</code> is used as a hint to improve the efficiency of the
|
||||
operation.<br>
|
||||
<b>Postconditions:</b> <code>nh</code> is empty if insertion succeeds,
|
||||
and is not changed otherwise.<br>
|
||||
<b>Returns:</b> <code>end()</code> if <code>nh</code> is empty.
|
||||
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.<br>
|
||||
<b>Complexity:</b> <code>O(H(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong, except that rehashing may occur even if the
|
||||
operation fails.
|
||||
If an exception is thrown, <code>nh</code> is not changed.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>node_type extract(const_iterator position);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid dereferenceable iterator
|
||||
of the index.<br>
|
||||
<b>Effects:</b> Extracts the node of the element pointed to by <code>position</code>.<br>
|
||||
<b>Returns:</b> A node handle owning the extracted node.<br>
|
||||
<b>Complexity:</b> <code>O(D(n))</code>.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>node_type extract(const key_type& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b> Extracts the node of the first element
|
||||
with key equivalent to <code>x</code>, if there is any.<br>
|
||||
<b>Returns:</b> A node handle owning the extracted node, or empty otherwise.<br>
|
||||
<b>Complexity:</b> Average case <code>O(1 + D(n))</code>, worst case
|
||||
<code>O(n<sub>dist</sub> + D(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>iterator erase(iterator position);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid dereferenceable iterator
|
||||
of the index.<br>
|
||||
of the index.</br>
|
||||
<b>Effects:</b> Deletes the element pointed to by <code>position</code>.<br>
|
||||
<b>Returns:</b> An iterator pointing to the element immediately following
|
||||
the one that was deleted, or <code>end()</code>
|
||||
@@ -752,8 +518,8 @@ if no such element exists.<br>
|
||||
<blockquote>
|
||||
<b>Effects:</b> Deletes the elements with key equivalent to <code>x</code>.<br>
|
||||
<b>Returns:</b> Number of elements deleted.<br>
|
||||
<b>Complexity:</b> Average case <code>O(1 + m*D(n))</code>, worst case
|
||||
<code>O(n<sub>dist</sub> + m*D(n))</code>, where <code>m</code> is
|
||||
<b>Complexity:</b> Average case, <code>O(1 + m*D(n))</code>, worst case
|
||||
<code>O(n + m*D(n))</code>, where <code>m</code> is
|
||||
the number of elements deleted.<br>
|
||||
<b>Exception safety:</b> Basic.<br>
|
||||
</blockquote>
|
||||
@@ -770,14 +536,11 @@ the number of elements in [<code>first</code>,<code>last</code>).<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<a name="replace"><code>bool replace(iterator position,const value_type& x);</code></a><br>
|
||||
<code>bool replace(iterator position,value_type&& x);</code>
|
||||
<a name="replace"><code>bool replace(iterator position,const value_type& x);</code></a>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires (first version):</b> <code>value_type</code> is <code>CopyAssignable</code>.
|
||||
<code>position</code> is a valid dereferenceable iterator of the index.<br>
|
||||
<b>Requires (second version):</b> <code>value_type</code> is <code>MoveAssignable</code>.
|
||||
<code>position</code> is a valid dereferenceable iterator of the index.<br>
|
||||
<b>Requires:</b> <code>position</code> is a valid dereferenceable iterator
|
||||
of the index.</br>
|
||||
<b>Effects:</b> Assigns the value <code>x</code> to the element pointed
|
||||
to by <code>position</code> into the <code>multi_index_container</code> to which
|
||||
the index belongs if, for the value <code>x</code>
|
||||
@@ -788,8 +551,7 @@ the index belongs if, for the value <code>x</code>
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
<b>Postconditions:</b> Validity of <code>position</code> is preserved
|
||||
in all cases. If the key of the new value is equivalent to that of the replaced value,
|
||||
the position of the element does not change.<br>
|
||||
in all cases.<br>
|
||||
<b>Returns:</b> <code>true</code> if the replacement took place,
|
||||
<code>false</code> otherwise.<br>
|
||||
<b>Complexity:</b> <code>O(R(n))</code>.<br>
|
||||
@@ -802,14 +564,11 @@ belongs remains in its original state.
|
||||
<code>template<typename Modifier> bool modify(iterator position,Modifier mod);</code></a>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>mod</code> is a unary function object
|
||||
accepting arguments of type
|
||||
<b>Requires:</b> <code>Modifier</code> is a model of
|
||||
<a href="http://www.sgi.com/tech/stl/UnaryFunction.html">
|
||||
<code>Unary Function</code></a> accepting arguments of type
|
||||
<code>value_type&</code>. <code>position</code> is a valid dereferenceable
|
||||
iterator of the index.
|
||||
The execution of <code>mod(e)</code>, where <code>e</code> is the element
|
||||
pointed to by <code>position</code>, does not invoke any operation of the
|
||||
<code>multi_index_container</code> after <code>e</code> is directly modified
|
||||
or, before modification, if the operation would invalidate <code>position</code>.<br>
|
||||
iterator of the index.</br>
|
||||
<b>Effects:</b> Calls <code>mod(e)</code> where <code>e</code> is the element
|
||||
pointed to by <code>position</code> and rearranges <code>*position</code> into
|
||||
all the indices of the <code>multi_index_container</code>. Rearrangement is successful if
|
||||
@@ -821,99 +580,46 @@ all the indices of the <code>multi_index_container</code>. Rearrangement is succ
|
||||
</ul>
|
||||
If the rearrangement fails, the element is erased.<br>
|
||||
<b>Postconditions:</b> Validity of <code>position</code> is preserved if the
|
||||
operation succeeds. If the key of the modified value is equivalent to that of the
|
||||
original value, the position of the element does not change.<br>
|
||||
operation succeeds.<br>
|
||||
<b>Returns:</b> <code>true</code> if the operation succeeded, <code>false</code>
|
||||
otherwise.<br>
|
||||
<b>Complexity:</b> <code>O(M(n))</code>.<br>
|
||||
<b>Exception safety:</b> Basic. If an exception is thrown by some
|
||||
user-provided operation (including <code>mod</code>), then
|
||||
user-provided operation (except possibly <code>mod</code>), then
|
||||
the element pointed to by <code>position</code> is erased.
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename Modifier,typename Rollback><br>
|
||||
bool modify(iterator position,Modifier mod,Rollback back);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>mod</code> and <code>back</code> are unary function
|
||||
objects accepting arguments of type
|
||||
<code>value_type&</code>. <code>position</code> is a valid dereferenceable
|
||||
iterator of the index.
|
||||
The execution of <code>mod(e)</code>, where <code>e</code> is the element
|
||||
pointed to by <code>position</code>, does not invoke any operation of the
|
||||
<code>multi_index_container</code> after <code>e</code> is directly modified
|
||||
or, before modification, if the operation would invalidate <code>position</code>.
|
||||
<code>back(e)</code> does not invoke any operation of the
|
||||
<code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> Calls <code>mod(e)</code> where <code>e</code> is the element
|
||||
pointed to by <code>position</code> and tries to rearrange <code>*position</code> into
|
||||
all the indices of the <code>multi_index_container</code>. Rearrangement is successful if
|
||||
<ul>
|
||||
<li>the index is non-unique OR no other element exists
|
||||
with equivalent key,</li>
|
||||
<li>AND rearrangement is allowed by all other indices of the
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
If the rearrangement fails, <code>back(e)</code> is invoked: if the resulting value
|
||||
of <code>e</code> is consistent with its original position and constraints in all
|
||||
indices, the element is kept, otherwise it is erased.<br>
|
||||
<b>Postconditions:</b> Validity of <code>position</code> is preserved except if
|
||||
the element is erased under the conditions described below.
|
||||
If the key of the modified value is equivalent to that of the
|
||||
original value, the position of the element does not change.<br>
|
||||
<b>Returns:</b> <code>true</code> if the operation succeeded, <code>false</code>
|
||||
otherwise.<br>
|
||||
<b>Complexity:</b> <code>O(M(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong, except if <code>mod</code> or <code>back</code> throw an
|
||||
exception or <code>back(e)</code> fails to properly restore the element or there is
|
||||
a throwing user-provided operation after invoking <code>back(e)</code>, in which cases
|
||||
the modified element is erased. If <code>back</code>
|
||||
throws inside the handling code executing after some other user-provided
|
||||
operation has thrown, it is the exception generated by <code>back</code> that
|
||||
is rethrown.
|
||||
</blockquote>
|
||||
|
||||
<a name="modify_key">
|
||||
<code>template<typename Modifier> bool modify_key(iterator position,Modifier mod);</code></a>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>key_from_value</code> is a read/write
|
||||
<a href="key_extraction.html#key_extractors"><code>Key Extractor</code></a>
|
||||
from <code>value_type</code>. <code>mod</code> is a
|
||||
unary function object accepting arguments of type
|
||||
from <code>value_type</code>. <code>Modifier</code> is a model of
|
||||
<a href="http://www.sgi.com/tech/stl/UnaryFunction.html">
|
||||
<code>Unary Function</code></a> accepting arguments of type
|
||||
<code>key_type&</code>. <code>position</code> is a valid dereferenceable
|
||||
iterator of the index.
|
||||
The execution of <code>mod(k)</code>, where <code>k</code> is the key of the element
|
||||
pointed to by <code>position</code>, does not invoke any operation of the
|
||||
<code>multi_index_container</code> after <code>k</code> is directly modified
|
||||
or, before modification, if the operation would invalidate <code>position</code>.<br>
|
||||
<b>Effects:</b> Equivalent to <code>modify(position,mod')</code>,
|
||||
with <code>mod'</code> defined in such a way that
|
||||
<code>mod'(x)</code> is the same as <code>mod(key(x))</code>, where
|
||||
<code>key</code> is the internal <code>KeyFromValue</code> object of the index.
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename Modifier,typename Rollback><br>
|
||||
bool modify_key(iterator position,Modifier mod,Rollback back);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>key_from_value</code> is a read/write
|
||||
<a href="key_extraction.html#key_extractors"><code>Key Extractor</code></a>
|
||||
from <code>value_type</code>. <code>mod</code> and <code>back</code>
|
||||
are unary function objects accepting arguments of type
|
||||
<code>key_type&</code>. <code>position</code> is a valid dereferenceable
|
||||
iterator of the index.
|
||||
The execution of <code>mod(k)</code>, where <code>k</code> is the key of the element
|
||||
pointed to by <code>position</code>, does not invoke any operation of the
|
||||
<code>multi_index_container</code> after <code>k</code> is directly modified
|
||||
or, before modification, if the operation would invalidate <code>position</code>.
|
||||
<code>back(k)</code> does not invoke any operation of the
|
||||
<code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> Equivalent to <code>modify(position,mod',back')</code>,
|
||||
with <code>mod'</code> and <code>back</code> defined in such a way that
|
||||
<code>mod'(x)</code> is the same as <code>mod(key(x))</code> and
|
||||
<code>back'(x)</code> is the same as <code>back(key(x))</code>, where
|
||||
<code>key</code> is the internal <code>KeyFromValue</code> object of the index.
|
||||
iterator of the index.</br>
|
||||
<b>Effects:</b> Calls <code>mod(k)</code> where <code>k</code> is the key
|
||||
obtained by the internal <code>KeyFromValue</code> object of the index from
|
||||
the element pointed to by <code>position</code>, and rearranges
|
||||
<code>*position</code> into all the indices of the <code>multi_index_container</code>.
|
||||
Rearrangement is successful if
|
||||
<ul>
|
||||
<li>the index is non-unique OR no other element exists
|
||||
with equivalent key,</li>
|
||||
<li>AND rearrangement is allowed by all other indices of the
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
If the rearrangement fails, the element is erased.<br>
|
||||
<b>Postconditions:</b>Validity of <code>position</code> is preserved if
|
||||
the operation succeeds.<br>
|
||||
<b>Returns:</b> <code>true</code> if the operation succeeded, <code>false</code>
|
||||
otherwise.<br>
|
||||
<b>Complexity:</b> <code>O(M(n))</code>.<br>
|
||||
<b>Exception safety:</b> Basic. If an exception is thrown by some
|
||||
user-provided operation (except possibly <code>mod</code>), then
|
||||
the element pointed to by <code>position</code> is erased.
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="observers">Observers</a></h4>
|
||||
@@ -935,7 +641,7 @@ the index.<br>
|
||||
|
||||
<p>
|
||||
Hashed indices provide the full lookup functionality required by
|
||||
<b>[unord.req]</b>, namely <code>find</code>,
|
||||
unordered associative containers, namely <code>find</code>,
|
||||
<code>count</code>, and <code>equal_range</code>. Additionally,
|
||||
these member functions are templatized to allow for non-standard
|
||||
arguments, so extending the types of search operations allowed.
|
||||
@@ -946,8 +652,9 @@ functions is defined by the following concept.
|
||||
<p>
|
||||
Consider a pair (<code>Hash</code>, <code>Pred</code>) where
|
||||
<code>Hash</code> is a hash functor over values of type <code>Key</code>
|
||||
and <code>Pred</code> is a binary predicate
|
||||
inducing an equivalence relation
|
||||
and <code>Pred</code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/BinaryPredicate.html">
|
||||
<code>Binary Predicate</code></a> inducing an equivalence relation
|
||||
on <code>Key</code>, with the additional constraint that equivalent
|
||||
keys have the same hash value.
|
||||
A triplet of types (<code>CompatibleKey</code>, <code>CompatibleHash</code>,
|
||||
@@ -956,9 +663,13 @@ of (<code>Hash</code>, <code>Pred</code>) if
|
||||
<ol>
|
||||
<li><code>CompatibleHash</code> is a hash functor on values of
|
||||
type <code>CompatibleKey</code>,</li>
|
||||
<li><code>CompatiblePred</code> is a binary predicate over (<code>Key</code>,
|
||||
<li><code>CompatiblePred</code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/BinaryPredicate.html">
|
||||
<code>Binary Predicate</code></a> over (<code>Key</code>,
|
||||
<code>CompatibleKey</code>),</li>
|
||||
<li><code>CompatiblePred</code> is a binary predicate over (<code>CompatibleKey</code>,
|
||||
<li><code>CompatiblePred</code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/BinaryPredicate.html">
|
||||
<code>Binary Predicate</code></a> over (<code>CompatibleKey</code>,
|
||||
<code>Key</code>),</li>
|
||||
<li>if <code>c_eq(ck,k1)</code> then <code>c_eq(k1,ck)</code>,</li>
|
||||
<li>if <code>c_eq(ck,k1)</code> and <code>eq(k1,k2)</code> then
|
||||
@@ -981,7 +692,7 @@ for every <code>c_hash</code> of type <code>CompatibleHash</code>,
|
||||
is a compatible extension of (<code>Hash</code>, <code>Pred</code>).
|
||||
This implies that <code>Hash</code> and <code>Pred</code> accept arguments
|
||||
of type <code>CompatibleKey</code>, which usually means they have
|
||||
several overloads of their corresponding <code>operator()</code>
|
||||
several overloads of therir corresponding <code>operator()</code>
|
||||
member functions.
|
||||
</p>
|
||||
|
||||
@@ -995,11 +706,11 @@ In the context of a compatible extension or a compatible key, the expression
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
|
||||
(<code>hasher</code>, <code>key_equal</code>).<br>
|
||||
(<code>hasher</code>, <code>key_equal</code>).</br>
|
||||
<b>Effects:</b> Returns a pointer to an element whose key is equivalent to
|
||||
<code>x</code>, or <code>end()</code> if such an element does not exist.<br>
|
||||
<b>Complexity:</b> Average case <code>O(1)</code> (constant), worst case
|
||||
<code>O(n<sub>dist</sub>)</code>.<br>
|
||||
<code>O(n)</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<<br>
|
||||
@@ -1013,11 +724,11 @@ iterator find(<br>
|
||||
<blockquote>
|
||||
<b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleHash</code>,
|
||||
<code>CompatiblePred</code>) is a compatible extension of
|
||||
(<code>hasher</code>, <code>key_equal</code>).<br>
|
||||
(<code>hasher</code>, <code>key_equal</code>).</br>
|
||||
<b>Effects:</b> Returns a pointer to an element whose key is equivalent to
|
||||
<code>x</code>, or <code>end()</code> if such an element does not exist.<br>
|
||||
<b>Complexity:</b> Average case <code>O(1)</code> (constant), worst case
|
||||
<code>O(n<sub>dist</sub>)</code>.<br>
|
||||
<code>O(n)</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename CompatibleKey><br>
|
||||
@@ -1026,10 +737,10 @@ size_type count(const CompatibleKey& x)const;
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
|
||||
(<code>hasher</code>, <code>key_equal</code>).<br>
|
||||
(<code>hasher</code>, <code>key_equal</code>).</br>
|
||||
<b>Effects:</b> Returns the number of elements with key equivalent to <code>x</code>.<br>
|
||||
<b>Complexity:</b> Average case <code>O(count(x))</code>, worst case
|
||||
<code>O(count(x)+n<sub>dist</sub>)</code>.<br>
|
||||
<code>O(n)</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<<br>
|
||||
@@ -1043,10 +754,10 @@ size_type count(<br>
|
||||
<blockquote>
|
||||
<b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleHash</code>,
|
||||
<code>CompatiblePred</code>) is a compatible extension of
|
||||
(<code>hasher</code>, <code>key_equal</code>).<br>
|
||||
(<code>hasher</code>, <code>key_equal</code>).</br>
|
||||
<b>Effects:</b> Returns the number of elements with key equivalent to <code>x</code>.<br>
|
||||
<b>Complexity:</b> Average case <code>O(count(x,hash,eq))</code>, worst case
|
||||
<code>O(count(x,hash,eq)+n<sub>dist</sub>)</code>.<br>
|
||||
<code>O(n)</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename CompatibleKey><br>
|
||||
@@ -1055,18 +766,17 @@ std::pair<iterator,iterator> equal_range(const CompatibleKey& x)const;
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
|
||||
(<code>hasher</code>, <code>key_equal</code>).<br>
|
||||
(<code>hasher</code>, <code>key_equal</code>).</br>
|
||||
<b>Effects:</b> Returns a range containing all elements with keys equivalent
|
||||
to <code>x</code> (and only those), or (<code>end()</code>,<code>end()</code>)
|
||||
if no such elements exist.<br>
|
||||
<b>Complexity:</b> Average case <code>O(1)</code> (constant), worst case
|
||||
<code>O(n<sub>dist</sub>)</code>.<br>
|
||||
to <code>x</code> (and only those).<br>
|
||||
<b>Complexity:</b> Average case <code>O(count(x))</code>, worst case
|
||||
<code>O(n)</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<<br>
|
||||
typename CompatibleKey,typename CompatibleHash, typename CompatiblePred<br>
|
||||
><br>
|
||||
std::pair<iterator,iterator> equal_range(<br>
|
||||
std::pair<iterator,iterator> equal_range(</br>
|
||||
const CompatibleKey& x,<br>
|
||||
const CompatibleHash& hash,const CompatiblePred& eq)const;
|
||||
</code>
|
||||
@@ -1074,24 +784,11 @@ std::pair<iterator,iterator> equal_range(<br>
|
||||
<blockquote>
|
||||
<b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleHash</code>,
|
||||
<code>CompatiblePred</code>) is a compatible extension of
|
||||
(<code>hasher</code>, <code>key_equal</code>).<br>
|
||||
(<code>hasher</code>, <code>key_equal</code>).</br>
|
||||
<b>Effects:</b> Returns a range containing all elements with keys equivalent
|
||||
to <code>x</code> (and only those), or (<code>end()</code>,<code>end()</code>)
|
||||
if no such elements exist.<br>
|
||||
<b>Complexity:</b> Average case <code>O(1)</code> (constant), worst case
|
||||
<code>O(n<sub>dist</sub>)</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="bucket_interface">Bucket interface</a></h4>
|
||||
|
||||
<code>local_iterator local_iterator_to(const value_type& x);<br>
|
||||
const_local_iterator local_iterator_to(const value_type& x)const;</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>x</code> is a reference to an element of the container.<br>
|
||||
<b>Returns:</b> An iterator to <code>x</code>.<br>
|
||||
<b>Complexity:</b> Constant.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.<br>
|
||||
to <code>x</code> (and only those).<br>
|
||||
<b>Complexity:</b> Average case <code>O(count(x,hash,eq))</code>, worst case
|
||||
<code>O(n)</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
|
||||
@@ -1105,50 +802,11 @@ so that <code>size()/bucket_count()</code> does not exceed the maximum
|
||||
load factor, and <code>bucket_count()>=n</code>.<br>
|
||||
<b>Postconditions:</b> Validity of iterators and references to the
|
||||
elements contained is preserved.<br>
|
||||
<b>Complexity:</b> <code>O(m)</code>, where <code>m</code> is the number of
|
||||
non-equivalent elements in the index.<br>
|
||||
<b>Complexity:</b> Average case <code>O(size())</code>, worst case
|
||||
<code>O(size(n)<sup>2</sup>)</code>.<br>
|
||||
<b>Exception safety:</b> Strong.
|
||||
</blockquote>
|
||||
|
||||
<code>void reserve(size_type n);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>rehash</span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>ceil</span><span class=special>(</span><span class=identifier>n</span><span class=special>/</span><span class=identifier>max_load_factor</span><span class=special>()));</span>
|
||||
</pre></blockquote>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="comparison">Comparison</a></h4>
|
||||
|
||||
<code>template<<i>implementation defined</i>><br>
|
||||
bool operator==(const <i>index class name</i>& x,const <i>index class name</i>& y);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>x.key_extractor()</code>, <code>x.hash_function()</code> and
|
||||
<code>x.key_eq()</code> have the same behavior as the corresponding objects in <code>y</code>.
|
||||
For any two elements <code>e1</code>, <code>e2</code> in <code>x</code> or <code>y</code>,
|
||||
if <code>e1==e2</code> then their keys are equivalent.<br>
|
||||
<b>Returns:</b> <code>true</code> iff <code>x</code> and <code>y</code> have the same size
|
||||
and for each key <code>k</code> present in <code>x</code> the range
|
||||
<code>x.equal_range(k)</code> is equal (considering the <code>==</code> operator of <code>value_type</code>)
|
||||
to <code>y.equal_range(k)</code> under permutations of the elements.<br>
|
||||
<b>Complexity:</b> Let <code>k<sub>1</sub></code>,...,<code>k<sub>m</sub></code> be the different
|
||||
keys present in <code>x</code>:<br>
|
||||
<ul>
|
||||
<li>If, for each <code>k<sub>i</sub></code>, <code>x.equal_range(k<sub>i</sub>)</code> is arranged
|
||||
in the same order as <code>y.equal_range(k<sub>i</sub>)</code>, average case is
|
||||
<code>O(x.size())</code>, worst case <code>O(x.size()<sup>2</sup>)</code>.
|
||||
</li>
|
||||
<li>Otherwise, average case is
|
||||
<code>O(<font style="font-size:1.5em">Σ</font>(x.count(k<sub>i</sub>)<sup>2</sup>))</code>,
|
||||
worst case <code>O(x.size()<sup>2</sup>)</code>.
|
||||
</li>
|
||||
</ul>
|
||||
(For unique indices, the formulas above reduce to average case
|
||||
<code>O(x.size())</code>, worst case <code>O(x.size()<sup>2</sup>)</code>.)
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="serialization">Serialization</a></h4>
|
||||
|
||||
<p>
|
||||
@@ -1174,7 +832,7 @@ input archive (XML archive) <code>ar</code>.
|
||||
<b>Requires:</b> Additionally to the general requirements, <code>key_eq()</code>
|
||||
must be serialization-compatible with <code>m.get<i>().key_eq()</code>,
|
||||
where <code>i</code> is the position of the hashed index in the container.<br>
|
||||
<b>Postconditions:</b> On successful loading, the range
|
||||
<b>Postconditions:</b> On succesful loading, the range
|
||||
[<code>begin()</code>, <code>end()</code>) contains restored copies of every
|
||||
element in [<code>m.get<i>().begin()</code>, <code>m.get<i>().end()</code>),
|
||||
though not necessarily in the same order.
|
||||
@@ -1192,11 +850,11 @@ Operation: loading of an <code>iterator</code> or <code>const_iterator</code>
|
||||
<code>it'</code> from an input archive (XML archive) <code>ar</code>.
|
||||
|
||||
<blockquote>
|
||||
<b>Postconditions:</b> On successful loading, if <code>it</code> was dereferenceable
|
||||
<b>Postconditions:</b> On succesful loading, if <code>it</code> was dereferenceable
|
||||
then <code>*it'</code> is the restored copy of <code>*it</code>, otherwise
|
||||
<code>it'==end()</code>.<br>
|
||||
<b>Note:</b> It is allowed that <code>it</code> be a <code>const_iterator</code>
|
||||
and the restored <code>it'</code> an <code>iterator</code>, or vice versa.
|
||||
and the restored <code>it'</code> an <code>iterator</code>, or viceversa.
|
||||
</blockquote>
|
||||
|
||||
Operation: saving of a <code>local_iterator</code> or
|
||||
@@ -1213,20 +871,20 @@ Operation: loading of a <code>local_iterator</code> or
|
||||
<code>it'</code> from an input archive (XML archive) <code>ar</code>.
|
||||
|
||||
<blockquote>
|
||||
<b>Postconditions:</b> On successful loading, if <code>it</code> was dereferenceable
|
||||
<b>Postconditions:</b> On succesful loading, if <code>it</code> was dereferenceable
|
||||
then <code>*it'</code> is the restored copy of <code>*it</code>; if <code>it</code>
|
||||
was <code>m.get<i>().end(n)</code> for some <code>n</code>, then
|
||||
<code>it'==m'.get<i>().end(n)</code> (where <code>m</code> is the original
|
||||
<code>multi_index_container</code>, <code>m'</code> its restored copy
|
||||
and <code>i</code> is the ordinal of the index.)<br>
|
||||
<b>Note:</b> It is allowed that <code>it</code> be a <code>const_local_iterator</code>
|
||||
and the restored <code>it'</code> a <code>local_iterator</code>, or vice versa.
|
||||
and the restored <code>it'</code> a <code>local_iterator</code>, or viceversa.
|
||||
</blockquote>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="prev_link"><a href="rnk_indices.html"><img src="../prev.gif" alt="ranked indices" border="0"><br>
|
||||
Ranked indices
|
||||
<div class="prev_link"><a href="ord_indices.html"><img src="../prev.gif" alt="ordered indices" border="0"><br>
|
||||
Ordered indices
|
||||
</a></div>
|
||||
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.MultiIndex reference" border="0"><br>
|
||||
Boost.MultiIndex reference
|
||||
@@ -1237,9 +895,9 @@ Sequenced indices
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised May 9th 2020</p>
|
||||
<p>Revised July 13th 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2020 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"middle" width="277" height="86">Boost.MultiIndex Reference</h1>
|
||||
|
||||
<div class="prev_link"><a href="../tutorial/techniques.html"><img src="../prev.gif" alt="techniques" border="0"><br>
|
||||
Techniques
|
||||
Tecnhiques
|
||||
</a></div>
|
||||
<div class="up_link"><a href="../index.html"><img src="../up.gif" alt="index" border="0"><br>
|
||||
Index
|
||||
@@ -34,7 +34,6 @@ Index
|
||||
<li><a href="multi_index_container.html">Class template <code>multi_index_container</code></a></li>
|
||||
<li><a href="indices.html">Index reference</a></li>
|
||||
<li><a href="ord_indices.html">Ordered indices</a></li>
|
||||
<li><a href="rnk_indices.html">Ranked indices</a></li>
|
||||
<li><a href="hash_indices.html">Hashed indices</a></li>
|
||||
<li><a href="seq_indices.html">Sequenced indices</a></li>
|
||||
<li><a href="rnd_indices.html">Random access indices</a></li>
|
||||
@@ -60,13 +59,6 @@ The following dependencies among headers of Boost.MultiIndex hold:
|
||||
<code>"boost/multi_index/tag.hpp"</code></a>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="rnk_indices.html#synopsis">
|
||||
<code>"boost/multi_index/ranked_index.hpp"</code></a> includes
|
||||
<ul>
|
||||
<li><a href="indices.html#tag_synopsis">
|
||||
<code>"boost/multi_index/tag.hpp"</code></a>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="hash_indices.html#synopsis">
|
||||
<code>"boost/multi_index/hashed_index.hpp"</code></a> includes
|
||||
<ul>
|
||||
@@ -96,9 +88,7 @@ The following dependencies among headers of Boost.MultiIndex hold:
|
||||
<li><a href="key_extraction.html#member_synopsis">
|
||||
<code>"boost/multi_index/member.hpp"</code></a>,</li>
|
||||
<li><a href="key_extraction.html#mem_fun_synopsis">
|
||||
<code>"boost/multi_index/mem_fun.hpp"</code></a>,</li>
|
||||
<li><a href="key_extraction.html#global_fun_synopsis">
|
||||
<code>"boost/multi_index/global_fun.hpp"</code></a> and</li>
|
||||
<code>"boost/multi_index/mem_fun.hpp"</code></a> and</li>
|
||||
<li><a href="key_extraction.html#composite_key_synopsis">
|
||||
<code>"boost/multi_index/composite_key.hpp"</code></a>.</li>
|
||||
</ul>
|
||||
@@ -124,7 +114,7 @@ object modules.
|
||||
<hr>
|
||||
|
||||
<div class="prev_link"><a href="../tutorial/techniques.html"><img src="../prev.gif" alt="techniques" border="0"><br>
|
||||
Techniques
|
||||
Tecnhiques
|
||||
</a></div>
|
||||
<div class="up_link"><a href="../index.html"><img src="../up.gif" alt="index" border="0"><br>
|
||||
Index
|
||||
@@ -135,9 +125,9 @@ Index
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised November 24th 2015</p>
|
||||
<p>Revised February 6th 2005</p>
|
||||
|
||||
<p>© Copyright 2003-2015 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
+24
-37
@@ -105,13 +105,12 @@ The last two primitives deserve some further explanation: in order to
|
||||
guarantee the invariants associated to each index (e.g. some definite
|
||||
ordering,) elements of a <code>multi_index_container</code> are not mutable.
|
||||
To overcome this restriction, indices expose member functions
|
||||
for replacement and modification which allow for the mutation of elements
|
||||
for updating and modifying, which allow for the mutation of elements
|
||||
in a controlled fashion. Immutability of elements does not significantly
|
||||
impact the interfaces of ordered and hashed indices, as they are based upon
|
||||
those of associative and unordered associative containers, respectively,
|
||||
and these containers
|
||||
impact the interface of ordered indices, as it is based upon that of
|
||||
<code>std::set</code> and <code>std:multiset</code>, and these containers
|
||||
also have non-mutable elements; but it may come as a surprise when dealing
|
||||
with sequenced and random access indices, which are designed upon the functionality provided
|
||||
with sequenced indices, which are designed upon the functionality provided
|
||||
by <code>std::list</code>.
|
||||
</p>
|
||||
|
||||
@@ -121,9 +120,11 @@ they are wrapped as appropriate by each index (for instance, ordered indices
|
||||
provide a set-like suite of insertion member functions, whereas sequenced
|
||||
and random access indices have <code>push_back</code> and <code>push_front</code>
|
||||
operations.) Boost.MultiIndex poses no particular conditions on
|
||||
the interface of indices, although each index provided satisfy the C++ requirements for
|
||||
standard containers to the maximum extent possible within the conceptual framework
|
||||
of the library.
|
||||
the interface of indices, save that they must model
|
||||
<a href="http://www.sgi.com/tech/stl/Container.html">
|
||||
<code>Container</code></a> (without the requirement of being
|
||||
<a href="http://www.sgi.com/tech/stl/Assignable.html">
|
||||
<code>Assignable</code></a>.)
|
||||
</p>
|
||||
|
||||
<h2><a name="complexity_signature">Complexity signature</a></h2>
|
||||
@@ -156,16 +157,16 @@ with <code>N</code> indices labelled <code>0</code>,...,<code>N-1</code>
|
||||
whose complexity signatures are
|
||||
(<code>c<sub>i</sub></code>,<code>i<sub>i</sub></code>,<code>h<sub>i</sub></code>,<code>d<sub>i</sub></code>,<code>r<sub>i</sub></code>,<code>m<sub>i</sub></code>);
|
||||
the insertion of an element in such a container is then of complexity
|
||||
<code>O(i<sub>0</sub>(n)+···+i<sub>N-1</sub>(n))</code> where <code>n</code>
|
||||
<code>O(i<sub>0</sub>(n)+···+i<sub>N-1</sub>(n))</code> where <code>n</code>
|
||||
is the number of elements. To abbreviate notation, we adopt the
|
||||
following definitions:
|
||||
<ul>
|
||||
<li><code>C(n)=c<sub>0</sub>(n)+···+c<sub>N-1</sub>(n)</code>,</li>
|
||||
<li><code>I(n)=i<sub>0</sub>(n)+···+i<sub>N-1</sub>(n)</code>,</li>
|
||||
<li><code>H(n)=h<sub>0</sub>(n)+···+h<sub>N-1</sub>(n)</code>,</li>
|
||||
<li><code>D(n)=d<sub>0</sub>(n)+···+d<sub>N-1</sub>(n)</code>,</li>
|
||||
<li><code>R(n)=r<sub>0</sub>(n)+···+r<sub>N-1</sub>(n)</code>,</li>
|
||||
<li><code>M(n)=m<sub>0</sub>(n)+···+m<sub>N-1</sub>(n)</code>.</li>
|
||||
<li><code>C(n)=c<sub>0</sub>(n)+···+c<sub>N-1</sub>(n)</code>,</li>
|
||||
<li><code>I(n)=i<sub>0</sub>(n)+···+i<sub>N-1</sub>(n)</code>,</li>
|
||||
<li><code>H(n)=h<sub>0</sub>(n)+···+h<sub>N-1</sub>(n)</code>,</li>
|
||||
<li><code>D(n)=d<sub>0</sub>(n)+···+d<sub>N-1</sub>(n)</code>,</li>
|
||||
<li><code>R(n)=r<sub>0</sub>(n)+···+r<sub>N-1</sub>(n)</code>,</li>
|
||||
<li><code>M(n)=m<sub>0</sub>(n)+···+m<sub>N-1</sub>(n)</code>.</li>
|
||||
</ul>
|
||||
For instance, consider a <code>multi_index_container</code> with two ordered indices,
|
||||
for which <code>i(n)=log(n)</code>, and a sequenced index with <code>i(n)=1</code>
|
||||
@@ -189,14 +190,11 @@ index specifiers
|
||||
<li><a href="ord_indices.html#unique_non_unique"><code>ordered_unique</code> and
|
||||
<code>ordered_non_unique</code></a> for
|
||||
<a href="ord_indices.html">ordered indices</a>,</li>
|
||||
<li><a href="rnk_indices.html#unique_non_unique"><code>ranked_unique</code> and
|
||||
<code>ranked_non_unique</code></a> for
|
||||
<a href="rnk_indices.html">ranked indices</a>,</li>
|
||||
<li><a href="hash_indices.html#unique_non_unique"><code>hashed_unique</code> and
|
||||
<code>hashed_non_unique</code></a> for
|
||||
<a href="hash_indices.html">hashed indices</a>,</li>
|
||||
<li><a href="seq_indices.html#sequenced"><code>sequenced</code></a> for
|
||||
<a href="seq_indices.html">sequenced indices</a>,</li>
|
||||
<a href="seq_indices.html">sequenced indices</a></li>
|
||||
<li>and <a href="rnd_indices.html#random_access"><code>random_access</code></a> for
|
||||
<a href="rnd_indices.html">random access indices</a>.</li>
|
||||
</ul>
|
||||
@@ -281,10 +279,7 @@ sequence of tags to be assigned to an index in instantiation time.
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>T0</span><span class=special>,...,</span><span class=keyword>typename</span> <span class=identifier>Tn</span><span class=special>></span>
|
||||
<span class=keyword>struct</span> <span class=identifier>tag</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>type</span><span class=special>;</span>
|
||||
<span class=special>};</span>
|
||||
<span class=keyword>struct</span> <span class=identifier>tag</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
@@ -292,13 +287,6 @@ Elements of <code>tag</code> can be any type, though the user is expected
|
||||
to provide classes with mnemonic names. Duplicate elements are not allowed.
|
||||
The maximum number of elements of a <code>tag</code> instantiation is
|
||||
implementation defined.
|
||||
The nested
|
||||
<code>type</code> is a model of
|
||||
<a href="../../../../libs/mpl/doc/refmanual/random-access-sequence.html">
|
||||
<code>MPL Random Access Sequence</code></a> and
|
||||
<a href="../../../../libs/mpl/doc/refmanual/extensible-sequence.html">
|
||||
<code>MPL Extensible Sequence</code></a> containing the types <code>T0</code>, ... ,
|
||||
<code>Tn</code> in the same order as specified.
|
||||
</p>
|
||||
|
||||
<h2><a name="index_catalog">Indices provided by Boost.MultiIndex</a></h2>
|
||||
@@ -313,10 +301,6 @@ reference</a>.
|
||||
<ul>
|
||||
<li><a href="ord_indices.html">Ordered indices</a> sort the elements
|
||||
on the key and provide fast lookup capabilites.</li>
|
||||
<li><a href="rnk_indices.html">Ranked indices</a> are a variation of
|
||||
ordered indices providing extra operations based on
|
||||
<i>rank</i>, the numerical position of an element
|
||||
in the sequence.</li>
|
||||
<li><a href="hash_indices.html">Hashed indices</a> offer high
|
||||
efficiency access through hashing techniques.</li>
|
||||
</ul>
|
||||
@@ -339,7 +323,10 @@ reference</a>.
|
||||
The following concept is used by the rearrange facilities of non key-based
|
||||
indices. Given an index <code>i</code> of type <code>Index</code>, a <i>view
|
||||
of <code>i</code></i> is any range [<code>first</code>,<code>last</code>)
|
||||
where <code>first</code> and <code>last</code> are input iterators such that
|
||||
where <code>first</code> and <code>last</code> are objects of a type
|
||||
<code>Iterator</code> modelling
|
||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">
|
||||
<code>Input Iterator</code></a> such that
|
||||
<ol>
|
||||
<li>the associated value type of <code>Iterator</code> is convertible
|
||||
to <code>const Index::value_type&</code>
|
||||
@@ -386,9 +373,9 @@ Ordered indices
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised January 9th 2020</p>
|
||||
<p>Revised February 6th 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2020 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
+520
-662
File diff suppressed because it is too large
Load Diff
@@ -88,8 +88,6 @@ synopsis</a>
|
||||
</h2>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=preprocessor>#include</span> <span class=special><</span><span class=identifier>initializer_list</span><span class=special>></span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>multi_index</span><span class=special>{</span>
|
||||
@@ -101,15 +99,10 @@ synopsis</a>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</span><span class=special>,</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span> <span class=keyword>struct</span> <span class=identifier>nth_index</span><span class=special>;</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</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>index</span><span class=special>;</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</span><span class=special>,</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span>
|
||||
<span class=keyword>struct</span> <span class=identifier>nth_index_iterator</span><span class=special>;</span> <span class=comment><b>// deprecated</b></span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</span><span class=special>,</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span>
|
||||
<span class=keyword>struct</span> <span class=identifier>nth_index_const_iterator</span><span class=special>;</span> <span class=comment><b>// deprecated</b></span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</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>index_iterator</span><span class=special>;</span> <span class=comment><b>// deprecated</b></span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</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>index_const_iterator</span><span class=special>;</span> <span class=comment><b>// deprecated</b></span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</span><span class=special>,</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span> <span class=keyword>struct</span> <span class=identifier>nth_index_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</span><span class=special>,</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span> <span class=keyword>struct</span> <span class=identifier>nth_index_const_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</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>index_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</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>index_const_iterator</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// multi_index_container global functions for index retrieval:</span>
|
||||
|
||||
@@ -119,7 +112,7 @@ synopsis</a>
|
||||
<span class=keyword>typename</span> <span class=identifier>nth_index</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>,</span><span class=identifier>N</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span><span class=special>&</span>
|
||||
<span class=identifier>get</span><span class=special>(</span><span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>)</span><span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>get</span><span class=special>(</span><span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>);</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span>
|
||||
<span class=keyword>int</span> <span class=identifier>N</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Allocator</span>
|
||||
@@ -127,7 +120,7 @@ synopsis</a>
|
||||
<span class=keyword>const</span> <span class=keyword>typename</span> <span class=identifier>nth_index</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>,</span><span class=identifier>N</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span><span class=special>&</span>
|
||||
<span class=identifier>get</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>)</span><span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>get</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>);</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>Tag</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Allocator</span>
|
||||
@@ -135,7 +128,7 @@ synopsis</a>
|
||||
<span class=keyword>typename</span> <span class=identifier>index</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</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>get</span><span class=special>(</span><span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>)</span><span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>get</span><span class=special>(</span><span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>);</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>Tag</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Allocator</span>
|
||||
@@ -143,7 +136,7 @@ synopsis</a>
|
||||
<span class=keyword>const</span> <span class=keyword>typename</span> <span class=identifier>index</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</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>get</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>)</span><span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>get</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>);</span>
|
||||
|
||||
<span class=comment>// multi_index_container global functions for projection of iterators:</span>
|
||||
|
||||
@@ -151,9 +144,9 @@ synopsis</a>
|
||||
<span class=keyword>int</span> <span class=identifier>N</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IteratorType</span><span class=special>,</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Allocator</span>
|
||||
<span class=special>></span>
|
||||
<span class=keyword>typename</span> <span class=identifier>nth_index</span><span class=special><</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>nth_index_iterator</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>,</span><span class=identifier>N</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span><span class=special>::</span><span class=identifier>iterator</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span>
|
||||
<span class=identifier>project</span><span class=special>(</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>,</span>
|
||||
<span class=identifier>IteratorType</span> <span class=identifier>it</span><span class=special>);</span>
|
||||
@@ -162,9 +155,9 @@ synopsis</a>
|
||||
<span class=keyword>int</span> <span class=identifier>N</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IteratorType</span><span class=special>,</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Allocator</span>
|
||||
<span class=special>></span>
|
||||
<span class=keyword>typename</span> <span class=identifier>nth_index</span><span class=special><</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>nth_index_const_iterator</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>,</span><span class=identifier>N</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span><span class=special>::</span><span class=identifier>const_iterator</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span>
|
||||
<span class=identifier>project</span><span class=special>(</span>
|
||||
<span class=keyword>const</span> <span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>,</span>
|
||||
<span class=identifier>IteratorType</span> <span class=identifier>it</span><span class=special>);</span>
|
||||
@@ -173,9 +166,9 @@ synopsis</a>
|
||||
<span class=keyword>typename</span> <span class=identifier>Tag</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IteratorType</span><span class=special>,</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Allocator</span>
|
||||
<span class=special>></span>
|
||||
<span class=keyword>typename</span> <span class=identifier>index</span><span class=special><</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>index_iterator</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</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>iterator</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span>
|
||||
<span class=identifier>project</span><span class=special>(</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>,</span>
|
||||
<span class=identifier>IteratorType</span> <span class=identifier>it</span><span class=special>);</span>
|
||||
@@ -184,9 +177,9 @@ synopsis</a>
|
||||
<span class=keyword>typename</span> <span class=identifier>Tag</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IteratorType</span><span class=special>,</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Allocator</span>
|
||||
<span class=special>></span>
|
||||
<span class=keyword>typename</span> <span class=identifier>index</span><span class=special><</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>index_const_iterator</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</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>const_iterator</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span>
|
||||
<span class=identifier>project</span><span class=special>(</span>
|
||||
<span class=keyword>const</span> <span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>,</span>
|
||||
<span class=identifier>IteratorType</span> <span class=identifier>it</span><span class=special>);</span>
|
||||
@@ -264,7 +257,6 @@ operators and functions associated with the index (vg. comparison and
|
||||
<span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>iterator_type_list</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>const_iterator_type_list</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>Allocator</span> <span class=identifier>allocator_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>node_type</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// nested class templates:</span>
|
||||
|
||||
@@ -272,75 +264,52 @@ operators and functions associated with the index (vg. comparison and
|
||||
<span class=keyword>struct</span> <span class=identifier>nth_index</span> <span class=special>{</span><span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>type</span><span class=special>;};</span>
|
||||
<span class=keyword>template</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>index</span> <span class=special>{</span><span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>type</span><span class=special>;};</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span>
|
||||
<span class=keyword>struct</span> <span class=identifier>nth_index_iterator</span> <span class=special>{</span><span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>type</span><span class=special>;};</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span>
|
||||
<span class=keyword>struct</span> <span class=identifier>nth_index_const_iterator</span> <span class=special>{</span><span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>type</span><span class=special>;};</span>
|
||||
<span class=keyword>template</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>index_iterator</span> <span class=special>{</span><span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>type</span><span class=special>;};</span>
|
||||
<span class=keyword>template</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>index_const_iterator</span> <span class=special>{</span><span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>type</span><span class=special>;};</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span>
|
||||
<span class=keyword>struct</span> <span class=identifier>nth_index_iterator</span> <span class=comment><b>// deprecated</b></span>
|
||||
<span class=special>{</span><span class=keyword>typedef</span> <b><span class=identifier>implementation</span> <span class=identifier>defined</span></b> <span class=identifier>type</span><span class=special>;};</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span>
|
||||
<span class=keyword>struct</span> <span class=identifier>nth_index_const_iterator</span> <span class=comment><b>// deprecated</b></span>
|
||||
<span class=special>{</span><span class=keyword>typedef</span> <b><span class=identifier>implementation</span> <span class=identifier>defined</span></b> <span class=identifier>type</span><span class=special>;};</span>
|
||||
<span class=keyword>template</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>index_iterator</span> <span class=comment><b>// deprecated</b></span>
|
||||
<span class=special>{</span><span class=keyword>typedef</span> <b><span class=identifier>implementation</span> <span class=identifier>defined</span></b> <span class=identifier>type</span><span class=special>;};</span>
|
||||
<span class=keyword>template</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>index_const_iterator</span> <span class=comment><b>// deprecated</b></span>
|
||||
<span class=special>{</span><span class=keyword>typedef</span> <b><span class=identifier>implementation</span> <span class=identifier>defined</span></b> <span class=identifier>type</span><span class=special>;};</span>
|
||||
|
||||
<span class=comment>// construct/copy/destroy:</span>
|
||||
|
||||
<span class=identifier>multi_index_container</span><span class=special>();</span>
|
||||
<span class=keyword>explicit</span> <span class=identifier>multi_index_container</span><span class=special>(
|
||||
</span><span class=keyword>const</span> <span class=identifier>ctor_args_list</span><span class=special>&</span> <span class=identifier>args_list</span><span class=special>,
|
||||
</span><span class=keyword>const</span> <span class=identifier>ctor_args_list</span><span class=special>&</span> <span class=identifier>args_list</span><span class=special>=</span><span class=identifier>ctor_args_list</span><span class=special>(),
|
||||
</span><span class=keyword>const</span> <span class=identifier>allocator_type</span><span class=special>&</span> <span class=identifier>al</span><span class=special>=</span><span class=identifier>allocator_type</span><span class=special>());</span>
|
||||
<span class=keyword>explicit</span> <span class=identifier>multi_index_container</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>allocator_type</span><span class=special>&</span> <span class=identifier>al</span><span class=special>);</span>
|
||||
<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>multi_index_container</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=keyword>const</span> <span class=identifier>ctor_args_list</span><span class=special>&</span> <span class=identifier>args_list</span><span class=special>=</span><span class=identifier>ctor_args_list</span><span class=special>(),
|
||||
</span><span class=keyword>const</span> <span class=identifier>allocator_type</span><span class=special>&</span> <span class=identifier>al</span><span class=special>=</span><span class=identifier>allocator_type</span><span class=special>());</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special>(</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special><</span><span class=identifier>Value</span><span class=special>></span> <span class=identifier>list</span><span class=special>,</span>
|
||||
<span class=keyword>const</span> <span class=identifier>ctor_args_list</span><span class=special>&</span> <span class=identifier>args_list</span><span class=special>=</span><span class=identifier>ctor_args_list</span><span class=special>(),</span>
|
||||
<span class=keyword>const</span> <span class=identifier>allocator_type</span><span class=special>&</span> <span class=identifier>al</span><span class=special>=</span><span class=identifier>allocator_type</span><span class=special>());</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special>(</span>
|
||||
<span class=keyword>const</span> <span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>x</span><span class=special>);</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special>(</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&&</span> <span class=identifier>x</span><span class=special>);</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special>(</span>
|
||||
<span class=keyword>const</span> <span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>x</span><span class=special>,</span>
|
||||
<span class=keyword>const</span> <span class=identifier>allocator_type</span><span class=special>&</span> <span class=identifier>al</span><span class=special>);</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special>(</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&&</span> <span class=identifier>x</span><span class=special>,</span>
|
||||
<span class=keyword>const</span> <span class=identifier>allocator_type</span><span class=special>&</span> <span class=identifier>al</span><span class=special>);</span>
|
||||
|
||||
<span class=special>~</span><span class=identifier>multi_index_container</span><span class=special>();</span>
|
||||
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=keyword>operator</span><span class=special>=(</span>
|
||||
<span class=keyword>const</span> <span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>x</span><span class=special>);</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=keyword>operator</span><span class=special>=(</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&&</span> <span class=identifier>x</span><span class=special>);</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=keyword>operator</span><span class=special>=(</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special><</span><span class=identifier>Value</span><span class=special>></span> <span class=identifier>list</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=keyword>noexcept</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>// retrieval of indices</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span> <span class=keyword>typename</span> <span class=identifier>nth_index</span><span class=special><</span><span class=identifier>N</span><span class=special>>::</span><span class=identifier>type</span><span class=special>&</span> <span class=identifier>get</span><span class=special>()</span><span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span> <span class=keyword>const</span> <span class=keyword>typename</span> <span class=identifier>nth_index</span><span class=special><</span><span class=identifier>N</span><span class=special>>::</span><span class=identifier>type</span><span class=special>&</span> <span class=identifier>get</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Tag</span><span class=special>></span> <span class=keyword>typename</span> <span class=identifier>index</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>get</span><span class=special>()</span><span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Tag</span><span class=special>></span> <span class=keyword>const</span> <span class=keyword>typename</span> <span class=identifier>index</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>get</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span> <span class=keyword>typename</span> <span class=identifier>nth_index</span><span class=special><</span><span class=identifier>N</span><span class=special>>::</span><span class=identifier>type</span><span class=special>&</span> <span class=identifier>get</span><span class=special>();</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span> <span class=keyword>const</span> <span class=keyword>typename</span> <span class=identifier>nth_index</span><span class=special><</span><span class=identifier>N</span><span class=special>>::</span><span class=identifier>type</span><span class=special>&</span> <span class=identifier>get</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>typename</span> <span class=identifier>Tag</span><span class=special>></span> <span class=keyword>typename</span> <span class=identifier>index</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>get</span><span class=special>()</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Tag</span><span class=special>></span> <span class=keyword>const</span> <span class=keyword>typename</span> <span class=identifier>index</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>get</span><span class=special>()</span><span class=keyword>const</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// projection of iterators</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IteratorType</span><span class=special>></span>
|
||||
<span class=keyword>typename</span> <span class=identifier>nth_index</span><span class=special><</span><span class=identifier>N</span><span class=special>>::</span><span class=identifier>type</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>it</span><span class=special>);</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>nth_index_iterator</span><span class=special><</span><span class=identifier>N</span><span class=special>>::</span><span class=identifier>type</span> <span class=identifier>project</span><span class=special>(</span><span class=identifier>IteratorType</span> <span class=identifier>it</span><span class=special>);</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IteratorType</span><span class=special>></span>
|
||||
<span class=keyword>typename</span> <span class=identifier>nth_index</span><span class=special><</span><span class=identifier>N</span><span class=special>>::</span><span class=identifier>type</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>it</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>nth_index_const_iterator</span><span class=special><</span><span class=identifier>N</span><span class=special>>::</span><span class=identifier>type</span> <span class=identifier>project</span><span class=special>(</span><span class=identifier>IteratorType</span> <span class=identifier>it</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>typename</span> <span class=identifier>Tag</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IteratorType</span><span class=special>></span>
|
||||
<span class=keyword>typename</span> <span class=identifier>index</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>iterator</span> <span class=identifier>project</span><span class=special>(</span><span class=identifier>IteratorType</span> <span class=identifier>it</span><span class=special>);</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>index_iterator</span><span class=special><</span><span class=identifier>Tag</span><span class=special>>::</span><span class=identifier>type</span> <span class=identifier>project</span><span class=special>(</span><span class=identifier>IteratorType</span> <span class=identifier>it</span><span class=special>);</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Tag</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IteratorType</span><span class=special>></span>
|
||||
<span class=keyword>typename</span> <span class=identifier>index</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>const_iterator</span> <span class=identifier>project</span><span class=special>(</span><span class=identifier>IteratorType</span> <span class=identifier>it</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>index_const_iterator</span><span class=special><</span><span class=identifier>Tag</span><span class=special>>::</span><span class=identifier>type</span> <span class=identifier>project</span><span class=special>(</span><span class=identifier>IteratorType</span> <span class=identifier>it</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
|
||||
<span class=special>};</span>
|
||||
|
||||
<span class=comment>// multi_index_container associated global class templates:</span>
|
||||
@@ -355,26 +324,22 @@ operators and functions associated with the index (vg. comparison and
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</span><span class=special>::</span><span class=identifier>index</span><span class=special><</span><span class=identifier>Tag</span><span class=special>>::</span><span class=identifier>type</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>MultiIndexContainer</span><span class=special>,</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span>
|
||||
<span class=keyword>struct</span> <span class=identifier>nth_index_iterator</span> <span class=comment><b>// deprecated</b></span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</span><span class=special>,</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span> <span class=keyword>struct</span> <span class=identifier>nth_index_iterator</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</span><span class=special>::</span><span class=identifier>nth_index_iterator</span><span class=special><</span><span class=identifier>N</span><span class=special>>::</span><span class=identifier>type</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>MultiIndexContainer</span><span class=special>,</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span>
|
||||
<span class=keyword>struct</span> <span class=identifier>nth_index_const_iterator</span> <span class=comment><b>// deprecated</b></span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</span><span class=special>,</span><span class=keyword>int</span> <span class=identifier>N</span><span class=special>></span> <span class=keyword>struct</span> <span class=identifier>nth_index_const_iterator</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</span><span class=special>::</span><span class=identifier>nth_index_const_iterator</span><span class=special><</span><span class=identifier>N</span><span class=special>>::</span><span class=identifier>type</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>MultiIndexContainer</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>index_iterator</span> <span class=comment><b>// deprecated</b></span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</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>index_iterator</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</span><span class=special>::</span><span class=identifier>index_iterator</span><span class=special><</span><span class=identifier>Tag</span><span class=special>>::</span><span class=identifier>type</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>MultiIndexContainer</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>index_const_iterator</span> <span class=comment><b>// deprecated</b></span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</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>index_const_iterator</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>MultiIndexContainer</span><span class=special>::</span><span class=identifier>index_const_iterator</span><span class=special><</span><span class=identifier>Tag</span><span class=special>>::</span><span class=identifier>type</span> <span class=identifier>type</span><span class=special>;</span>
|
||||
<span class=special>};</span>
|
||||
@@ -387,7 +352,7 @@ operators and functions associated with the index (vg. comparison and
|
||||
<span class=keyword>typename</span> <span class=identifier>nth_index</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>,</span><span class=identifier>N</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span><span class=special>&</span>
|
||||
<span class=identifier>get</span><span class=special>(</span><span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>)</span><span class=keyword>noexcept</span>
|
||||
<span class=identifier>get</span><span class=special>(</span><span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>m</span><span class=special>.</span><span class=identifier>get</span><span class=special><</span><span class=identifier>N</span><span class=special>>();</span>
|
||||
<span class=special>}</span>
|
||||
@@ -398,7 +363,7 @@ operators and functions associated with the index (vg. comparison and
|
||||
<span class=keyword>const</span> <span class=keyword>typename</span> <span class=identifier>nth_index</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>,</span><span class=identifier>N</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span><span class=special>&</span>
|
||||
<span class=identifier>get</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>)</span><span class=keyword>noexcept</span>
|
||||
<span class=identifier>get</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>m</span><span class=special>.</span><span class=identifier>get</span><span class=special><</span><span class=identifier>N</span><span class=special>>();</span>
|
||||
<span class=special>}</span>
|
||||
@@ -409,7 +374,7 @@ operators and functions associated with the index (vg. comparison and
|
||||
<span class=keyword>typename</span> <span class=identifier>index</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</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>get</span><span class=special>(</span><span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>)</span><span class=keyword>noexcept</span>
|
||||
<span class=identifier>get</span><span class=special>(</span><span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>m</span><span class=special>.</span><span class=identifier>get</span><span class=special><</span><span class=identifier>Tag</span><span class=special>>();</span>
|
||||
<span class=special>}</span>
|
||||
@@ -420,7 +385,7 @@ operators and functions associated with the index (vg. comparison and
|
||||
<span class=keyword>const</span> <span class=keyword>typename</span> <span class=identifier>index</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</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>get</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>)</span><span class=keyword>noexcept</span>
|
||||
<span class=identifier>get</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>m</span><span class=special>.</span><span class=identifier>get</span><span class=special><</span><span class=identifier>Tag</span><span class=special>>();</span>
|
||||
<span class=special>}</span>
|
||||
@@ -431,56 +396,56 @@ operators and functions associated with the index (vg. comparison and
|
||||
<span class=keyword>int</span> <span class=identifier>N</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IteratorType</span><span class=special>,</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Allocator</span>
|
||||
<span class=special>></span>
|
||||
<span class=keyword>typename</span> <span class=identifier>nth_index</span><span class=special><</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>nth_index_iterator</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>,</span><span class=identifier>N</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span><span class=special>::</span><span class=identifier>iterator</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span>
|
||||
<span class=identifier>project</span><span class=special>(</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>,</span>
|
||||
<span class=identifier>IteratorType</span> <span class=identifier>it</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>m</span><span class=special>.</span><span class=keyword>template</span> <span class=identifier>project</span><span class=special><</span><span class=identifier>N</span><span class=special>>(</span><span class=identifier>it</span><span class=special>);</span>
|
||||
<span class=keyword>return</span> <span class=identifier>m</span><span class=special>.</span><span class=identifier>project</span><span class=special><</span><span class=identifier>N</span><span class=special>>(</span><span class=identifier>it</span><span class=special>);</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span>
|
||||
<span class=keyword>int</span> <span class=identifier>N</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IteratorType</span><span class=special>,</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Allocator</span>
|
||||
<span class=special>></span>
|
||||
<span class=keyword>typename</span> <span class=identifier>nth_index</span><span class=special><</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>nth_index_const_iterator</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>,</span><span class=identifier>N</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span><span class=special>::</span><span class=identifier>const_iterator</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span>
|
||||
<span class=identifier>project</span><span class=special>(</span>
|
||||
<span class=keyword>const</span> <span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>,</span>
|
||||
<span class=identifier>IteratorType</span> <span class=identifier>it</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>m</span><span class=special>.</span><span class=keyword>template</span> <span class=identifier>project</span><span class=special><</span><span class=identifier>N</span><span class=special>>(</span><span class=identifier>it</span><span class=special>);</span>
|
||||
<span class=keyword>return</span> <span class=identifier>m</span><span class=special>.</span><span class=identifier>project</span><span class=special><</span><span class=identifier>N</span><span class=special>>(</span><span class=identifier>it</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>Tag</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IteratorType</span><span class=special>,</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Allocator</span>
|
||||
<span class=special>></span>
|
||||
<span class=keyword>typename</span> <span class=identifier>index</span><span class=special><</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>index_iterator</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</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>iterator</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span>
|
||||
<span class=identifier>project</span><span class=special>(</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>,</span>
|
||||
<span class=identifier>IteratorType</span> <span class=identifier>it</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>m</span><span class=special>.</span><span class=keyword>template</span> <span class=identifier>project</span><span class=special><</span><span class=identifier>Tag</span><span class=special>>(</span><span class=identifier>it</span><span class=special>);</span>
|
||||
<span class=keyword>return</span> <span class=identifier>m</span><span class=special>.</span><span class=identifier>project</span><span class=special><</span><span class=identifier>Tag</span><span class=special>>(</span><span class=identifier>it</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>Tag</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IteratorType</span><span class=special>,</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Allocator</span>
|
||||
<span class=special>></span>
|
||||
<span class=keyword>typename</span> <span class=identifier>index</span><span class=special><</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>index_const_iterator</span><span class=special><</span>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</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>const_iterator</span>
|
||||
<span class=special>>::</span><span class=identifier>type</span>
|
||||
<span class=identifier>project</span><span class=special>(</span>
|
||||
<span class=keyword>const</span> <span class=identifier>multi_index_container</span><span class=special><</span><span class=identifier>Value</span><span class=special>,</span><span class=identifier>IndexSpecifierList</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>&</span> <span class=identifier>m</span><span class=special>,</span>
|
||||
<span class=identifier>IteratorType</span> <span class=identifier>it</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>m</span><span class=special>.</span><span class=keyword>template</span> <span class=identifier>project</span><span class=special><</span><span class=identifier>Tag</span><span class=special>>(</span><span class=identifier>it</span><span class=special>);</span>
|
||||
<span class=keyword>return</span> <span class=identifier>m</span><span class=special>.</span><span class=identifier>project</span><span class=special><</span><span class=identifier>Tag</span><span class=special>>(</span><span class=identifier>it</span><span class=special>);</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=comment>// comparison:</span>
|
||||
@@ -526,9 +491,9 @@ scheme outlined in the
|
||||
<p>
|
||||
<code>multi_index_container</code> is instantiated with the following types:
|
||||
<ol>
|
||||
<li><code>Value</code> is the type of the elements contained. <code>Value</code> must be
|
||||
<code>Erasable</code> from <code>multi_index_container</code>.
|
||||
</li>
|
||||
<li><code>Value</code> is the
|
||||
<a href="http://www.sgi.com/tech/stl/Assignable.html"><code>Assignable</code></a>
|
||||
type of the elements contained.</li>
|
||||
<li><code>IndexSpecifierList</code> specifies the indices that the
|
||||
<code>multi_index_container</code> is composed of. It must be a non-empty
|
||||
<a href="../../../../libs/mpl/doc/refmanual/forward-sequence.html">
|
||||
@@ -538,36 +503,14 @@ scheme outlined in the
|
||||
syntactic convenience, the
|
||||
<a href="indices.html#indexed_by"><code>indexed_by</code></a>
|
||||
MPL sequence can be used.
|
||||
</li>
|
||||
<li><code>Allocator</code> must be an allocator of <code>Value</code> objects
|
||||
satisfying the associated C++ requirements at <b>[allocator.requirements]</b>.
|
||||
The following relaxations to the standard requirements are allowed:
|
||||
<ul>
|
||||
<li>Non-equal allocator instances are supported: swapping two non-equal
|
||||
instances must not throw any exception.
|
||||
</li>
|
||||
<li>For every type <code>T</code>,
|
||||
the type <code>Allocator::rebind<T>::other::pointer</code> can be any
|
||||
kind of random access iterator, provided that it is explicitly constructible from
|
||||
the literal <code>0</code> (standing here as the null pointer) or from any
|
||||
<code>p</code> of type <code>T*</code> pointing into an area allocated by
|
||||
some instance of <code>Allocator</code> or some other allocator type rebound
|
||||
from <code>Allocator</code>. A <code>pointer</code> constructed from
|
||||
<code>p</code> shall dereference to <code>*p</code>.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><code>Allocator</code> must comply with the C++ requirements for
|
||||
allocators <b>[lib.allocator.requirements]</b>.
|
||||
</ol>
|
||||
Indices of a given <code>multi_index_container</code> instantiation cannot have
|
||||
duplicate <a href="indices.html#tags">tags</a>, either within a single
|
||||
index or in two different indices.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
In what follows, the number of indices of the <code>multi_index_container</code>
|
||||
is named <code>I</code>.
|
||||
</p>
|
||||
|
||||
<h4><a name="types">Nested types</a></h4>
|
||||
|
||||
<code>ctor_args_list</code>
|
||||
@@ -585,8 +528,9 @@ implicit conversion from
|
||||
to <code>const ctor_args_list&</code>. This type is used for
|
||||
providing the construction arguments of the indices of the
|
||||
<code>multi_index_container</code>. <code>ctor_args_list</code> is
|
||||
<code>DefaultConstructible</code>, provided that all <code>ctor_args</code> types
|
||||
involved are <code>DefaultConstructible</code>.
|
||||
<a href="http://www.sgi.com/tech/stl/DefaultConstructible.html"><code>Default
|
||||
Constructible</code></a>, provided that all <code>ctor_args</code> types
|
||||
involved are default constructible.
|
||||
</blockquote>
|
||||
|
||||
<code>index_specifier_type_list</code>
|
||||
@@ -630,22 +574,6 @@ iterators of the indices held by the <code>multi_index_container</code>, in the
|
||||
as they were specified.
|
||||
</blockquote>
|
||||
|
||||
<a name="node_type"><code>node_type</code></a>
|
||||
|
||||
<blockquote>
|
||||
Node handle class following the standard specification at
|
||||
<b>[container.node]</b> (version for set containers).
|
||||
Two instantiations of <code>multi_index_container</code>
|
||||
have compatible nodes (i.e., the same <code>node_type</code>) if and only if
|
||||
they are of the form
|
||||
<code>multi_index_container<Value,IndexSpecifierList1,Allocator></code> and
|
||||
<code>multi_index_container<Value,IndexSpecifierList2,Allocator></code>,
|
||||
have the same number <code>I</code> of index specifiers, and, for <code>i</code> =
|
||||
<code>0</code>, ... , <code>I-1</code>, the respective <code>i</code>-th index specifiers
|
||||
refer to the same <a href="indices.html#index_catalog">type of index</a>, regardless
|
||||
of unique/non-unique variants and particular configuration type arguments.
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="nested_templates">Nested class templates</a></h4>
|
||||
|
||||
<code>template<int N> struct nth_index</code>
|
||||
@@ -654,14 +582,14 @@ of unique/non-unique variants and particular configuration type arguments.
|
||||
<code>nth_index<N>::type</code> yields the type of the
|
||||
<code>N</code>-th (0-based) index held by the <code>multi_index_container</code>, in
|
||||
the same order as they were specified.<br>
|
||||
<b>Requires:</b> <code>0 <= N < I-1</code>.
|
||||
<b>Requires:</b> <code>0 <= N < I</code>.
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename Tag> struct index</code>
|
||||
|
||||
<blockquote>
|
||||
<code>index<Tag>::type</code> yields the type of the index which
|
||||
has <code>Tag</code> as an associated <a href="indices.html#tags">tag type</a>.<br>
|
||||
has <code>Tag</code> as an associated <a href="indices.html#tags">tag type</a>.</br>
|
||||
<b>Requires:</b> Some index of the <code>multi_index_container</code> has <code>Tag</code>
|
||||
as an associated tag type.
|
||||
</blockquote>
|
||||
@@ -671,7 +599,6 @@ as an associated tag type.
|
||||
<blockquote>
|
||||
<code>nth_index_iterator<N>::type</code> is equivalent to
|
||||
<code>nth_index<N>::type::iterator</code>.<br>
|
||||
<b>Note:</b> The use of <code>nth_index_iterator</code> is deprecated.
|
||||
</blockquote>
|
||||
|
||||
<code>template<int N> struct nth_index_const_iterator</code>
|
||||
@@ -679,7 +606,6 @@ as an associated tag type.
|
||||
<blockquote>
|
||||
<code>nth_index_const_iterator<N>::type</code> is equivalent to
|
||||
<code>nth_index<N>::type::const_iterator</code>.<br>
|
||||
<b>Note:</b> The use of <code>nth_index_const_iterator</code> is deprecated.
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename Tag> struct index_iterator</code>
|
||||
@@ -687,7 +613,6 @@ as an associated tag type.
|
||||
<blockquote>
|
||||
<code>index_iterator<Tag>::type</code> is equivalent to
|
||||
<code>index<Tag>::type::iterator</code>.<br>
|
||||
<b>Note:</b> The use of <code>index_iterator</code> is deprecated.
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename Tag> struct index_const_iterator</code>
|
||||
@@ -695,21 +620,12 @@ as an associated tag type.
|
||||
<blockquote>
|
||||
<code>index_const_iterator<Tag>::type</code> is equivalent to
|
||||
<code>index<Tag>::type::const_iterator</code>.<br>
|
||||
<b>Note:</b> The use of <code>index_const_iterator</code> is deprecated.
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="constructors">Constructors, copy and assignment</a></h4>
|
||||
|
||||
<code>multi_index_container();</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b> Constructs an empty <code>multi_index_container</code> using the
|
||||
default values of <code>ctor_args_list</code> and <code>allocator_type</code>.<br>
|
||||
<b>Complexity:</b> Constant.
|
||||
</blockquote>
|
||||
|
||||
<code>explicit multi_index_container(<br>
|
||||
const ctor_args_list& args_list,<br>
|
||||
const ctor_args_list& comp=ctor_args_list(),<br>
|
||||
const allocator_type& al=allocator_type());</code>
|
||||
|
||||
<blockquote>
|
||||
@@ -718,26 +634,18 @@ specified argument list and allocator.<br>
|
||||
<b>Complexity:</b> Constant.
|
||||
</blockquote>
|
||||
|
||||
<code>explicit multi_index_container(const allocator_type& al);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b> Constructs an empty <code>multi_index_container</code> using the
|
||||
specified allocator and the default value of <code>ctor_args_list</code>.<br>
|
||||
<b>Complexity:</b> Constant.
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename InputIterator><br>
|
||||
multi_index_container(<br>
|
||||
InputIterator first,InputIterator last,<br>
|
||||
const ctor_args_list& args_list=ctor_args_list(),<br>
|
||||
const ctor_args_list& comp=ctor_args_list(),<br>
|
||||
const allocator_type& al=allocator_type());</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>InputIterator</code> is an input iterator.
|
||||
<code>Value</code> is
|
||||
<code>EmplaceConstructible</code> into <code>multi_index_container</code>
|
||||
from <code>*first</code>.
|
||||
<code>last</code> is reachable from <code>first</code>.<br>
|
||||
<b>Requires:</b> <code>InputIterator</code> is a model of
|
||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">
|
||||
<code>Input Iterator</code></a> over elements of type
|
||||
<code>Value</code> or a type convertible to <code>Value</code>.
|
||||
<code>last</code> is reachable from <code>first</code>.</br>
|
||||
<b>Effects:</b> Constructs and empty <code>multi_index_container</code> using the
|
||||
specified argument list and allocator and fills it with
|
||||
the elements in the range [<code>first</code>,<code>last</code>).
|
||||
@@ -747,80 +655,19 @@ on the acceptance by all the indices of the <code>multi_index_container</code>.<
|
||||
the number of elements in [<code>first</code>,<code>last</code>).<br>
|
||||
</blockquote>
|
||||
|
||||
<code>multi_index_container(<br>
|
||||
std::initializer_list<Value> list,<br>
|
||||
const ctor_args_list& args_list=ctor_args_list(),<br>
|
||||
const allocator_type& al=allocator_type());</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b> Equivalent to
|
||||
<code>multi_index_container(list.begin(),list.end(),args_list,al)</code>.
|
||||
</blockquote>
|
||||
|
||||
<code>multi_index_container(<br>
|
||||
const multi_index_container<Value,IndexSpecifierList,Allocator>& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>Value</code> is <code>CopyInsertable</code> into
|
||||
<code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> Constructs a copy of <code>x</code>, copying its
|
||||
elements as well as its internal objects (those specified
|
||||
in <code>ctor_args_list</code> and the allocator.)<br>
|
||||
elements as well as its internal objects (key extractors, comparison objects,
|
||||
allocator.)<br>
|
||||
<b>Postconditions:</b> <code>*this==x</code>. The order on every index
|
||||
of the <code>multi_index_container</code> is preserved as well.<br>
|
||||
<b>Complexity:</b> <code>O(x.size()*log(x.size()) + C(x.size()))</code>.
|
||||
</blockquote>
|
||||
|
||||
<code>multi_index_container(<br>
|
||||
multi_index_container<Value,IndexSpecifierList,Allocator>&& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b> Constructs a <code>multi_index_container</code> by transferring the
|
||||
elements of <code>x</code> and copying its internal objects (those specified
|
||||
in <code>ctor_args_list</code> and the allocator.)<br>
|
||||
<b>Postconditions:</b> If <code>x==y</code> just
|
||||
before the movement, <code>*this==y</code>. The order on every index
|
||||
of the <code>multi_index_container</code> is preserved as well.<br>
|
||||
<b>Complexity:</b> Constant.
|
||||
</blockquote>
|
||||
|
||||
<code>multi_index_container(<br>
|
||||
const multi_index_container<Value,IndexSpecifierList,Allocator>& x,<br>
|
||||
const allocator_type& al);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>Value</code> is <code>CopyInsertable</code> into
|
||||
<code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> Constructs a copy of <code>x</code>, copying its
|
||||
elements and its internal objects (those specified
|
||||
in <code>ctor_args_list</code>) and using a copy of the allocator
|
||||
<code>al</code> provided.<br>
|
||||
<b>Postconditions:</b> <code>*this==x</code>. The order on every index
|
||||
of the <code>multi_index_container</code> is preserved as well.<br>
|
||||
<b>Complexity:</b> <code>O(x.size()*log(x.size()) + C(x.size()))</code>.
|
||||
</blockquote>
|
||||
|
||||
<code>multi_index_container(<br>
|
||||
multi_index_container<Value,IndexSpecifierList,Allocator>&& x,<br>
|
||||
const allocator_type& al);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>Value</code> is <code>MoveInsertable</code> into
|
||||
<code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> Constructs a <code>multi_index_container</code> by transferring/moving
|
||||
the elements of <code>x</code>, copying its internal objects (those specified
|
||||
in <code>ctor_args_list</code>) and using a copy of the allocator
|
||||
<code>al</code> provided. If <code>x.get_allocator()==al</code>, elements are transferred
|
||||
(no constructions involved), otherwise they are move constructed from <code>x</code>.<br>
|
||||
<b>Postconditions:</b> If <code>x==y</code> just
|
||||
before the movement, <code>*this==y</code>. The order on every index
|
||||
of the <code>multi_index_container</code> is preserved as well.<br>
|
||||
<b>Complexity:</b> Constant if <code>x.get_allocator()==al</code>, otherwise
|
||||
<code>O(x.size()*log(x.size()) + C(x.size()))</code>.
|
||||
</blockquote>
|
||||
|
||||
<code>~multi_index_container()</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b> Destroys the <code>multi_index_container</code> and all the elements
|
||||
contained. The order in which the elements are destroyed is not specified.<br>
|
||||
@@ -831,14 +678,8 @@ contained. The order in which the elements are destroyed is not specified.<br>
|
||||
const multi_index_container<Value,IndexSpecifierList,Allocator>& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>Value</code> is <code>CopyInsertable</code> into
|
||||
<code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> Replaces the elements and internal objects (those specified
|
||||
in <code>ctor_args_list</code>) of the <code>multi_index_container</code>
|
||||
with copies from <code>x</code>. The internal allocator is replaced with a
|
||||
copy of <code>x.get_allocator()</code> if and only if
|
||||
<code>std::allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value</code>
|
||||
is <code>true</code>.<br>
|
||||
Replaces the elements and internal objects of the <code>multi_index_container</code>
|
||||
with copies from <code>x</code>.<br>
|
||||
<b>Postconditions:</b> <code>*this==x</code>. The order on every index
|
||||
of the <code>multi_index_container</code> is preserved as well.<br>
|
||||
<b>Returns:</b> <code>*this</code>.<br>
|
||||
@@ -848,53 +689,7 @@ C(x.size()))</code>.<br>
|
||||
of the types of <code>ctor_args_list</code> do not throw.
|
||||
</blockquote>
|
||||
|
||||
<code>multi_index_container<Value,IndexSpecifierList,Allocator>& operator=(<br>
|
||||
multi_index_container<Value,IndexSpecifierList,Allocator>&& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> If <code>std::allocator_traits<allocator_type>::propagate_on_container_move_assignment::value</code>
|
||||
is <code>true</code>, <code>Value</code> is <code>MoveInsertable</code> into
|
||||
<code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> Replaces the elements of <code>multi_index_container</code>
|
||||
with those of <code>x</code> or with copies move-constructed from those of <code>x</code>.
|
||||
Replaces the internal objects (those specified
|
||||
in <code>ctor_args_list</code>) with copies from the
|
||||
corresponding objects in <code>x</code>. Replaces the internal allocator with a
|
||||
copy of <code>x.get_allocator()</code> if and only if
|
||||
<code>std::allocator_traits<allocator_type>::propagate_on_container_move_assignment::value</code>
|
||||
is <code>true</code>.
|
||||
Elements of <code>x</code> are transferred (no constructions involved) if and only if
|
||||
<code>x.get_allocator()</code> is copied or is equal to the previous value of the internal
|
||||
allocator.
|
||||
<br>
|
||||
<b>Postconditions:</b> If <code>x==y</code> just
|
||||
before the movement, <code>*this==y</code>. The order on every index
|
||||
of the <code>multi_index_container</code> is preserved as well.<br>
|
||||
<b>Returns:</b> <code>*this</code>.<br>
|
||||
<b>Complexity:</b> <code>O(n)</code> if elements of <code>x</code> are transferred,
|
||||
otherwise <code>O(n + x.size()*log(x.size()) + C(x.size()))</code>.<br>
|
||||
<b>Exception safety:</b> Strong, provided the copy and assignment operations
|
||||
of the types of <code>ctor_args_list</code> do not throw.
|
||||
</blockquote>
|
||||
|
||||
<code>multi_index_container<Value,IndexSpecifierList,Allocator>& operator=(<br>
|
||||
std::initializer_list<Value> list);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>Value</code> is <code>CopyInsertable</code> into
|
||||
<code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> Replaces the elements the <code>multi_index_container</code>
|
||||
with copies of the elements of <code>list</code>, inserted in the specified order.
|
||||
Insertion of each element may or may not succeed depending
|
||||
on the acceptance by all the indices of the <code>multi_index_container</code>.<br>
|
||||
<b>Returns:</b> <code>*this</code>.<br>
|
||||
<b>Complexity:</b> <code>O(n + I(m))</code>, where <code>m</code> is the
|
||||
number of elements of <code>list</code>.<br>
|
||||
<b>Exception safety:</b> Strong, provided the copy and assignment operations
|
||||
of the types of <code>ctor_args_list</code> do not throw.
|
||||
</blockquote>
|
||||
|
||||
<code>allocator_type get_allocator()const noexcept;</code>
|
||||
<code>allocator_type get_allocator()const;</code>
|
||||
|
||||
<blockquote>
|
||||
Returns a copy of the <code>allocator_type</code> object used to construct
|
||||
@@ -904,25 +699,27 @@ the <code>multi_index_container</code>.<br>
|
||||
|
||||
<h4><a name="index_retrieval">Index retrieval operations</a></h4>
|
||||
|
||||
<code>template<int N> typename nth_index<N>::type& get()noexcept;</code>
|
||||
<code>template<int N> typename nth_index<N>::type& get();</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>0 <= N < I-1</code>.<br>
|
||||
<b>Requires:</b> <code>0 <= N < I</code>.<br>
|
||||
<b>Effects:</b> Returns a reference to the
|
||||
<code>nth_index<N>::type</code> index held by <code>*this</code>.<br>
|
||||
<b>Complexity:</b> Constant.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.
|
||||
</blockquote>
|
||||
|
||||
<code>template<int N> const typename nth_index<N>::type& get()const noexcept;</code>
|
||||
<code>template<int N> const typename nth_index<N>::type& get()const;</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>0 <= N < I-1</code>.<br>
|
||||
<b>Requires:</b> <code>0 <= N < I</code>.<br>
|
||||
<b>Effects:</b> Returns a <code>const</code> reference to the
|
||||
<code>nth_index<N>::type</code> index held by <code>*this</code>.<br>
|
||||
<b>Complexity:</b> Constant.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename Tag> typename index<Tag>::type& get()noexcept;</code>
|
||||
<code>template<typename Tag> typename index<Tag>::type& get()</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>Tag</code> is such that <code>index<Tag>::type</code>
|
||||
@@ -931,9 +728,10 @@ is valid.<br>
|
||||
<code>index<Tag>::type</code> index held by
|
||||
<code>*this</code>.<br>
|
||||
<b>Complexity:</b> Constant.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename Tag> const typename index<Tag>::type& get()const noexcept;</code>
|
||||
<code>template<typename Tag> const typename index<Tag>::type& get()const;</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>Tag</code> is such that <code>index<Tag>::type</code>
|
||||
@@ -942,6 +740,7 @@ is valid.<br>
|
||||
<code>index<Tag>::type</code> index held by
|
||||
<code>*this</code>.<br>
|
||||
<b>Complexity:</b> Constant.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="projection">Projection operations</a></h4>
|
||||
@@ -959,60 +758,60 @@ are <i>equivalent</i> if:
|
||||
</p>
|
||||
|
||||
<code>template<int N,typename IteratorType><br>
|
||||
typename nth_index<N>::type::iterator project(IteratorType it);</code>
|
||||
typename nth_index_iterator<N>::type project(IteratorType it);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>0 <= N < I-1</code>. <code>IteratorType</code>
|
||||
<b>Requires:</b> <code>0 <= N < I</code>. <code>IteratorType</code>
|
||||
belongs to <code>iterator_type_list</code>. <code>it</code> is a valid
|
||||
iterator of some index of <code>*this</code> (i.e. does not refer to some
|
||||
other <code>multi_index_container</code>.)<br>
|
||||
<b>Effects:</b> Returns an <code>nth_index<N>::type::iterator</code>
|
||||
<b>Effects:</b> Returns an <code>nth_index_iterator<N>::type</code> iterator
|
||||
equivalent to <code>it</code>.<br>
|
||||
<b>Complexity:</b> Constant.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.
|
||||
</blockquote>
|
||||
|
||||
<code>template<int N,typename IteratorType><br>
|
||||
typename nth_index<N>::type::const_iterator project(IteratorType it)const;</code>
|
||||
typename nth_index_const_iterator<N>::type project(IteratorType it)const;</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>0 <= N < I-1</code>. <code>IteratorType</code>
|
||||
<b>Requires:</b> <code>0 <= N < I</code>. <code>IteratorType</code>
|
||||
belongs to <code>const_iterator_type_list</code> or
|
||||
<code>iterator_type_list</code>. <code>it</code> is a
|
||||
valid (constant or non-constant) iterator of some index of <code>*this</code>
|
||||
(i.e. does not refer to some other <code>multi_index_container</code>.)<br>
|
||||
<b>Effects:</b> Returns an <code>nth_index<N>::type::const_iterator</code>
|
||||
equivalent to <code>it</code>.<br>
|
||||
<b>Effects:</b> Returns an <code>nth_index_const_iterator<N>::type</code>
|
||||
iterator equivalent to <code>it</code>.<br>
|
||||
<b>Complexity:</b> Constant.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename Tag,typename IteratorType><br>
|
||||
typename index<Tag>::type::iterator project(IteratorType it);</code>
|
||||
typename index_iterator<Tag>::type project(IteratorType it);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>Tag</code> is such that
|
||||
<code>index<Tag>::type</code> is valid. <code>IteratorType</code>
|
||||
<code>index_iterator<Tag>::type</code> is valid. <code>IteratorType</code>
|
||||
belongs to <code>iterator_type_list</code>. <code>it</code> is a valid
|
||||
iterator of some index of <code>*this</code> (i.e. does not refer to some
|
||||
other <code>multi_index_container</code>.)<br>
|
||||
<b>Effects:</b> Returns an <code>index<Tag>::type::iterator</code>
|
||||
<b>Effects:</b> Returns an <code>index_iterator<Tag>::type</code> iterator
|
||||
equivalent to <code>it</code>.<br>
|
||||
<b>Complexity:</b> Constant.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename Tag,typename IteratorType><br>
|
||||
typename index<Tag>::type::const_iterator project(IteratorType it)const;</code>
|
||||
typename index_const_iterator<Tag>::type project(IteratorType it)const;</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>Tag</code> is such that
|
||||
<code>index<Tag>::type</code> is valid. <code>IteratorType</code>
|
||||
<code>index_const_iterator<Tag>::type</code> is valid. <code>IteratorType</code>
|
||||
belongs to <code>const_iterator_type_list</code> or
|
||||
<code>iterator_type_list</code>. <code>it</code> is a valid
|
||||
(constant or non-constant) iterator of some index of <code>*this</code>
|
||||
(i.e. does not refer to some other <code>multi_index_container</code>.)<br>
|
||||
<b>Effects:</b> Returns an <code>index<Tag>::type::const_iterator</code>
|
||||
<b>Effects:</b> Returns an <code>index_const_iterator<Tag>::type</code>
|
||||
iterator equivalent to <code>it</code>.<br>
|
||||
<b>Complexity:</b> Constant.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.
|
||||
@@ -1036,7 +835,8 @@ these, the following concepts are used. A type <code>T</code> is <i>serializable
|
||||
archive (XML archive) and later retrieved from an input archive (XML archive) associated to
|
||||
the same storage. If <code>x'</code> of type <code>T</code> is loaded from the
|
||||
serialization information saved from another object <code>x</code>, we say that
|
||||
<code>x'</code> is a <i>restored copy</i> of <code>x</code>. Given a binary predicate
|
||||
<code>x'</code> is a <i>restored copy</i> of <code>x</code>. Given a
|
||||
<a href="http://www.sgi.com/tech/stl/BinaryPredicate.html"><code>Binary Predicate</code></a>
|
||||
<code>Pred</code> over (<code>T</code>, <code>T</code>), and objects <code>p</code>
|
||||
and <code>q</code> of type <code>Pred</code>, we say that <code>q</code>
|
||||
is <i>serialization-compatible</i> with <code>p</code> if
|
||||
@@ -1082,9 +882,9 @@ Index reference
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised May 9th 2020</p>
|
||||
<p>Revised February 6th 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2020 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
+122
-378
@@ -21,8 +21,8 @@ Index reference
|
||||
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.MultiIndex reference" border="0"><br>
|
||||
Boost.MultiIndex reference
|
||||
</a></div>
|
||||
<div class="next_link"><a href="rnk_indices.html"><img src="../next.gif" alt="ranked indices" border="0"><br>
|
||||
Ranked indices
|
||||
<div class="next_link"><a href="hash_indices.html"><img src="../next.gif" alt="hashed indices" border="0"><br>
|
||||
Hashed indices
|
||||
</a></div><br clear="all" style="clear: all;">
|
||||
|
||||
<hr>
|
||||
@@ -43,7 +43,6 @@ Ranked indices
|
||||
<li><a href="#complexity_signature">Complexity signature</a></li>
|
||||
<li><a href="#instantiation_types">Instantiation types</a></li>
|
||||
<li><a href="#constructors">Constructors, copy and assignment</a></li>
|
||||
<li><a href="#iterators">Iterators</a></li>
|
||||
<li><a href="#modifiers">Modifiers</a></li>
|
||||
<li><a href="#observers">Observers</a></li>
|
||||
<li><a href="#set_operations">Set operations</a></li>
|
||||
@@ -97,8 +96,6 @@ their associated <a href="#ord_indices">ordered index</a> classes.
|
||||
<code>"boost/multi_index/ordered_index.hpp"</code></a> synopsis</a></h2>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=preprocessor>#include</span> <span class=special><</span><span class=identifier>initializer_list</span><span class=special>></span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>multi_index</span><span class=special>{</span>
|
||||
@@ -192,17 +189,15 @@ together, with minor differences explicitly stated when they exist.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Except where noted or if the corresponding interface does not exist,
|
||||
ordered indices (both unique and non-unique) satisfy the C++ requirements
|
||||
for associative containers at <b>[associative.reqmts]</b>
|
||||
(supporting unique and equivalent keys, respectively.)
|
||||
Iterators (including to the end of the index) and pointers and references to an element
|
||||
remain valid during the lifetime of the associated container (which can change
|
||||
upon swapping), or until the referred-to element is erased or extracted;
|
||||
pointers and references to an extracted element, but not so for iterators,
|
||||
become valid again once the element is re-inserted.
|
||||
We only provide descriptions of those types and operations that
|
||||
do not exactly conform to or are not mandated by the standard requirements.
|
||||
Except where noted, ordered indices (both unique and non-unique) are models of
|
||||
<a href="http://www.sgi.com/tech/stl/SortedAssociativeContainer.html">
|
||||
<code>Sorted Associative Container</code></a> and
|
||||
<a href="http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html">
|
||||
<code>Unique Associative Container</code></a>, much as <code>std::set</code>s
|
||||
are. Accordingly, validity of iterators and references to elements is
|
||||
preserved. 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>
|
||||
|
||||
<blockquote><pre>
|
||||
@@ -210,7 +205,7 @@ do not exactly conform to or are not mandated by the standard requirements.
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>multi_index</span><span class=special>{</span>
|
||||
|
||||
<b>implementation defined </b><span class=identifier>unbounded</span><span class=special>;</span> <span class=comment>// see range()</span>
|
||||
<span class=keyword>namespace</span><span class=special>{</span> <b>implementation defined </b><span class=identifier>unbounded</span><span class=special>;</span> <span class=special>}</span> <span class=comment>// see range()</span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>detail</span><span class=special>{</span>
|
||||
|
||||
@@ -226,8 +221,7 @@ do not exactly conform to or are not mandated by the standard requirements.
|
||||
<span class=keyword>typedef</span> <span class=identifier>KeyFromValue</span> <span class=identifier>key_from_value</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>Compare</span> <span class=identifier>key_compare</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined </b><span class=identifier>value_compare</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>tuple</span><span class=special><</span><span class=identifier>key_from_value</span><span class=special>,</span><span class=identifier>key_compare</span><span class=special>></span> <span class=identifier>ctor_args</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>TagList</span> <span class=identifier>tag_list</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>tuple</span><span class=special><</span><span class=identifier>key_from_value</span><span class=special>,</span><span class=identifier>key_compare</span><span class=special>></span> <span class=identifier>ctor_args</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>Allocator</span> <span class=identifier>allocator_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>Allocator</span><span class=special>::</span><span class=identifier>reference</span> <span class=identifier>reference</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>Allocator</span><span class=special>::</span><span class=identifier>const_reference</span> <span class=identifier>const_reference</span><span class=special>;</span>
|
||||
@@ -241,74 +235,47 @@ do not exactly conform to or are not mandated by the standard requirements.
|
||||
std::reverse_iterator<iterator></b> <span class=identifier>reverse_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>equivalent to
|
||||
std::reverse_iterator<const_iterator></b> <span class=identifier>const_reverse_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>same as owning container </b><span class=identifier>node_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>following [container.insert.return] spec </b><span class=identifier>insert_return_type</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// construct/copy/destroy:</span>
|
||||
|
||||
<b>index class name</b><span class=special>&</span> <span class=keyword>operator</span><span class=special>=(</span><span class=keyword>const</span> <b>index class name</b><span class=special>&</span> <span class=identifier>x</span><span class=special>);</span>
|
||||
<b>index class name</b><span class=special>&</span> <span class=keyword>operator</span><span class=special>=(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special><</span><span class=identifier>value_type</span><span class=special>></span> <span class=identifier>list</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=keyword>noexcept</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=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>iterator</span> <span class=identifier>end</span><span class=special>()</span><span class=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>reverse_iterator</span> <span class=identifier>rbegin</span><span class=special>()</span><span class=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>reverse_iterator</span> <span class=identifier>rend</span><span class=special>()</span><span class=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_iterator</span> <span class=identifier>cbegin</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_iterator</span> <span class=identifier>cend</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_reverse_iterator</span> <span class=identifier>crbegin</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_reverse_iterator</span> <span class=identifier>crend</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</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=identifier>iterator</span> <span class=identifier>iterator_to</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>const_iterator</span> <span class=identifier>iterator_to</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>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=keyword>noexcept</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=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</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=keyword>template</span><span class=special><</span><span class=keyword>typename</span><span class=special>...</span> <span class=identifier>Args</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> <span class=identifier>emplace</span><span class=special>(</span><span class=identifier>Args</span><span class=special>&&...</span> <span class=identifier>args</span><span class=special>);</span>
|
||||
<span class=keyword>template</span> <span class=special><</span><span class=keyword>typename</span><span class=special>...</span> <span class=identifier>Args</span><span class=special>></span>
|
||||
<span class=identifier>iterator</span> <span class=identifier>emplace_hint</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Args</span><span class=special>&&...</span> <span class=identifier>args</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> <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>
|
||||
<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>value_type</span><span class=special>&&</span> <span class=identifier>x</span><span class=special>);</span>
|
||||
<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>
|
||||
<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=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>typename</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>
|
||||
<span class=keyword>void</span> <span class=identifier>insert</span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special><</span><span class=identifier>value_type</span><span class=special>></span> <span class=identifier>list</span><span class=special>);</span>
|
||||
<span class=identifier>insert_return_type</span> <span class=identifier>insert</span><span class=special>(</span><span class=identifier>node_type</span><span class=special>&&</span> <span class=identifier>nh</span><span class=special>);</span>
|
||||
<span class=identifier>iterator</span> <span class=identifier>insert</span><span class=special>(</span><span class=identifier>const_iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>node_type</span><span class=special>&&</span> <span class=identifier>nh</span><span class=special>);</span>
|
||||
|
||||
<span class=identifier>node_type</span> <span class=identifier>extract</span><span class=special>(</span><span class=identifier>const_iterator</span> <span class=identifier>position</span><span class=special>);</span>
|
||||
<span class=identifier>node_type</span> <span class=identifier>extract</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=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>
|
||||
<span class=identifier>size_type</span> <span class=identifier>erase</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=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>
|
||||
|
||||
<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>
|
||||
<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=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>typename</span> <span class=identifier>Modifier</span><span class=special>></span> <span class=keyword>bool</span> <span class=identifier>modify</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Modifier</span> <span class=identifier>mod</span><span class=special>);</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Modifier</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Rollback</span><span class=special>></span>
|
||||
<span class=keyword>bool</span> <span class=identifier>modify</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Modifier</span> <span class=identifier>mod</span><span class=special>,</span><span class=identifier>Rollback</span> <span class=identifier>back</span><span class=special>);</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Modifier</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>Modifier</span> <span class=identifier>mod</span><span class=special>);</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Modifier</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Rollback</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>Modifier</span> <span class=identifier>mod</span><span class=special>,</span><span class=identifier>Rollback</span> <span class=identifier>back</span><span class=special>);</span>
|
||||
|
||||
<span class=keyword>void</span> <span class=identifier>swap</span><span class=special>(</span><b>index class name</b><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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=keyword>void</span> <span class=identifier>clear</span><span class=special>();</span>
|
||||
|
||||
<span class=comment>// observers:</span>
|
||||
|
||||
@@ -428,7 +395,7 @@ section</a>. The complexity signature of ordered indices is:
|
||||
<li>copying: <code>c(n)=n*log(n)</code>,</li>
|
||||
<li>insertion: <code>i(n)=log(n)</code>,</li>
|
||||
<li>hinted insertion: <code>h(n)=1</code> (constant) if the hint element
|
||||
is immediately after the point of insertion, <code>h(n)=log(n)</code> otherwise,</li>
|
||||
precedes the point of insertion, <code>h(n)=log(n)</code> otherwise,</li>
|
||||
<li>deletion: <code>d(n)=1</code> (amortized constant),</li>
|
||||
<li>replacement: <code>r(n)=1</code> (constant) if the element position does not
|
||||
change, <code>r(n)=log(n)</code> otherwise,</li>
|
||||
@@ -447,7 +414,7 @@ following types:
|
||||
<ul>
|
||||
<li><code>Value</code> from <code>multi_index_container</code>,</li>
|
||||
<li><code>Allocator</code> from <code>multi_index_container</code>,</li>
|
||||
<li><code>TagList</code> from the index specifier (if provided, otherwise <code>tag<></code> is assumed),</li>
|
||||
<li><code>TagList</code> from the index specifier (if provided),</li>
|
||||
<li><code>KeyFromValue</code> from the index specifier,</li>
|
||||
<li><code>Compare</code> from the index specifier.</li>
|
||||
</ul>
|
||||
@@ -456,8 +423,9 @@ following types:
|
||||
which determines the mechanism for extracting a key from <code>Value</code>,
|
||||
must be a model of <a href="key_extraction.html#key_extractors">
|
||||
<code>Key Extractor</code></a> from <code>Value</code>. <code>Compare</code> is a
|
||||
<code>CopyConstructible</code> binary predicate inducing a strict weak order
|
||||
on elements of <code>KeyFromValue::result_type</code>.
|
||||
<a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">
|
||||
<code>Strict Weak Ordering</code></a> on elements of
|
||||
<code>KeyFromValue::result_type</code>.
|
||||
</p>
|
||||
|
||||
<h4><a name="constructors">Constructors, copy and assignment</a></h4>
|
||||
@@ -480,91 +448,11 @@ objects to which <code>*this</code> and <code>x</code> belong, respectively.<br>
|
||||
<b>Returns:</b> <code>*this</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code><b>index class name</b>& operator=(std::initializer_list<value_type> list);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>a</span><span class=special>=</span><span class=identifier>list</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
where <code>a</code> is the <code>multi_index_container</code>
|
||||
object to which <code>*this</code> belongs.<br>
|
||||
<b>Returns:</b> <code>*this</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="iterators">Iterators</a></h4>
|
||||
|
||||
<code>iterator iterator_to(const value_type& x);<br>
|
||||
const_iterator iterator_to(const value_type& x)const;</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>x</code> is a reference to an element of the container.<br>
|
||||
<b>Returns:</b> An iterator to <code>x</code>.<br>
|
||||
<b>Complexity:</b> Constant.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="modifiers">Modifiers</a></h4>
|
||||
|
||||
<code>template<typename... Args><br>
|
||||
std::pair<iterator,bool> emplace(Args&&... args);</code>
|
||||
<code>std::pair<iterator,bool> insert(const value_type& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>value_type</code> is <code>EmplaceConstructible</code>
|
||||
into <code>multi_index_container</code> from <code>args</code>.<br>
|
||||
<b>Effects:</b> Inserts a <code>value_type</code> object constructed with
|
||||
<code>std::forward<Args>(args)...</code> into the <code>multi_index_container</code> to which
|
||||
the index belongs if
|
||||
<ul>
|
||||
<li>the index is non-unique OR no other element exists with
|
||||
equivalent key,</li>
|
||||
<li>AND insertion is allowed by all other indices of the
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
<b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
|
||||
is <code>true</code> if and only if insertion took place. On successful insertion,
|
||||
<code>p.first</code> points to the element inserted; otherwise, <code>p.first</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.<br>
|
||||
<b>Complexity:</b> <code>O(I(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename... Args><br>
|
||||
iterator emplace_hint(iterator position, Args&&... args);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>value_type</code> is <code>EmplaceConstructible</code>
|
||||
into <code>multi_index_container</code> from <code>args</code>.
|
||||
<code>position</code> is a valid iterator of the index.<br>
|
||||
<b>Effects:</b> Inserts a <code>value_type</code> object constructed with
|
||||
<code>std::forward<Args>(args)...</code> into the <code>multi_index_container</code> to which
|
||||
the index belongs if
|
||||
<ul>
|
||||
<li>the index is non-unique OR no other element exists with
|
||||
equivalent key,</li>
|
||||
<li>AND insertion is allowed by all other indices of the
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
<code>position</code> is used as a hint to improve the efficiency of the
|
||||
operation. If successful, insertion happens as close as possible to the
|
||||
location just prior to <code>position</code>.<br>
|
||||
<b>Returns:</b> 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.<br>
|
||||
<b>Complexity:</b> <code>O(H(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>std::pair<iterator,bool> insert(const value_type& x);</code><br>
|
||||
<code>std::pair<iterator,bool> insert(value_type&& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires (first version):</b> <code>value_type</code> is <code>CopyInsertable</code>
|
||||
into <code>multi_index_container</code>.<br>
|
||||
<b>Requires (second version):</b> <code>value_type</code> is <code>MoveInsertable</code>
|
||||
into <code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> Inserts <code>x</code> into the <code>multi_index_container</code> to which
|
||||
the index belongs if
|
||||
<ul>
|
||||
@@ -582,16 +470,10 @@ one element can be causing insertion not to be allowed.<br>
|
||||
<b>Exception safety:</b> Strong.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>iterator insert(iterator position,const value_type& x);</code><br>
|
||||
<code>iterator insert(iterator position,value_type&& x);</code>
|
||||
<code>iterator insert(iterator position,const value_type& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires (first version):</b> <code>value_type</code> is <code>CopyInsertable</code>
|
||||
into <code>multi_index_container</code>.
|
||||
<code>position</code> is a valid iterator of the index.<br>
|
||||
<b>Requires (second version):</b> <code>value_type</code> is <code>MoveInsertable</code>
|
||||
into <code>multi_index_container</code>.
|
||||
<code>position</code> is a valid iterator of the index.<br>
|
||||
<b>Requires:</b> <code>position</code> is a valid iterator of the index.</br>
|
||||
<b>Effects:</b> Inserts <code>x</code> into the <code>multi_index_container</code> to which
|
||||
the index belongs if
|
||||
<ul>
|
||||
@@ -601,8 +483,7 @@ the index belongs if
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
<code>position</code> is used as a hint to improve the efficiency of the
|
||||
operation. If successful, insertion happens as close as possible to the
|
||||
location just prior to <code>position</code>.<br>
|
||||
operation.<br>
|
||||
<b>Returns:</b> 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
|
||||
@@ -615,121 +496,29 @@ allowed.<br>
|
||||
void insert(InputIterator first,InputIterator last);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>InputIterator</code> is an input iterator.
|
||||
<code>value_type</code> is <code>EmplaceConstructible</code> into
|
||||
<code>multi_index_container</code> from <code>*first</code>.
|
||||
<b>Requires:</b> <code>InputIterator</code> is a model of
|
||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">
|
||||
<code>Input Iterator</code></a> over elements of type
|
||||
<code>value_type</code> or a type convertible to <code>value_type</code>.
|
||||
<code>first</code> and <code>last</code> are not iterators into any
|
||||
index of the <code>multi_index_container</code> to which this index belongs.
|
||||
<code>last</code> is reachable from <code>first</code>.<br>
|
||||
<code>last</code> is reachable from <code>first</code>.</br>
|
||||
<b>Effects:</b>
|
||||
For each element of [<code>first</code>, <code>last</code>), in this
|
||||
order, inserts it into the <code>multi_index_container</code>
|
||||
to which this index belongs if
|
||||
<ul>
|
||||
<li>the index is non-unique OR no other element exists with
|
||||
equivalent key,</li>
|
||||
<li>AND insertion is allowed by all other indices of the
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>iterator</span> <span class=identifier>hint</span><span class=special>=</span><span class=identifier>end</span><span class=special>();</span>
|
||||
<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=identifier>first</span><span class=special>++);</span>
|
||||
</pre></blockquote>
|
||||
<b>Complexity:</b> <code>O(m*H(n+m))</code>, where
|
||||
<code>m</code> is the number of elements in [<code>first</code>,
|
||||
<code>last</code>).<br>
|
||||
<b>Exception safety:</b> Basic.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>void insert(std::initializer_list<value_type> list);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>insert</span><span class=special>(</span><span class=identifier>list</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>list</span><span class=special>.</span><span class=identifier>end</span><span class=special>())</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
</blockquote>
|
||||
|
||||
<code>insert_return_type insert(node_type&& nh);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>nh.empty() || get_allocator()==nh.get_allocator()</code>.<br>
|
||||
<b>Effects:</b> Does nothing if <code>nh</code> is empty; otherwise,
|
||||
inserts the node owned by <code>nh</code> into the
|
||||
<code>multi_index_container</code> to which the index belongs if
|
||||
<ul>
|
||||
<li>the index is non-unique OR no other element exists with
|
||||
equivalent key,</li>
|
||||
<li>AND insertion is allowed by all other indices of the
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
<b>Postconditions:</b> <code>nh</code> is empty.<br>
|
||||
<b>Returns:</b> A value <code>p</code> of type <code>insert_return_type</code>.
|
||||
If <code>nh</code> is empty, <code>p.position</code> is <code>end()</code>,
|
||||
<code>p.inserted</code> is <code>false</code> and <code>p.node</code> is empty;
|
||||
on successful insertion, <code>p.position</code> points to the element inserted,
|
||||
<code>p.inserted</code> is <code>true</code> and <code>p.node</code>
|
||||
is empty;
|
||||
if the insertion failed, <code>p.position</code> points to an element that caused
|
||||
the insertion to be banned, <code>p.inserted</code> is <code>false</code> and
|
||||
<code>p.node</code> owns the original node.
|
||||
Note that more than one element can be causing insertion not to be allowed.<br>
|
||||
<b>Complexity:</b> <code>O(I(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong. If an exception
|
||||
is thrown, <code>nh</code> is not changed.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>iterator insert(const_iterator position,node_type&& nh);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>nh.empty() || get_allocator()==nh.get_allocator()</code>.
|
||||
<code>position</code> is a valid iterator of the index.<br>
|
||||
<b>Effects:</b> Does nothing if <code>nh</code> is empty; otherwise,
|
||||
inserts the node owned by <code>nh</code> into the
|
||||
<code>multi_index_container</code> to which the index belongs if
|
||||
<ul>
|
||||
<li>the index is non-unique OR no other element exists with
|
||||
equivalent key,</li>
|
||||
<li>AND insertion is allowed by all other indices of the
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
<code>position</code> is used as a hint to improve the efficiency of the
|
||||
operation. If successful, insertion happens as close as possible to the
|
||||
location just prior to <code>position</code>.<br>
|
||||
<b>Postconditions:</b> <code>nh</code> is empty if insertion succeeds,
|
||||
and is not changed otherwise.<br>
|
||||
<b>Returns:</b> <code>end()</code> if <code>nh</code> is empty.
|
||||
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.<br>
|
||||
<b>Complexity:</b> <code>O(H(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong. If an exception
|
||||
is thrown, <code>nh</code> is not changed.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>node_type extract(const_iterator position);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid dereferenceable iterator
|
||||
of the index.<br>
|
||||
<b>Effects:</b> Extracts the node of the element pointed to by <code>position</code>.<br>
|
||||
<b>Returns:</b> A node handle owning the extracted node.<br>
|
||||
<b>Complexity:</b> <code>O(D(n))</code>.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>node_type extract(const key_type& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b> Extracts the node of the first element
|
||||
with key equivalent to <code>x</code>, if there is any.<br>
|
||||
<b>Returns:</b> A node handle owning the extracted node, or empty otherwise.<br>
|
||||
<b>Complexity:</b> <code>O(log(n) + D(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>iterator erase(iterator position);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid dereferenceable iterator
|
||||
of the index.<br>
|
||||
<b>Requires:</b> <code>position</code> is a valid dereferenceable iterator
|
||||
of the index.</br>
|
||||
<b>Effects:</b> Deletes the element pointed to by <code>position</code>.<br>
|
||||
<b>Returns:</b> An iterator pointing to the element immediately following
|
||||
the one that was deleted, or <code>end()</code>
|
||||
@@ -760,14 +549,11 @@ the number of elements in [<code>first</code>,<code>last</code>).<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<a name="replace"><code>bool replace(iterator position,const value_type& x);</code></a><br>
|
||||
<code>bool replace(iterator position,value_type&& x);</code>
|
||||
<a name="replace"><code>bool replace(iterator position,const value_type& x);</code></a>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires (first version):</b> <code>value_type</code> is <code>CopyAssignable</code>.
|
||||
<code>position</code> is a valid dereferenceable iterator of the index.<br>
|
||||
<b>Requires (second version):</b> <code>value_type</code> is <code>MoveAssignable</code>.
|
||||
<code>position</code> is a valid dereferenceable iterator of the index.<br>
|
||||
<b>Requires:</b> <code>position</code> is a valid dereferenceable iterator
|
||||
of the index.</br>
|
||||
<b>Effects:</b> Assigns the value <code>x</code> to the element pointed
|
||||
to by <code>position</code> into the <code>multi_index_container</code> to which
|
||||
the index belongs if, for the value <code>x</code>
|
||||
@@ -778,8 +564,7 @@ the index belongs if, for the value <code>x</code>
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
<b>Postconditions:</b> Validity of <code>position</code> is preserved
|
||||
in all cases. If the key of the new value is equivalent to that of the
|
||||
replaced value, the position of the element does not change.<br>
|
||||
in all cases.<br>
|
||||
<b>Returns:</b> <code>true</code> if the replacement took place,
|
||||
<code>false</code> otherwise.<br>
|
||||
<b>Complexity:</b> <code>O(R(n))</code>.<br>
|
||||
@@ -792,14 +577,11 @@ belongs remains in its original state.
|
||||
<code>template<typename Modifier> bool modify(iterator position,Modifier mod);</code></a>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>mod</code> is a unary function object
|
||||
accepting arguments of type
|
||||
<b>Requires:</b> <code>Modifier</code> is a model of
|
||||
<a href="http://www.sgi.com/tech/stl/UnaryFunction.html">
|
||||
<code>Unary Function</code></a> accepting arguments of type
|
||||
<code>value_type&</code>. <code>position</code> is a valid dereferenceable
|
||||
iterator of the index.
|
||||
The execution of <code>mod(e)</code>, where <code>e</code> is the element
|
||||
pointed to by <code>position</code>, does not invoke any operation of the
|
||||
<code>multi_index_container</code> after <code>e</code> is directly modified
|
||||
or, before modification, if the operation would invalidate <code>position</code>.<br>
|
||||
iterator of the index.</br>
|
||||
<b>Effects:</b> Calls <code>mod(e)</code> where <code>e</code> is the element
|
||||
pointed to by <code>position</code> and rearranges <code>*position</code> into
|
||||
all the indices of the <code>multi_index_container</code>. Rearrangement is successful if
|
||||
@@ -811,99 +593,46 @@ all the indices of the <code>multi_index_container</code>. Rearrangement is succ
|
||||
</ul>
|
||||
If the rearrangement fails, the element is erased.<br>
|
||||
<b>Postconditions:</b> Validity of <code>position</code> is preserved if the
|
||||
operation succeeds. If the key of the modified value is equivalent to that of the
|
||||
original value, the position of the element does not change.<br>
|
||||
operation succeeds.<br>
|
||||
<b>Returns:</b> <code>true</code> if the operation succeeded, <code>false</code>
|
||||
otherwise.<br>
|
||||
<b>Complexity:</b> <code>O(M(n))</code>.<br>
|
||||
<b>Exception safety:</b> Basic. If an exception is thrown by some
|
||||
user-provided operation (including <code>mod</code>), then
|
||||
user-provided operation (except possibly <code>mod</code>), then
|
||||
the element pointed to by <code>position</code> is erased.
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename Modifier,typename Rollback><br>
|
||||
bool modify(iterator position,Modifier mod,Rollback back);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>mod</code> and <code>back</code> are unary function
|
||||
objects accepting arguments of type
|
||||
<code>value_type&</code>. <code>position</code> is a valid dereferenceable
|
||||
iterator of the index.
|
||||
The execution of <code>mod(e)</code>, where <code>e</code> is the element
|
||||
pointed to by <code>position</code>, does not invoke any operation of the
|
||||
<code>multi_index_container</code> after <code>e</code> is directly modified
|
||||
or, before modification, if the operation would invalidate <code>position</code>.
|
||||
<code>back(e)</code> does not invoke any operation of the
|
||||
<code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> Calls <code>mod(e)</code> where <code>e</code> is the element
|
||||
pointed to by <code>position</code> and tries to rearrange <code>*position</code> into
|
||||
all the indices of the <code>multi_index_container</code>. Rearrangement is successful if
|
||||
<ul>
|
||||
<li>the index is non-unique OR no other element exists
|
||||
with equivalent key,</li>
|
||||
<li>AND rearrangement is allowed by all other indices of the
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
If the rearrangement fails, <code>back(e)</code> is invoked: if the resulting value
|
||||
of <code>e</code> is consistent with its original position and constraints in all
|
||||
indices, the element is kept, otherwise it is erased.<br>
|
||||
<b>Postconditions:</b> Validity of <code>position</code> is preserved except if
|
||||
the element is erased under the conditions described below.
|
||||
If the key of the modified value is equivalent to that of the
|
||||
original value, the position of the element does not change.<br>
|
||||
<b>Returns:</b> <code>true</code> if the operation succeeded, <code>false</code>
|
||||
otherwise.<br>
|
||||
<b>Complexity:</b> <code>O(M(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong, except if <code>mod</code> or <code>back</code> throw an
|
||||
exception or <code>back(e)</code> fails to properly restore the element or there is
|
||||
a throwing user-provided operation after invoking <code>back(e)</code>, in which cases
|
||||
the modified element is erased. If <code>back</code>
|
||||
throws inside the handling code executing after some other user-provided
|
||||
operation has thrown, it is the exception generated by <code>back</code> that
|
||||
is rethrown.
|
||||
</blockquote>
|
||||
|
||||
<a name="modify_key">
|
||||
<code>template<typename Modifier> bool modify_key(iterator position,Modifier mod);</code></a>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>key_from_value</code> is a read/write
|
||||
<a href="key_extraction.html#key_extractors"><code>Key Extractor</code></a>
|
||||
from <code>value_type</code>. <code>mod</code> is a
|
||||
unary function object accepting arguments of type
|
||||
from <code>value_type</code>. <code>Modifier</code> is a model of
|
||||
<a href="http://www.sgi.com/tech/stl/UnaryFunction.html">
|
||||
<code>Unary Function</code></a> accepting arguments of type
|
||||
<code>key_type&</code>. <code>position</code> is a valid dereferenceable
|
||||
iterator of the index.
|
||||
The execution of <code>mod(k)</code>, where <code>k</code> is the key of the element
|
||||
pointed to by <code>position</code>, does not invoke any operation of the
|
||||
<code>multi_index_container</code> after <code>k</code> is directly modified
|
||||
or, before modification, if the operation would invalidate <code>position</code>.<br>
|
||||
<b>Effects:</b> Equivalent to <code>modify(position,mod')</code>,
|
||||
with <code>mod'</code> defined in such a way that
|
||||
<code>mod'(x)</code> is the same as <code>mod(key(x))</code>, where
|
||||
<code>key</code> is the internal <code>KeyFromValue</code> object of the index.
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename Modifier,typename Rollback><br>
|
||||
bool modify_key(iterator position,Modifier mod,Rollback back);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>key_from_value</code> is a read/write
|
||||
<a href="key_extraction.html#key_extractors"><code>Key Extractor</code></a>
|
||||
from <code>value_type</code>. <code>mod</code> and <code>back</code>
|
||||
are unary function objects accepting arguments of type
|
||||
<code>key_type&</code>. <code>position</code> is a valid dereferenceable
|
||||
iterator of the index.
|
||||
The execution of <code>mod(k)</code>, where <code>k</code> is the key of the element
|
||||
pointed to by <code>position</code>, does not invoke any operation of the
|
||||
<code>multi_index_container</code> after <code>k</code> is directly modified
|
||||
or, before modification, if the operation would invalidate <code>position</code>.
|
||||
<code>back(k)</code> does not invoke any operation of the
|
||||
<code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> Equivalent to <code>modify(position,mod',back')</code>,
|
||||
with <code>mod'</code> and <code>back</code> defined in such a way that
|
||||
<code>mod'(x)</code> is the same as <code>mod(key(x))</code> and
|
||||
<code>back'(x)</code> is the same as <code>back(key(x))</code>, where
|
||||
<code>key</code> is the internal <code>KeyFromValue</code> object of the index.
|
||||
iterator of the index.</br>
|
||||
<b>Effects:</b> Calls <code>mod(k)</code> where <code>k</code> is the key
|
||||
obtained by the internal <code>KeyFromValue</code> object of the index from
|
||||
the element pointed to by <code>position</code>, and rearranges
|
||||
<code>*position</code> into all the indices of the <code>multi_index_container</code>.
|
||||
Rearrangement is successful if
|
||||
<ul>
|
||||
<li>the index is non-unique OR no other element exists
|
||||
with equivalent key,</li>
|
||||
<li>AND rearrangement is allowed by all other indices of the
|
||||
<code>multi_index_container</code>.</li>
|
||||
</ul>
|
||||
If the rearrangement fails, the element is erased.<br>
|
||||
<b>Postconditions:</b>Validity of <code>position</code> is preserved if
|
||||
the operation succeeds.<br>
|
||||
<b>Returns:</b> <code>true</code> if the operation succeeded, <code>false</code>
|
||||
otherwise.<br>
|
||||
<b>Complexity:</b> <code>O(M(n))</code>.<br>
|
||||
<b>Exception safety:</b> Basic. If an exception is thrown by some
|
||||
user-provided operation (except possibly <code>mod</code>), then
|
||||
the element pointed to by <code>position</code> is erased.
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="observers">Observers</a></h4>
|
||||
@@ -925,7 +654,10 @@ the index.<br>
|
||||
|
||||
<p>
|
||||
Ordered indices provide the full lookup functionality required by
|
||||
<b>[associative.reqmts]</b>, namely <code>find</code>,
|
||||
<a href="http://www.sgi.com/tech/stl/SortedAssociativeContainer.html">
|
||||
<code>Sorted Associative Containers</code></a> and
|
||||
<a href="http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html">
|
||||
<code>Unique Associative Containers</code></a>, namely <code>find</code>,
|
||||
<code>count</code>, <code>lower_bound</code>, <code>upper_bound</code>
|
||||
and <code>equal_range</code>. Additionally, these member functions are
|
||||
templatized to allow for non-standard arguments, so extending
|
||||
@@ -935,14 +667,20 @@ concept.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Consider a binary predicate <code>Compare</code> inducing a strict
|
||||
weak order over values of type <code>Key</code>. A pair of types (<code>CompatibleKey</code>,
|
||||
Consider a
|
||||
<a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">
|
||||
<code>Strict Weak Ordering</code></a> <code>Compare</code> over values
|
||||
of type <code>Key</code>. A pair of types (<code>CompatibleKey</code>,
|
||||
<code>CompatibleCompare</code>) is said to be a <i>compatible extension</i>
|
||||
of <code>Compare</code> if
|
||||
<ol>
|
||||
<li><code>CompatibleCompare</code> is a binary predicate over (<code>Key</code>,
|
||||
<li><code>CompatibleCompare</code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/BinaryPredicate.html">
|
||||
<code>Binary Predicate</code></a> over (<code>Key</code>,
|
||||
<code>CompatibleKey</code>),</li>
|
||||
<li><code>CompatibleCompare</code> is a binary predicate over (<code>CompatibleKey</code>,
|
||||
<li><code>CompatibleCompare</code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/BinaryPredicate.html">
|
||||
<code>Binary Predicate</code></a> over (<code>CompatibleKey</code>,
|
||||
<code>Key</code>),</li>
|
||||
<li>if <code>c_comp(ck,k1)</code> then <code>!c_comp(k1,ck)</code>,</li>
|
||||
<li>if <code>!c_comp(ck,k1)</code> and <code>!comp(k1,k2)</code> then
|
||||
@@ -977,7 +715,7 @@ interpretations.
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
|
||||
<code>key_compare</code>.<br>
|
||||
<code>key_compare</code>.</br>
|
||||
<b>Effects:</b> Returns a pointer to an element whose key is equivalent to
|
||||
<code>x</code>, or <code>end()</code> if such an element does not exist.<br>
|
||||
<b>Complexity:</b> <code>O(log(n))</code>.<br>
|
||||
@@ -989,7 +727,7 @@ iterator find(const CompatibleKey& x,const CompatibleCompare& comp)const
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleCompare</code>)
|
||||
is a compatible extension of <code>key_compare</code>.<br>
|
||||
is a compatible extension of <code>key_compare</code>.</br>
|
||||
<b>Effects:</b> Returns a pointer to an element whose key is equivalent to
|
||||
<code>x</code>, or <code>end()</code> if such an element does not exist.<br>
|
||||
<b>Complexity:</b> <code>O(log(n))</code>.<br>
|
||||
@@ -1001,7 +739,7 @@ count(const CompatibleKey& x)const;
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
|
||||
<code>key_compare</code>.<br>
|
||||
<code>key_compare</code>.</br>
|
||||
<b>Effects:</b> Returns the number of elements with key equivalent to <code>x</code>.<br>
|
||||
<b>Complexity:</b> <code>O(log(n) + count(x))</code>.<br>
|
||||
</blockquote>
|
||||
@@ -1012,7 +750,7 @@ size_type count(const CompatibleKey& x,const CompatibleCompare& comp)con
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleCompare</code>)
|
||||
is a compatible extension of <code>key_compare</code>.<br>
|
||||
is a compatible extension of <code>key_compare</code>.</br>
|
||||
<b>Effects:</b> Returns the number of elements with key equivalent to <code>x</code>.<br>
|
||||
<b>Complexity:</b> <code>O(log(n) + count(x,comp))</code>.<br>
|
||||
</blockquote>
|
||||
@@ -1023,7 +761,7 @@ iterator lower_bound(const CompatibleKey& x)const;
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
|
||||
<code>key_compare</code>.<br>
|
||||
<code>key_compare</code>.</br>
|
||||
<b>Effects:</b> Returns an iterator pointing to the first element with
|
||||
key not less than <code>x</code>, or <code>end()</code> if such an element does
|
||||
not exist.<br>
|
||||
@@ -1036,7 +774,7 @@ iterator lower_bound(const CompatibleKey& x,const CompatibleCompare& com
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleCompare</code>)
|
||||
is a compatible extension of <code>key_compare</code>.<br>
|
||||
is a compatible extension of <code>key_compare</code>.</br>
|
||||
<b>Effects:</b> Returns an iterator pointing to the first element with
|
||||
key not less than <code>x</code>, or <code>end()</code> if such an element does
|
||||
not exist.<br>
|
||||
@@ -1049,7 +787,7 @@ iterator upper_bound(const CompatibleKey& x)const;
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
|
||||
<code>key_compare</code>.<br>
|
||||
<code>key_compare</code>.</br>
|
||||
<b>Effects:</b> Returns an iterator pointing to the first element with
|
||||
key greater than <code>x</code>, or <code>end()</code> if such an element does
|
||||
not exist.<br>
|
||||
@@ -1062,7 +800,7 @@ iterator upper_bound(const CompatibleKey& x,const CompatibleCompare& com
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleCompare</code>)
|
||||
is a compatible extension of <code>key_compare</code>.<br>
|
||||
is a compatible extension of <code>key_compare</code>.</br>
|
||||
<b>Effects:</b> Returns an iterator pointing to the first element with
|
||||
key greater than <code>x</code>, or <code>end()</code> if such an element does
|
||||
not exist.<br>
|
||||
@@ -1076,19 +814,19 @@ std::pair<iterator,iterator> equal_range(<br>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
|
||||
<code>key_compare</code>.<br>
|
||||
<code>key_compare</code>.</br>
|
||||
<b>Effects:</b> Equivalent to <code>make_pair(lower_bound(x),upper_bound(x))</code>.<br>
|
||||
<b>Complexity:</b> <code>O(log(n))</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename CompatibleKey,typename CompatibleCompare><br>
|
||||
std::pair<iterator,iterator> equal_range(<br>
|
||||
std::pair<iterator,iterator> equal_range(</br>
|
||||
const CompatibleKey& x,const CompatibleCompare& comp)const;
|
||||
</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleCompare</code>)
|
||||
is a compatible extension of <code>key_compare</code>.<br>
|
||||
is a compatible extension of <code>key_compare</code>.</br>
|
||||
<b>Effects:</b> Equivalent to
|
||||
<code>make_pair(lower_bound(x,comp),upper_bound(x,comp))</code>.<br>
|
||||
<b>Complexity:</b> <code>O(log(n))</code>.<br>
|
||||
@@ -1105,11 +843,15 @@ are modeled after the following concepts.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Consider a binary predicate <code>Compare</code> inducing a strict
|
||||
weak order over values of type <code>Key</code>. A type <code>LowerBounder</code> is said to be
|
||||
Consider a
|
||||
<a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">
|
||||
<code>Strict Weak Ordering</code></a> <code>Compare</code> over values
|
||||
of type <code>Key</code>. A type <code>LowerBounder</code> is said to be
|
||||
a <i>lower bounder</i> of <code>Compare</code> if
|
||||
<ol>
|
||||
<li><code>LowerBounder</code> is a predicate over <code>Key</code>,</li>
|
||||
<li><code>LowerBounder</code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/Predicate.html">
|
||||
<code>Predicate</code></a> over <code>Key</code>,</li>
|
||||
<li>if <code>lower(k1)</code> and <code>!comp(k2,k1)</code> then
|
||||
<code>lower(k2)</code>,</li>
|
||||
</ol>
|
||||
@@ -1118,7 +860,9 @@ for every <code>lower</code> of type <code>LowerBounder</code>,
|
||||
<code>k2</code> of type <code>Key</code>. Similarly, an <i>upper bounder</i>
|
||||
is a type <code>UpperBounder</code> such that
|
||||
<ol>
|
||||
<li><code>UpperBounder</code> is a predcate over <code>Key</code>,</li>
|
||||
<li><code>UpperBounder</code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/Predicate.html">
|
||||
<code>Predicate</code></a> over <code>Key</code>,</li>
|
||||
<li>if <code>upper(k1)</code> and <code>!comp(k1,k2)</code> then
|
||||
<code>upper(k2)</code>,</li>
|
||||
</ol>
|
||||
@@ -1134,7 +878,7 @@ std::pair<iterator,iterator> range(<br>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>LowerBounder</code> and <code>UpperBounder</code> are
|
||||
a lower and upper bounder of <code>key_compare</code>, respectively.<br>
|
||||
a lower and upper bounder of <code>key_compare</code>, respectively.</br>
|
||||
<b>Effects:</b> Returns a pair of iterators pointing to the beginning and one
|
||||
past the end of the subsequence of elements satisfying <code>lower</code> and
|
||||
<code>upper</code> simultaneously. If no such elements exist, the iterators
|
||||
@@ -1172,7 +916,7 @@ input archive (XML archive) <code>ar</code>.
|
||||
<b>Requires:</b> Additionally to the general requirements, <code>value_comp()</code>
|
||||
must be serialization-compatible with <code>m.get<i>().value_comp()</code>,
|
||||
where <code>i</code> is the position of the ordered index in the container.<br>
|
||||
<b>Postconditions:</b> On successful loading, each of the elements of
|
||||
<b>Postconditions:</b> On succesful loading, each of the elements of
|
||||
[<code>begin()</code>, <code>end()</code>) is a restored copy of the corresponding
|
||||
element in [<code>m.get<i>().begin()</code>, <code>m.get<i>().end()</code>).
|
||||
</blockquote>
|
||||
@@ -1189,7 +933,7 @@ Operation: loading of an <code>iterator</code> or <code>const_iterator</code>
|
||||
<code>it'</code> from an input archive (XML archive) <code>ar</code>.
|
||||
|
||||
<blockquote>
|
||||
<b>Postconditions:</b> On successful loading, if <code>it</code> was dereferenceable
|
||||
<b>Postconditions:</b> On succesful loading, if <code>it</code> was dereferenceable
|
||||
then <code>*it'</code> is the restored copy of <code>*it</code>, otherwise
|
||||
<code>it'==end()</code>.<br>
|
||||
<b>Note:</b> It is allowed that <code>it</code> be a <code>const_iterator</code>
|
||||
@@ -1204,15 +948,15 @@ Index reference
|
||||
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.MultiIndex reference" border="0"><br>
|
||||
Boost.MultiIndex reference
|
||||
</a></div>
|
||||
<div class="next_link"><a href="rnk_indices.html"><img src="../next.gif" alt="ranked indices" border="0"><br>
|
||||
Ranked indices
|
||||
<div class="next_link"><a href="hash_indices.html"><img src="../next.gif" alt="hashed indices" border="0"><br>
|
||||
Hashed indices
|
||||
</a></div><br clear="all" style="clear: all;">
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised May 9th 2020</p>
|
||||
<p>Revised March 31st 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2020 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
+121
-335
@@ -41,7 +41,6 @@ Key extraction
|
||||
<li><a href="#complexity_signature">Complexity signature</a></li>
|
||||
<li><a href="#instantiation_types">Instantiation types</a></li>
|
||||
<li><a href="#constructors">Constructors, copy and assignment</a></li>
|
||||
<li><a href="#iterators">Iterators</a></li>
|
||||
<li><a href="#capacity">Capacity operations</a></li>
|
||||
<li><a href="#modifiers">Modifiers</a></li>
|
||||
<li><a href="#list_operations">List operations</a></li>
|
||||
@@ -92,8 +91,6 @@ its associated <a href="#rnd_indices">random access index</a> class.
|
||||
<code>"boost/multi_index/random_access_index.hpp"</code></a> synopsis</a></h2>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=preprocessor>#include</span> <span class=special><</span><span class=identifier>initializer_list</span><span class=special>></span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>multi_index</span><span class=special>{</span>
|
||||
@@ -158,40 +155,38 @@ random access indices includes that of
|
||||
<a href="seq_indices.html">sequenced indices</a>, with differences in
|
||||
the complexity of the operations, plus extra operations for
|
||||
positional access (<code>operator[]</code> and <code>at()</code>) and
|
||||
for capacity handling.
|
||||
Iterators (including to the end of the index) and pointers and references to an element
|
||||
remain valid during the lifetime of the associated container (which can change
|
||||
upon swapping) regardless of the capacity status, or until the referred-to element
|
||||
is erased or extracted; pointers and references to an extracted element,
|
||||
but not so for iterators, become valid again once the element is re-inserted.
|
||||
for capacity handling. Validity of iterators and references to elements
|
||||
is preserved in all operations, regardless of the capacity status.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Except where noted or if the corresponding interface does not exist, random access
|
||||
indices verify the same container requirements as <code>std::vector</code>
|
||||
plus the requirements for <code>std::list</code> specific list operations at
|
||||
<b>[list.ops]</b>. Some of the most important differences with respect to
|
||||
<code>std::vector</code> are:
|
||||
As is the case with sequenced indices, random access indices have the
|
||||
following limitations with respect to STL sequence containers:
|
||||
<ul>
|
||||
<li>Random access indices do not provide memory contiguity, and hence do not
|
||||
have <code>data</code> member functions.
|
||||
</li>
|
||||
|
||||
<li>The complexity of some operations, notably insertion and deletion, differ
|
||||
from those of <code>std::vector</code>.
|
||||
</li>
|
||||
<li>Unlike as in <code>std::vector</code>, insertions into a random access index
|
||||
may fail due to clashings with other indices. This alters the semantics
|
||||
of the operations provided with respect to their analogues in
|
||||
<code>std::vector</code>.
|
||||
<li>Random access indices are not <a href="http://www.sgi.com/tech/stl/Assignable.html">
|
||||
<code>Assignable</code></a> (like any other index.)</li>
|
||||
<li>Insertions into a random access index may fail due to clashings
|
||||
with other indices. This alters the semantics of the operations
|
||||
provided with respect to their analogues in STL sequence containers.
|
||||
</li>
|
||||
<li>Elements in a random access index are not mutable, and can only be changed
|
||||
in place by means of <a href="#replace"><code>replace</code></a> and
|
||||
by means of <a href="#replace"><code>replace</code></a> and
|
||||
<a href="#modify"><code>modify</code></a> member functions.
|
||||
</li>
|
||||
<li><code>push_front</code> and <code>pop_front</code> are provided for
|
||||
compatibility with sequenced indices, even though they take linear time to execute.
|
||||
</li></ul>
|
||||
</ul>
|
||||
Having these restrictions into account, random access indices are models
|
||||
of <a href="http://www.sgi.com/tech/stl/RandomAccessContainer.html">
|
||||
<code>Random Access Container</code></a> and
|
||||
<a href="http://www.sgi.com/tech/stl/BackInsertionSequence.html">
|
||||
<code>Back Insertion Sequence</code></a>. Although these indices do
|
||||
not model
|
||||
<a href="http://www.sgi.com/tech/stl/FrontInsertionSequence.html">
|
||||
<code>Front Insertion Sequence</code></a>, because front insertion
|
||||
and deletion take linear time, front operations are nonetheless provided
|
||||
to match the interface of sequenced indices.
|
||||
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>
|
||||
|
||||
<blockquote><pre>
|
||||
@@ -207,66 +202,52 @@ plus the requirements for <code>std::list</code> specific list operations at
|
||||
<span class=keyword>public</span><span class=special>:</span>
|
||||
<span class=comment>// types:</span>
|
||||
|
||||
<span class=keyword>typedef</span> <span class=identifier>Value</span> <span class=identifier>value_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>tuples</span><span class=special>::</span><span class=identifier>null_type</span> <span class=identifier>ctor_args</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>TagList</span> <span class=identifier>tag_list</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>Allocator</span> <span class=identifier>allocator_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>node_type</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=identifier>tuples</span><span class=special>::</span><span class=identifier>null_type</span> <span class=identifier>ctor_args</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>Allocator</span> <span class=identifier>allocator_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>allocator_type</span><span class=special>::</span><span class=identifier>reference</span> <span class=identifier>reference</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>allocator_type</span><span class=special>::</span><span class=identifier>const_reference</span> <span class=identifier>const_reference</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>const_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>size_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>difference_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>size_t</span> <span class=identifier>size_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>ptrdiff_t</span> <span class=identifier>difference_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>allocator_type</span><span class=special>::</span><span class=identifier>pointer</span> <span class=identifier>pointer</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>allocator_type</span><span class=special>::</span><span class=identifier>const_pointer</span> <span class=identifier>const_pointer</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>equivalent to
|
||||
std::reverse_iterator<iterator></b> <span class=identifier>reverse_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>equivalent to
|
||||
std::reverse_iterator<const_iterator></b> <span class=identifier>const_reverse_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>same as owning container </b><span class=identifier>node_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>following [container.insert.return] spec </b><span class=identifier>insert_return_type</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// construct/copy/destroy:</span>
|
||||
|
||||
<b>index class name</b><span class=special>&</span> <span class=keyword>operator</span><span class=special>=(</span><span class=keyword>const</span> <b>index class name</b><span class=special>&</span> <span class=identifier>x</span><span class=special>);</span>
|
||||
<b>index class name</b><span class=special>&</span> <span class=keyword>operator</span><span class=special>=(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special><</span><span class=identifier>value_type</span><span class=special>></span> <span class=identifier>list</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> <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>
|
||||
<span class=keyword>void</span> <span class=identifier>assign</span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special><</span><span class=identifier>value_type</span><span class=special>></span> <span class=identifier>list</span><span class=special>)</span>
|
||||
<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>
|
||||
|
||||
<span class=identifier>allocator_type</span> <span class=identifier>get_allocator</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</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=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>iterator</span> <span class=identifier>end</span><span class=special>()</span><span class=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>reverse_iterator</span> <span class=identifier>rbegin</span><span class=special>()</span><span class=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>reverse_iterator</span> <span class=identifier>rend</span><span class=special>()</span><span class=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_iterator</span> <span class=identifier>cbegin</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_iterator</span> <span class=identifier>cend</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_reverse_iterator</span> <span class=identifier>crbegin</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_reverse_iterator</span> <span class=identifier>crend</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
|
||||
<span class=identifier>iterator</span> <span class=identifier>iterator_to</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>const_iterator</span> <span class=identifier>iterator_to</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>const</span><span class=special>;</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=keyword>noexcept</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=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>size_type</span> <span class=identifier>capacity</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</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> <span class=identifier>capacity</span><span class=special>()</span><span class=keyword>const</span><span class=special>;</span>
|
||||
<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>
|
||||
<span class=keyword>void</span> <span class=identifier>shrink_to_fit</span><span class=special>();</span>
|
||||
|
||||
<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>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=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>
|
||||
|
||||
<span class=comment>// access:</span>
|
||||
|
||||
@@ -277,42 +258,25 @@ plus the requirements for <code>std::list</code> specific list operations at
|
||||
|
||||
<span class=comment>// modifiers:</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span><span class=special>...</span> <span class=identifier>Args</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> <span class=identifier>emplace_front</span><span class=special>(</span><span class=identifier>Args</span><span class=special>&&...</span> <span class=identifier>args</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> <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>
|
||||
<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=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=keyword>template</span><span class=special><</span><span class=keyword>typename</span><span class=special>...</span> <span class=identifier>Args</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> <span class=identifier>emplace_back</span><span class=special>(</span><span class=identifier>Args</span><span class=special>&&...</span> <span class=identifier>args</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> <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>
|
||||
<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=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=keyword>template</span><span class=special><</span><span class=keyword>typename</span><span class=special>...</span> <span class=identifier>Args</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> <span class=identifier>emplace</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Args</span><span class=special>&&...</span> <span class=identifier>args</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> <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>
|
||||
<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=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>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>
|
||||
<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=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>
|
||||
<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>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special><</span><span class=identifier>value_type</span><span class=special>></span> <span class=identifier>list</span><span class=special>);</span>
|
||||
<span class=identifier>insert_return_type</span> <span class=identifier>insert</span><span class=special>(</span><span class=identifier>const_iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>node_type</span><span class=special>&&</span> <span class=identifier>nh</span><span class=special>);</span>
|
||||
|
||||
<span class=identifier>node_type</span> <span class=identifier>extract</span><span class=special>(</span><span class=identifier>const_iterator</span> <span class=identifier>position</span><span class=special>);</span>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<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=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>typename</span> <span class=identifier>Modifier</span><span class=special>></span> <span class=keyword>bool</span> <span class=identifier>modify</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Modifier</span> <span class=identifier>mod</span><span class=special>);</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Modifier</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Rollback</span><span class=special>></span>
|
||||
<span class=keyword>bool</span> <span class=identifier>modify</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Modifier</span> <span class=identifier>mod</span><span class=special>,</span><span class=identifier>Rollback</span> <span class=identifier>back</span><span class=special>);</span>
|
||||
|
||||
<span class=keyword>void</span> <span class=identifier>swap</span><span class=special>(</span><b>index class name</b><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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=keyword>void</span> <span class=identifier>clear</span><span class=special>();</span>
|
||||
|
||||
<span class=comment>// list operations:</span>
|
||||
|
||||
@@ -334,7 +298,7 @@ plus the requirements for <code>std::list</code> specific list operations at
|
||||
<span class=keyword>void</span> <span class=identifier>sort</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> <span class=identifier>sort</span><span class=special>(</span><span class=identifier>Compare</span> <span class=identifier>comp</span><span class=special>);</span>
|
||||
|
||||
<span class=keyword>void</span> <span class=identifier>reverse</span><span class=special>()</span><span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=keyword>void</span> <span class=identifier>reverse</span><span class=special>();</span>
|
||||
|
||||
<span class=comment>// rearrange operations:</span>
|
||||
|
||||
@@ -432,7 +396,7 @@ of the complexity formulas:
|
||||
|
||||
<p>
|
||||
(<code>shl</code> and <code>rel</code> stand for <i>shift left</i> and
|
||||
<i>relocate</i>, respectively.)
|
||||
<i>relocate</i>, respetively.)
|
||||
</p>
|
||||
|
||||
<h4><a name="instantiation_types">Instantiation types</a></h4>
|
||||
@@ -444,7 +408,7 @@ index specifier. Instantiations are dependent on the following types:
|
||||
<ul>
|
||||
<li><code>Value</code> from <code>multi_index_container</code>,</li>
|
||||
<li><code>Allocator</code> from <code>multi_index_container</code>,</li>
|
||||
<li><code>TagList</code> from the index specifier (if provided, otherwise <code>tag<></code> is assumed).</li>
|
||||
<li><code>TagList</code> from the index specifier (if provided).</li>
|
||||
</ul>
|
||||
<code>TagList</code> must be an instantiation of
|
||||
<a href="indices.html#tag"><code>tag</code></a>.
|
||||
@@ -470,22 +434,17 @@ objects to which <code>*this</code> and <code>x</code> belong, respectively.<br>
|
||||
<b>Returns:</b> <code>*this</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code><b>index class name</b>& operator=(std::initializer_list<value_type> list);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>a</span><span class=special>=</span><span class=identifier>list</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
where <code>a</code> is the <code>multi_index_container</code>
|
||||
object to which <code>*this</code> belongs.<br>
|
||||
<b>Returns:</b> <code>*this</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template <class InputIterator><br>
|
||||
void assign(InputIterator first,InputIterator last);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>InputIterator</code> is a model of
|
||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">
|
||||
<code>Input Iterator</code></a> over elements of type
|
||||
<code>value_type</code> or a type convertible to <code>value_type</code>.
|
||||
<code>first</code> and <code>last</code> are not iterators into any
|
||||
index of the <code>multi_index_container</code> to which this index belongs.
|
||||
<code>last</code> is reachable from <code>first</code>.</br>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>clear</span><span class=special>();</span>
|
||||
@@ -493,15 +452,6 @@ void assign(InputIterator first,InputIterator last);</code>
|
||||
</pre></blockquote>
|
||||
</blockquote>
|
||||
|
||||
<code>void assign(std::initializer_list<value_type> list);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>assign</span><span class=special>(</span><span class=identifier>list</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>list</span><span class=special>.</span><span class=identifier>end</span><span class=special>());</span>
|
||||
</pre></blockquote>
|
||||
</blockquote>
|
||||
|
||||
<code>void assign(size_type n,const value_type& value);</code>
|
||||
|
||||
<blockquote>
|
||||
@@ -512,21 +462,9 @@ void assign(InputIterator first,InputIterator last);</code>
|
||||
</pre></blockquote>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="iterators">Iterators</a></h4>
|
||||
|
||||
<code>iterator iterator_to(const value_type& x);<br>
|
||||
const_iterator iterator_to(const value_type& x)const;</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>x</code> is a reference to an element of the container.<br>
|
||||
<b>Returns:</b> An iterator to <code>x</code>.<br>
|
||||
<b>Complexity:</b> Constant.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="capacity">Capacity operations</a></h4>
|
||||
|
||||
<a name="capacity_memfun"><code>size_type capacity()const noexcept;</code></a>
|
||||
<a name="capacity_memfun"><code>size_type capacity()const;</code></a>
|
||||
|
||||
<blockquote>
|
||||
<b>Returns:</b> The total number of elements <code>c</code> such that, when
|
||||
@@ -539,7 +477,6 @@ is preserved in all insertions, regardless of the capacity status.
|
||||
</blockquote>
|
||||
|
||||
<a name="reserve"><code>void reserve(size_type m);</code></a>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b> If the previous value of <code>capacity()</code>
|
||||
was greater than or equal to <code>m</code>, nothing is done;
|
||||
@@ -551,123 +488,52 @@ otherwise <code>O(n)</code>.<br>
|
||||
otherwise, strong.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>void shrink_to_fit();</code>
|
||||
<code>void resize(size_type n,const value_type& x=value_type());</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b> Reduces <code>capacity()</code> to <code>size()</code>.<br>
|
||||
<b>Complexity:</b> If the capacity is not changed, constant;
|
||||
otherwise <code>O(n)</code>.<br>
|
||||
<b>Exception safety:</b> If the capacity is not changed, <code>nothrow</code>;
|
||||
otherwise, strong.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>void resize(size_type n);<br>
|
||||
void resize(size_type n,const value_type& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires (first version):</b> <code>value_type</code> is <code>DefaultInsertable</code>
|
||||
into <code>multi_index_container</code>.<br>
|
||||
<b>Requires (second version):</b> <code>value_type</code> is <code>CopyInsertable</code>
|
||||
into <code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> If <code>size()<n</code>, tries to append <code>n-size()</code> default-inserted
|
||||
elements (first version) or copies of <code>x</code> (second version) at the end of
|
||||
the index. If <code>n<size()</code>, erases the last <code>size()-n</code> elements.<br>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<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=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>
|
||||
<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=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>
|
||||
</pre></blockquote>
|
||||
<b>Note:</b> If an expansion is requested, the size of the index is not guaranteed
|
||||
to be <code>n</code> after this operation (other indices may ban insertions.)
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="modifiers">Modifiers</a></h4>
|
||||
|
||||
<code>template<typename... Args><br>
|
||||
std::pair<iterator,bool> emplace_front(Args&&... args);</code>
|
||||
<code>std::pair<iterator,bool> push_front(const value_type& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>emplace</span><span class=special>(</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>forward</span><span class=special><</span><span class=identifier>Args</span><span class=special>>(</span><span class=identifier>args</span><span class=special>)...);</span>
|
||||
</pre></blockquote>
|
||||
<b>Effects:</b> Inserts <code>x</code> at the beginning of the sequence if
|
||||
no other index of the <code>multi_index_container</code> bans the insertion.<br>
|
||||
<b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
|
||||
is <code>true</code> if and only if insertion took place. On successful
|
||||
insertion, <code>p.first</code> points to the element inserted; otherwise,
|
||||
<code>p.first</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.<br>
|
||||
<b>Complexity:</b> <code>O(n+I(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong.
|
||||
</blockquote>
|
||||
|
||||
<code>std::pair<iterator,bool> push_front(const value_type& x);</code><br>
|
||||
<code>std::pair<iterator,bool> push_front(value_type&& x);</code>
|
||||
|
||||
<code>std::pair<iterator,bool> push_back(const value_type& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>insert</span><span class=special>(</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>x</span><span class=special>);</span> <span class=comment>// lvalue ref version</span>
|
||||
<span class=identifier>insert</span><span class=special>(</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>move</span><span class=special>(</span><span class=identifier>x</span><span class=special>));</span> <span class=comment>// rvalue ref version</span>
|
||||
</pre></blockquote>
|
||||
<b>Effects:</b> Inserts <code>x</code> at the end of the sequence if
|
||||
no other index of the <code>multi_index_container</code> bans the insertion.<br>
|
||||
<b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
|
||||
is <code>true</code> if and only if insertion took place. On successful
|
||||
insertion, <code>p.first</code> points to the element inserted; otherwise,
|
||||
<code>p.first</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.<br>
|
||||
<b>Complexity:</b> <code>O(I(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong.
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename... Args><br>
|
||||
std::pair<iterator,bool> emplace_back(Args&&... args);</code>
|
||||
<code>std::pair<iterator,bool> insert(iterator position,const value_type& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>emplace</span><span class=special>(</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>forward</span><span class=special><</span><span class=identifier>Args</span><span class=special>>(</span><span class=identifier>args</span><span class=special>)...);</span>
|
||||
</pre></blockquote>
|
||||
<b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
|
||||
is <code>true</code> if and only if insertion took place. On successful
|
||||
insertion, <code>p.first</code> points to the element inserted; otherwise,
|
||||
<code>p.first</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.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>std::pair<iterator,bool> push_back(const value_type& x);</code><br>
|
||||
<code>std::pair<iterator,bool> push_back(value_type&& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>insert</span><span class=special>(</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>x</span><span class=special>);</span> <span class=comment>// lvalue ref version</span>
|
||||
<span class=identifier>insert</span><span class=special>(</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>move</span><span class=special>(</span><span class=identifier>x</span><span class=special>));</span> <span class=comment>// rvalue ref version</span>
|
||||
</pre></blockquote>
|
||||
<b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
|
||||
is <code>true</code> if and only if insertion took place. On successful
|
||||
insertion, <code>p.first</code> points to the element inserted; otherwise,
|
||||
<code>p.first</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.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename... Args><br>
|
||||
std::pair<iterator,bool> emplace(iterator position,Args&&... args);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>value_type</code> is <code>EmplaceConstructible</code>
|
||||
into <code>multi_index_container</code> from <code>args</code>.<br>
|
||||
<b>Effects:</b> Inserts a <code>value_type</code> object constructed with
|
||||
<code>std::forward<Args>(args)...</code> before <code>position</code> if insertion
|
||||
is allowed by all other indices of the <code>multi_index_container</code>.<br>
|
||||
<b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
|
||||
is <code>true</code> if and only if insertion took place. On successful insertion,
|
||||
<code>p.first</code> points to the element inserted; otherwise, <code>p.first</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.<br>
|
||||
<b>Complexity:</b> <code>O(shl(end()-position,1) + I(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>std::pair<iterator,bool> insert(iterator position,const value_type& x);</code><br>
|
||||
<code>std::pair<iterator,bool> insert(iterator position,value_type&& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires (first version):</b> <code>value_type</code> is <code>CopyInsertable</code>
|
||||
into <code>multi_index_container</code>.
|
||||
<code>position</code> is a valid iterator of the index.<br>
|
||||
<b>Requires (second version):</b> <code>value_type</code> is <code>MoveInsertable</code>
|
||||
into <code>multi_index_container</code>.
|
||||
<code>position</code> is a valid iterator of the index.<br>
|
||||
<b>Requires:</b> <code>position</code> is a valid iterator of the index.</br>
|
||||
<b>Effects:</b> Inserts <code>x</code> before <code>position</code> if insertion
|
||||
is allowed by all other indices of the <code>multi_index_container</code>.<br>
|
||||
<b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
|
||||
@@ -682,7 +548,7 @@ Note that more than one element can be causing insertion not to be allowed.<br>
|
||||
<code>void insert(iterator position,size_type m,const value_type& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid iterator of the index.<br>
|
||||
<b>Requires:</b> <code>position</code> is a valid iterator of the index.</br>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<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=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>
|
||||
@@ -695,71 +561,28 @@ void insert(iterator position,InputIterator first,InputIterator last);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid iterator of the index.
|
||||
<code>InputIterator</code> is an input iterator.
|
||||
<code>value_type</code> is
|
||||
<code>EmplaceConstructible</code> into
|
||||
<code>multi_index_container</code> from <code>*first</code>.
|
||||
<code>InputIterator</code> is a model of
|
||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">
|
||||
<code>Input Iterator</code></a> over elements of type
|
||||
<code>value_type</code> or a type convertible to <code>value_type</code>.
|
||||
<code>first</code> and <code>last</code> are not iterators into any
|
||||
index of the <code>multi_index_container</code> to which this index belongs.
|
||||
<code>last</code> is reachable from <code>first</code>.<br>
|
||||
<code>last</code> is reachable from <code>first</code>.</br>
|
||||
<b>Effects:</b>
|
||||
For each element of [<code>first</code>, <code>last</code>), in this
|
||||
order, inserts it before <code>position</code> if insertion is allowed by all
|
||||
other indices of the <code>multi_index_container</code>.<br>
|
||||
<blockquote><pre>
|
||||
<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>
|
||||
</pre></blockquote>
|
||||
<b>Complexity:</b> <code>O(shl(end()-position,m) + m*I(n+m))</code>,
|
||||
where <code>m</code> is the number of elements in
|
||||
[<code>first</code>,<code>last</code>).<br>
|
||||
<b>Exception safety:</b> Basic.
|
||||
</blockquote>
|
||||
|
||||
<code>void insert(iterator position,std::initializer_list<value_type> list);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>insert</span><span class=special>(</span><span class=identifier>position</span><span class=special>,</span><span class=identifier>list</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>list</span><span class=special>.</span><span class=identifier>end</span><span class=special>());</span>
|
||||
</pre></blockquote>
|
||||
</blockquote>
|
||||
|
||||
<code>insert_return_type insert(const_iterator position,node_type&& nh);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>nh.empty() || get_allocator()==nh.get_allocator()</code>.<br>
|
||||
<b>Effects:</b> Does nothing if <code>nh</code> is empty; otherwise,
|
||||
inserts the node owned by <code>nh</code> before <code>position</code> if insertion
|
||||
is allowed by all other indices of the <code>multi_index_container</code>.<br>
|
||||
<b>Postconditions:</b> <code>nh</code> is empty.<br>
|
||||
<b>Returns:</b> A value <code>p</code> of type <code>insert_return_type</code>.
|
||||
If <code>nh</code> is empty, <code>p.position</code> is <code>end()</code>,
|
||||
<code>p.inserted</code> is <code>false</code> and <code>p.node</code> is empty;
|
||||
on successful insertion, <code>p.position</code> points to the element inserted,
|
||||
<code>p.inserted</code> is <code>true</code> and <code>p.node</code>
|
||||
is empty;
|
||||
if the insertion failed, <code>p.position</code> points to an element that caused
|
||||
the insertion to be banned, <code>p.inserted</code> is <code>false</code> and
|
||||
<code>p.node</code> owns the original node.
|
||||
Note that more than one element can be causing insertion not to be allowed.<br>
|
||||
<b>Complexity:</b> <code>O(shl(end()-position,1) + I(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong. If an exception
|
||||
is thrown, <code>nh</code> is not changed.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>node_type extract(const_iterator position);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid dereferenceable iterator
|
||||
of the index.<br>
|
||||
<b>Effects:</b> Extracts the node of the element pointed to by <code>position</code>.<br>
|
||||
<b>Returns:</b> A node handle owning the extracted node.<br>
|
||||
<b>Complexity:</b> <code>O(D(n))</code>.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>iterator erase(iterator position);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid dereferenceable iterator
|
||||
of the index.<br>
|
||||
of the index.</br>
|
||||
<b>Effects:</b> Deletes the element pointed to by <code>position</code>.<br>
|
||||
<b>Returns:</b> An iterator pointing to the element immediately following
|
||||
the one that was deleted, or <code>end()</code>
|
||||
@@ -780,14 +603,11 @@ the number of elements in [<code>first</code>,<code>last</code>).<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<a name="replace"><code>bool replace(iterator position,const value_type& x);</code></a><br>
|
||||
<code>bool replace(iterator position,value_type&& x);</code>
|
||||
<a name="replace"><code>bool replace(iterator position,const value_type& x);</code></a>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires (first version):</b> <code>value_type</code> is <code>CopyAssignable</code>.
|
||||
<code>position</code> is a valid dereferenceable iterator of the index.<br>
|
||||
<b>Requires (second version):</b> <code>value_type</code> is <code>MoveAssignable</code>.
|
||||
<code>position</code> is a valid dereferenceable iterator of the index.<br>
|
||||
<b>Requires:</b> <code>position</code> is a valid dereferenceable iterator
|
||||
of the index.</br>
|
||||
<b>Effects:</b> Assigns the value <code>x</code> to the element pointed
|
||||
to by <code>position</code> into the <code>multi_index_container</code> to which
|
||||
the index belongs if replacing is allowed by all other indices of the
|
||||
@@ -806,66 +626,27 @@ belongs remains in its original state.
|
||||
<code>template<typename Modifier> bool modify(iterator position,Modifier mod);</code></a>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>mod</code> is a unary function object
|
||||
accepting arguments of type
|
||||
<b>Requires:</b> <code>Modifier</code> is a model of
|
||||
<a href="http://www.sgi.com/tech/stl/UnaryFunction.html">
|
||||
<code>Unary Function</code></a> accepting arguments of type
|
||||
<code>value_type&</code>. <code>position</code> is a valid dereferenceable
|
||||
iterator of the index.
|
||||
The execution of <code>mod(e)</code>, where <code>e</code> is the element
|
||||
pointed to by <code>position</code>, does not invoke any operation of the
|
||||
<code>multi_index_container</code> after <code>e</code> is directly modified
|
||||
or, before modification, if the operation would invalidate <code>position</code>.<br>
|
||||
iterator of the index.</br>
|
||||
<b>Effects:</b> Calls <code>mod(e)</code> where <code>e</code> is the element
|
||||
pointed to by <code>position</code> and rearranges <code>*position</code> into
|
||||
all the indices of the <code>multi_index_container</code>. Rearrangement on sequenced
|
||||
indices does not change the position of the element with respect to the index;
|
||||
rearrangement on other indices may or might not succeed. If the rearrangement
|
||||
fails, the element is erased.<br>
|
||||
all the indices of the <code>multi_index_container</code>. Rearrangement on
|
||||
rancom access indices does not change the position of the element with respect
|
||||
to the index; rearrangement on other indices may or might not suceed. If the
|
||||
rearrangement fails, the element is erased.<br>
|
||||
<b>Postconditions:</b> Validity of <code>position</code> is preserved if the
|
||||
operation succeeds.<br>
|
||||
<b>Returns:</b> <code>true</code> if the operation succeeded, <code>false</code>
|
||||
otherwise.<br>
|
||||
<b>Complexity:</b> <code>O(M(n))</code>.<br>
|
||||
<b>Exception safety:</b> Basic. If an exception is thrown by some
|
||||
user-provided operation (including <code>mod</code>), then
|
||||
user-provided operation (except possibly <code>mod</code>), then
|
||||
the element pointed to by <code>position</code> is erased.
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename Modifier,typename Rollback><br>
|
||||
bool modify(iterator position,Modifier mod,Rollback back);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>mod</code> and <code>back</code> are unary function
|
||||
objects accepting arguments of type
|
||||
<code>value_type&</code>. <code>position</code> is a valid dereferenceable
|
||||
iterator of the index.
|
||||
The execution of <code>mod(e)</code>, where <code>e</code> is the element
|
||||
pointed to by <code>position</code>, does not invoke any operation of the
|
||||
<code>multi_index_container</code> after <code>e</code> is directly modified
|
||||
or, before modification, if the operation would invalidate <code>position</code>.
|
||||
<code>back(e)</code> does not invoke any operation of the
|
||||
<code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> Calls <code>mod(e)</code> where <code>e</code> is the element
|
||||
pointed to by <code>position</code> and tries to rearrange <code>*position</code> into
|
||||
all the indices of the <code>multi_index_container</code>. Rearrangement on sequenced
|
||||
indices does not change the position of the element with respect to the index;
|
||||
rearrangement on other indices may or might not succeed.
|
||||
If the rearrangement fails, <code>back(e)</code> is invoked: if the resulting value
|
||||
of <code>e</code> is consistent with its original position and constraints in all
|
||||
indices, the element is kept, otherwise it is erased.<br>
|
||||
<b>Postconditions:</b> Validity of <code>position</code> is preserved except if
|
||||
the element is erased under the conditions described below.<br>
|
||||
<b>Returns:</b> <code>true</code> if the operation succeeded, <code>false</code>
|
||||
otherwise.<br>
|
||||
<b>Complexity:</b> <code>O(M(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong, except if <code>mod</code> or <code>back</code> throw an
|
||||
exception or <code>back(e)</code> fails to properly restore the element or there is
|
||||
a throwing user-provided operation after invoking <code>back(e)</code>, in which cases
|
||||
the modified element is erased. If <code>back</code>
|
||||
throws inside the handling code executing after some other user-provided
|
||||
operation has thrown, it is the exception generated by <code>back</code> that
|
||||
is rethrown.
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="list_operations">List operations</a></h4>
|
||||
|
||||
<p>
|
||||
@@ -879,9 +660,9 @@ of sequenced indices, but the associated complexity bounds differ in general.
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid iterator of the index.
|
||||
<code>&x!=this</code>.<br>
|
||||
<code>&x!=this</code>.</br>
|
||||
<b>Effects:</b> Inserts the contents of <code>x</code> before <code>position</code>,
|
||||
in the same order as they were in <code>x</code>. Those elements successfully
|
||||
in the same order as they were in <code>x</code>. Those elements succesfully
|
||||
inserted are erased from <code>x</code>.<br>
|
||||
<b>Complexity:</b> <code>O(shl(end()-position,x.size()) + x.size()*I(n+x.size()) + x.size()*D(x.size()))</code>.<br>
|
||||
<b>Exception safety:</b> Basic.<br>
|
||||
@@ -893,9 +674,9 @@ inserted are erased from <code>x</code>.<br>
|
||||
<b>Requires:</b> <code>position</code> is a valid iterator of the index.
|
||||
<code>i</code> is a valid dereferenceable iterator <code>x</code>.<br>
|
||||
<b>Effects:</b> Inserts the element pointed to by <code>i</code> before
|
||||
<code>position</code>: if insertion is successful, the element is erased from
|
||||
<code>position</code>: if insertion is succesful, the element is erased from
|
||||
<code>x</code>. In the special case <code>&x==this</code>, no copy or
|
||||
deletion is performed, and the operation is always successful. If
|
||||
deletion is performed, and the operation is always succesful. If
|
||||
<code>position==i</code>, no operation is performed.<br>
|
||||
<b>Postconditions:</b> If <code>&x==this</code>, no iterator or reference
|
||||
is invalidated.<br>
|
||||
@@ -913,10 +694,10 @@ otherwise, strong.<br>
|
||||
<code>last</code> is reachable from <code>first</code>. <code>position</code>
|
||||
is not in the range [<code>first</code>,<code>last</code>).<br>
|
||||
<b>Effects:</b> For each element in the range [<code>first</code>,<code>last</code>),
|
||||
insertion is tried before <code>position</code>; if the operation is successful,
|
||||
insertion is tried before <code>position</code>; if the operation is succesful,
|
||||
the element is erased from <code>x</code>. In the special case
|
||||
<code>&x==this</code>, no copy or deletion is performed, and insertions are
|
||||
always successful.<br>
|
||||
always succesful.<br>
|
||||
<b>Postconditions:</b> If <code>&x==this</code>, no iterator or reference
|
||||
is invalidated.<br>
|
||||
<b>Complexity:</b> If <code>&x==this</code>,
|
||||
@@ -973,10 +754,11 @@ is the number of elements erased.<br>
|
||||
<code>void merge(index class name& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>std::less<value_type></code> induces a
|
||||
strict weak ordering over <code>value_type</code>.
|
||||
<b>Requires:</b> <code>std::less<value_type></code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">
|
||||
<code>Strict Weak Ordering</code></a> over <code>value_type</code>.
|
||||
Both the index and <code>x</code> are sorted according to
|
||||
<code>std::less<value_type></code>.<br>
|
||||
<code>std::less<value_type></code>.<br>
|
||||
<b>Effects:</b> Attempts to insert every element of <code>x</code> into the
|
||||
corresponding position of the index (according to the order). Elements
|
||||
successfully inserted are erased from <code>x</code>. The resulting sequence
|
||||
@@ -996,8 +778,9 @@ otherwise, basic.<br>
|
||||
<code>template <typename Compare> void merge(index class name& x,Compare comp);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>Compare</code> induces a
|
||||
strict weak ordering over <code>value_type</code>.
|
||||
<b>Requires:</b> <code>Compare</code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">
|
||||
<code>Strict Weak Ordering</code></a> over <code>value_type</code>.
|
||||
Both the index and <code>x</code> are sorted according to <code>comp</code>.<br>
|
||||
<b>Effects:</b> Attempts to insert every element of <code>x</code> into the
|
||||
corresponding position of the index (according to <code>comp</code>).
|
||||
@@ -1018,8 +801,9 @@ otherwise, basic.<br>
|
||||
<code>void sort();</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>std::less<value_type></code> induces a
|
||||
strict weark ordering over <code>value_type</code>.<br>
|
||||
<b>Requires:</b> <code>std::less<value_type></code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">
|
||||
<code>Strict Weak Ordering</code></a> over <code>value_type</code>.<br>
|
||||
<b>Effects:</b> Sorts the index according to
|
||||
<code>std::less<value_type></code>. The sorting is stable, i.e.
|
||||
equivalent elements preserve their relative position.<br>
|
||||
@@ -1031,8 +815,9 @@ equivalent elements preserve their relative position.<br>
|
||||
<code>template <typename Compare> void sort(Compare comp);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>Compare</code> induces a
|
||||
strict weak ordering over <code>value_type</code>.<br>
|
||||
<b>Requires:</b> <code>Compare</code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">
|
||||
<code>Strict Weak Ordering</code></a> over <code>value_type</code>.<br>
|
||||
<b>Effects:</b> Sorts the index according to <code>comp</code>. The sorting
|
||||
is stable, i.e. equivalent elements preserve their relative position.<br>
|
||||
<b>Postconditions:</b> Validity of iterators and references is preserved.<br>
|
||||
@@ -1040,12 +825,13 @@ is stable, i.e. equivalent elements preserve their relative position.<br>
|
||||
<b>Exception safety:</b> Basic.
|
||||
</blockquote>
|
||||
|
||||
<code>void reverse()noexcept;</code>
|
||||
<code>void reverse();</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b> Reverses the order of the elements in the index.<br>
|
||||
<b>Postconditions:</b> Validity of iterators and references is preserved.<br>
|
||||
<b>Complexity:</b> <code>O(n)</code>.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="rearrange_operations">Rearrange operations</a></h4>
|
||||
@@ -1121,7 +907,7 @@ input archive (XML archive) <code>ar</code>.
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> No additional requirements to those imposed by the container.<br>
|
||||
<b>Postconditions:</b> On successful loading, each of the elements of
|
||||
<b>Postconditions:</b> On succesful loading, each of the elements of
|
||||
[<code>begin()</code>, <code>end()</code>) is a restored copy of the corresponding
|
||||
element in [<code>m.get<i>().begin()</code>, <code>m.get<i>().end()</code>),
|
||||
where <code>i</code> is the position of the random access index in the container.
|
||||
@@ -1139,7 +925,7 @@ Operation: loading of an <code>iterator</code> or <code>const_iterator</code>
|
||||
<code>it'</code> from an input archive (XML archive) <code>ar</code>.
|
||||
|
||||
<blockquote>
|
||||
<b>Postconditions:</b> On successful loading, if <code>it</code> was dereferenceable
|
||||
<b>Postconditions:</b> On succesful loading, if <code>it</code> was dereferenceable
|
||||
then <code>*it'</code> is the restored copy of <code>*it</code>, otherwise
|
||||
<code>it'==end()</code>.<br>
|
||||
<b>Note:</b> It is allowed that <code>it</code> be a <code>const_iterator</code>
|
||||
@@ -1160,9 +946,9 @@ Key extraction
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised May 9th 2020</p>
|
||||
<p>Revised February 6th 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2020 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
@@ -1,645 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Boost.MultiIndex Documentation - Ranked indices reference</title>
|
||||
<link rel="stylesheet" href="../style.css" type="text/css">
|
||||
<link rel="start" href="../index.html">
|
||||
<link rel="prev" href="indices.html">
|
||||
<link rel="up" href="index.html">
|
||||
<link rel="next" href="hash_indices.html">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
|
||||
"middle" width="277" height="86">Boost.MultiIndex Ranked indices reference</h1>
|
||||
|
||||
<div class="prev_link"><a href="ord_indices.html"><img src="../prev.gif" alt="ordered_indices" border="0"><br>
|
||||
Ordered indices
|
||||
</a></div>
|
||||
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.MultiIndex reference" border="0"><br>
|
||||
Boost.MultiIndex reference
|
||||
</a></div>
|
||||
<div class="next_link"><a href="hash_indices.html"><img src="../next.gif" alt="hashed indices" border="0"><br>
|
||||
Hashed indices
|
||||
</a></div><br clear="all" style="clear: all;">
|
||||
|
||||
<hr>
|
||||
|
||||
<h2>Contents</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="#rnk_index_fwd_synopsis">Header
|
||||
<code>"boost/multi_index/ranked_index_fwd.hpp"</code> synopsis</a></li>
|
||||
<li><a href="#synopsis">Header
|
||||
<code>"boost/multi_index/ranked_index.hpp"</code> synopsis</a>
|
||||
<ul>
|
||||
<li><a href="#unique_non_unique">
|
||||
Index specifiers <code>ranked_unique</code> and <code>ranked_non_unique</code>
|
||||
</a></li>
|
||||
<li><a href="#rnk_indices">Ranked indices</a>
|
||||
<ul>
|
||||
<li><a href="#complexity_signature">Complexity signature</a></li>
|
||||
<li><a href="#instantiation_types">Instantiation types</a></li>
|
||||
<li><a href="#rank_operations">Rank operations</a></li>
|
||||
<li><a href="#serialization">Serialization</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2>
|
||||
<a name="rnk_index_fwd_synopsis">Header
|
||||
<a href="../../../../boost/multi_index/ranked_index_fwd.hpp">
|
||||
<code>"boost/multi_index/ranked_index_fwd.hpp"</code></a> synopsis</a></h2>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>multi_index</span><span class=special>{</span>
|
||||
|
||||
<span class=comment>// index specifiers ranked_unique and ranked_non_unique</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>consult ranked_unique reference for arguments</b><span class=special>></span>
|
||||
<span class=keyword>struct</span> <span class=identifier>ranked_unique</span><span class=special>;</span>
|
||||
<span class=keyword>template</span><span class=special><</span><b>consult ranked_non_unique reference for arguments</b><span class=special>></span>
|
||||
<span class=keyword>struct</span> <span class=identifier>ranked_non_unique</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// indices</span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>detail</span><span class=special>{</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>implementation defined</b><span class=special>></span> <span class=keyword>class</span> <b>index name is implementation defined</b><span class=special>;</span>
|
||||
|
||||
<span class=special>}</span> <span class=comment>// namespace boost::multi_index::detail</span>
|
||||
|
||||
<span class=special>}</span> <span class=comment>// namespace boost::multi_index</span>
|
||||
|
||||
<span class=special>}</span> <span class=comment>// namespace boost</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
<code>ranked_index_fwd.hpp</code> provides forward declarations for index specifiers
|
||||
<a href="#unique_non_unique"><code>ranked_unique</code> and <code>ranked_non_unique</code></a> and
|
||||
their associated <a href="#rnk_indices">ranked index</a> classes.
|
||||
</p>
|
||||
|
||||
<h2>
|
||||
<a name="synopsis">Header
|
||||
<a href="../../../../boost/multi_index/ranked_index.hpp">
|
||||
<code>"boost/multi_index/ranked_index.hpp"</code></a> synopsis</a></h2>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=preprocessor>#include</span> <span class=special><</span><span class=identifier>initializer_list</span><span class=special>></span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>multi_index</span><span class=special>{</span>
|
||||
|
||||
<span class=comment>// index specifiers ranked_unique and ranked_non_unique</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>consult ranked_unique reference for arguments</b><span class=special>></span>
|
||||
<span class=keyword>struct</span> <span class=identifier>ranked_unique</span><span class=special>;</span>
|
||||
<span class=keyword>template</span><span class=special><</span><b>consult ranked_non_unique reference for arguments</b><span class=special>></span>
|
||||
<span class=keyword>struct</span> <span class=identifier>ranked_non_unique</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// indices</span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>detail</span><span class=special>{</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>implementation defined</b><span class=special>></span> <span class=keyword>class</span> <b>index class name implementation defined</b><span class=special>;</span>
|
||||
|
||||
<span class=comment>// index comparison:</span>
|
||||
|
||||
<span class=comment>// <b>OP</b> is any of ==,<,!=,>,>=,<=</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>arg set 1</b><span class=special>,</span><b>arg set 2</b><span class=special>></span>
|
||||
<span class=keyword>bool</span> <span class=keyword>operator</span> <b><i>OP</i></b><span class=special>(</span>
|
||||
<span class=keyword>const</span> <b>index class name</b><span class=special><</span><b>arg set 1</b><span class=special>>&</span> <span class=identifier>x</span><span class=special>,</span><span class=keyword>const</span> <b>index class name</b><span class=special><</span><b>arg set 2</b><span class=special>>&</span> <span class=identifier>y</span><span class=special>);</span>
|
||||
|
||||
<span class=comment>// index specialized algorithms:</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>implementation defined</b><span class=special>></span>
|
||||
<span class=keyword>void</span> <span class=identifier>swap</span><span class=special>(</span><b>index class name</b><span class=special>&</span> <span class=identifier>x</span><span class=special>,</span><b>index class name</b><span class=special>&</span> <span class=identifier>y</span><span class=special>);</span>
|
||||
|
||||
<span class=special>}</span> <span class=comment>// namespace boost::multi_index::detail</span>
|
||||
|
||||
<span class=special>}</span> <span class=comment>// namespace boost::multi_index</span>
|
||||
|
||||
<span class=special>}</span> <span class=comment>// namespace boost</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<h3><a name="unique_non_unique">
|
||||
Index specifiers <code>ranked_unique</code> and <code>ranked_non_unique</code>
|
||||
</a></h3>
|
||||
|
||||
<p>
|
||||
These <a href="indices.html#index_specification">index specifiers</a> allow
|
||||
for insertion of <a href="#rnk_indices">ranked indices</a> without and with
|
||||
allowance of duplicate elements, respectively. The syntax of <code>ranked_unique</code>
|
||||
and <code>ranked_non_unique</code> coincide, thus we describe them in a grouped manner.
|
||||
<code>ranked_unique</code> and <code>ranked_non_unique</code> can be instantiated in
|
||||
two different forms, according to whether a tag list for the index is provided or not:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=keyword>template</span><span class=special><</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>KeyFromValue</span><span class=special>,</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>Compare</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>KeyFromValue</span><span class=special>::</span><span class=identifier>result_type</span><span class=special>></span>
|
||||
<span class=special>></span>
|
||||
<span class=keyword>struct</span> <span class=special>(</span><span class=identifier>ranked_unique</span> <span class=special>|</span> <span class=identifier>ranked_non_unique</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>TagList</span><span class=special>,</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>KeyFromValue</span><span class=special>,</span>
|
||||
<span class=keyword>typename</span> <span class=identifier>Compare</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>KeyFromValue</span><span class=special>::</span><span class=identifier>result_type</span><span class=special>></span>
|
||||
<span class=special>></span>
|
||||
<span class=keyword>struct</span> <span class=special>(</span><span class=identifier>ranked_unique</span> <span class=special>|</span> <span class=identifier>ranked_non_unique</span><span class=special>)</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
If provided, <code>TagList</code> must be an instantiation of the class template
|
||||
<a href="indices.html#tag"><code>tag</code></a>.
|
||||
The template arguments are used by the corresponding index implementation,
|
||||
refer to the <a href="#rnk_indices">ranked indices</a> reference section for further
|
||||
explanations on their acceptable type values.
|
||||
</p>
|
||||
|
||||
<h3><a name="rnk_indices">Ranked indices</a></h3>
|
||||
|
||||
<p>
|
||||
Ranked indices are a variation of <a href="ord_indices.html">ordered indices</a>
|
||||
providing additional capabilities for calculation of and access by rank; the <i>rank</i> of an element is the
|
||||
distance to it from the beginning of the index. Besides this extension, ranked indices replicate the
|
||||
public interface of ordered indices with the difference, complexity-wise, that <a href="#complexity_signature">deletion</a>
|
||||
is done in logarithmic rather than constant time. Also, execution times and memory consumption are
|
||||
expected to be poorer due to the internal bookkeeping needed to maintain rank-related information.
|
||||
As with ordered indices, ranked indices can be unique (no duplicate elements are allowed)
|
||||
or non-unique: either version is associated to a different index specifier, but
|
||||
the interface of both index types is the same.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
In what follows, we only describe the extra operations provided by ranked indices: for the
|
||||
rest refer to the <a href="ord_indices.html#ord_indices">documentation</a> for ordered
|
||||
indices, bearing in mind the occasional differences in complexity.
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>multi_index</span><span class=special>{</span>
|
||||
|
||||
<b>implementation defined </b><span class=identifier>unbounded</span><span class=special>;</span> <span class=comment>// see range_rank()</span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>detail</span><span class=special>{</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>implementation defined: dependent on types Value, Allocator,
|
||||
TagList, KeyFromValue, Compare</b><span class=special>></span>
|
||||
<span class=keyword>class</span> <b>name is implementation defined</b>
|
||||
<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=keyword>typename</span> <span class=identifier>KeyFromValue</span><span class=special>::</span><span class=identifier>result_type</span> <span class=identifier>key_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>Value</span> <span class=identifier>value_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>KeyFromValue</span> <span class=identifier>key_from_value</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>Compare</span> <span class=identifier>key_compare</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined </b><span class=identifier>value_compare</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>tuple</span><span class=special><</span><span class=identifier>key_from_value</span><span class=special>,</span><span class=identifier>key_compare</span><span class=special>></span> <span class=identifier>ctor_args</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>TagList</span> <span class=identifier>tag_list</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>Allocator</span> <span class=identifier>allocator_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>Allocator</span><span class=special>::</span><span class=identifier>reference</span> <span class=identifier>reference</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>Allocator</span><span class=special>::</span><span class=identifier>const_reference</span> <span class=identifier>const_reference</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined </b><span class=identifier>iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined </b><span class=identifier>const_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined </b><span class=identifier>size_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined </b><span class=identifier>difference_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>Allocator</span><span class=special>::</span><span class=identifier>pointer</span> <span class=identifier>pointer</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>Allocator</span><span class=special>::</span><span class=identifier>const_pointer</span> <span class=identifier>const_pointer</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>equivalent to
|
||||
std::reverse_iterator<iterator></b> <span class=identifier>reverse_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>equivalent to
|
||||
std::reverse_iterator<const_iterator></b> <span class=identifier>const_reverse_iterator</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// construct/copy/destroy:</span>
|
||||
|
||||
<b>index class name</b><span class=special>&</span> <span class=keyword>operator</span><span class=special>=(</span><span class=keyword>const</span> <b>index class name</b><span class=special>&</span> <span class=identifier>x</span><span class=special>);</span>
|
||||
<b>index class name</b><span class=special>&</span> <span class=keyword>operator</span><span class=special>=(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special><</span><span class=identifier>value_type</span><span class=special>></span> <span class=identifier>list</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=keyword>noexcept</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=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>iterator</span> <span class=identifier>end</span><span class=special>()</span><span class=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>reverse_iterator</span> <span class=identifier>rbegin</span><span class=special>()</span><span class=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>reverse_iterator</span> <span class=identifier>rend</span><span class=special>()</span><span class=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_iterator</span> <span class=identifier>cbegin</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_iterator</span> <span class=identifier>cend</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_reverse_iterator</span> <span class=identifier>crbegin</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_reverse_iterator</span> <span class=identifier>crend</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
|
||||
<span class=identifier>iterator</span> <span class=identifier>iterator_to</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>const_iterator</span> <span class=identifier>iterator_to</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>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=keyword>noexcept</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=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// modifiers:</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span><span class=special>...</span> <span class=identifier>Args</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> <span class=identifier>emplace</span><span class=special>(</span><span class=identifier>Args</span><span class=special>&&...</span> <span class=identifier>args</span><span class=special>);</span>
|
||||
<span class=keyword>template</span> <span class=special><</span><span class=keyword>typename</span><span class=special>...</span> <span class=identifier>Args</span><span class=special>></span>
|
||||
<span class=identifier>iterator</span> <span class=identifier>emplace_hint</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Args</span><span class=special>&&...</span> <span class=identifier>args</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> <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>
|
||||
<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>value_type</span><span class=special>&&</span> <span class=identifier>x</span><span class=special>);</span>
|
||||
<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>
|
||||
<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=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>typename</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>
|
||||
<span class=keyword>void</span> <span class=identifier>insert</span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special><</span><span class=identifier>value_type</span><span class=special>></span> <span class=identifier>list</span><span class=special>);</span>
|
||||
|
||||
<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>
|
||||
<span class=identifier>size_type</span> <span class=identifier>erase</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=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>
|
||||
|
||||
<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>
|
||||
<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=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>typename</span> <span class=identifier>Modifier</span><span class=special>></span> <span class=keyword>bool</span> <span class=identifier>modify</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Modifier</span> <span class=identifier>mod</span><span class=special>);</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Modifier</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Rollback</span><span class=special>></span>
|
||||
<span class=keyword>bool</span> <span class=identifier>modify</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Modifier</span> <span class=identifier>mod</span><span class=special>,</span><span class=identifier>Rollback</span> <span class=identifier>back</span><span class=special>);</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Modifier</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>Modifier</span> <span class=identifier>mod</span><span class=special>);</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Modifier</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Rollback</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>Modifier</span> <span class=identifier>mod</span><span class=special>,</span><span class=identifier>Rollback</span> <span class=identifier>back</span><span class=special>);</span>
|
||||
|
||||
<span class=keyword>void</span> <span class=identifier>swap</span><span class=special>(</span><b>index class name</b><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=keyword>noexcept</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>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>typename</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>const</span><span class=special>;</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>CompatibleCompare</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>const</span> <span class=identifier>CompatibleCompare</span><span class=special>&</span> <span class=identifier>comp</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>typename</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>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>CompatibleCompare</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=identifier>CompatibleCompare</span><span class=special>&</span> <span class=identifier>comp</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>typename</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>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>typename</span> <span class=identifier>CompatibleKey</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>CompatibleCompare</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>CompatibleKey</span><span class=special>&</span> <span class=identifier>x</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>CompatibleCompare</span><span class=special>&</span> <span class=identifier>comp</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>typename</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>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>typename</span> <span class=identifier>CompatibleKey</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>CompatibleCompare</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>CompatibleKey</span><span class=special>&</span> <span class=identifier>x</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>CompatibleCompare</span><span class=special>&</span> <span class=identifier>comp</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>typename</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>const</span><span class=special>;</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>CompatibleCompare</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>const</span> <span class=identifier>CompatibleCompare</span><span class=special>&</span> <span class=identifier>comp</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// range:</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>LowerBounder</span><span class=special>,</span><span class=keyword>typename</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> <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>
|
||||
|
||||
<span class=comment>// rank operations:</span>
|
||||
|
||||
<span class=identifier>iterator</span> <span class=identifier>nth</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>rank</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=special>;</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>></span>
|
||||
<span class=identifier>size_type</span> <span class=identifier>find_rank</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>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>CompatibleCompare</span><span class=special>></span>
|
||||
<span class=identifier>size_type</span> <span class=identifier>find_rank</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=identifier>CompatibleCompare</span><span class=special>&</span> <span class=identifier>comp</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>typename</span> <span class=identifier>CompatibleKey</span><span class=special>></span>
|
||||
<span class=identifier>size_type</span> <span class=identifier>lower_bound_rank</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>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>CompatibleCompare</span><span class=special>></span>
|
||||
<span class=identifier>size_type</span> <span class=identifier>lower_bound_rank</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=identifier>CompatibleCompare</span><span class=special>&</span> <span class=identifier>comp</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>typename</span> <span class=identifier>CompatibleKey</span><span class=special>></span>
|
||||
<span class=identifier>size_type</span> <span class=identifier>upper_bound_rank</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>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>CompatibleCompare</span><span class=special>></span>
|
||||
<span class=identifier>size_type</span> <span class=identifier>upper_bound_rank</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=identifier>CompatibleCompare</span><span class=special>&</span> <span class=identifier>comp</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>typename</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>size_type</span><span class=special>,</span><span class=identifier>size_type</span><span class=special>></span> <span class=identifier>equal_range_rank</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>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>CompatibleCompare</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>size_type</span><span class=special>,</span><span class=identifier>size_type</span><span class=special>></span> <span class=identifier>equal_range_rank</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=identifier>CompatibleCompare</span><span class=special>&</span> <span class=identifier>comp</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>typename</span> <span class=identifier>LowerBounder</span><span class=special>,</span><span class=keyword>typename</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>size_type</span><span class=special>,</span><span class=identifier>size_type</span><span class=special>></span>
|
||||
<span class=identifier>range_rank</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>
|
||||
<span class=special>};</span>
|
||||
|
||||
<span class=comment>// index comparison:</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>arg set 1</b><span class=special>,</span><b>arg set 2</b><span class=special>></span>
|
||||
<span class=keyword>bool</span> <span class=keyword>operator</span><span class=special>==(</span>
|
||||
<span class=keyword>const</span> <b>index class name</b><span class=special><</span><b>arg set 1</b><span class=special>>&</span> <span class=identifier>x</span><span class=special>,</span>
|
||||
<span class=keyword>const</span> <b>index class name</b><span class=special><</span><b>arg set 2</b><span class=special>>&</span> <span class=identifier>y</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>x</span><span class=special>.</span><span class=identifier>size</span><span class=special>()==</span><span class=identifier>y</span><span class=special>.</span><span class=identifier>size</span><span class=special>()&&</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>equal</span><span class=special>(</span><span class=identifier>x</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>x</span><span class=special>.</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>y</span><span class=special>.</span><span class=identifier>begin</span><span class=special>());</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>arg set 1</b><span class=special>,</span><b>arg set 2</b><span class=special>></span>
|
||||
<span class=keyword>bool</span> <span class=keyword>operator</span><span class=special><(</span>
|
||||
<span class=keyword>const</span> <b>index class name</b><span class=special><</span><b>arg set 1</b><span class=special>>&</span> <span class=identifier>x</span><span class=special>,</span>
|
||||
<span class=keyword>const</span> <b>index class name</b><span class=special><</span><b>arg set 2</b><span class=special>>&</span> <span class=identifier>y</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>lexicographical_compare</span><span class=special>(</span><span class=identifier>x</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>x</span><span class=special>.</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>y</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>y</span><span class=special>.</span><span class=identifier>end</span><span class=special>());</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>arg set 1</b><span class=special>,</span><b>arg set 2</b><span class=special>></span>
|
||||
<span class=keyword>bool</span> <span class=keyword>operator</span><span class=special>!=(</span>
|
||||
<span class=keyword>const</span> <b>index class name</b><span class=special><</span><b>arg set 1</b><span class=special>>&</span> <span class=identifier>x</span><span class=special>,</span>
|
||||
<span class=keyword>const</span> <b>index class name</b><span class=special><</span><b>arg set 2</b><span class=special>>&</span> <span class=identifier>y</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</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=keyword>template</span><span class=special><</span><b>arg set 1</b><span class=special>,</span><b>arg set 2</b><span class=special>></span>
|
||||
<span class=keyword>bool</span> <span class=keyword>operator</span><span class=special>>(</span>
|
||||
<span class=keyword>const</span> <b>index class name</b><span class=special><</span><b>arg set 1</b><span class=special>>&</span> <span class=identifier>x</span><span class=special>,</span>
|
||||
<span class=keyword>const</span> <b>index class name</b><span class=special><</span><b>arg set 2</b><span class=special>>&</span> <span class=identifier>y</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=identifier>y</span><span class=special><</span><span class=identifier>x</span><span class=special>;</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>arg set 1</b><span class=special>,</span><b>arg set 2</b><span class=special>></span>
|
||||
<span class=keyword>bool</span> <span class=keyword>operator</span><span class=special>>=(</span>
|
||||
<span class=keyword>const</span> <b>index class name</b><span class=special><</span><b>arg set 1</b><span class=special>>&</span> <span class=identifier>x</span><span class=special>,</span>
|
||||
<span class=keyword>const</span> <b>index class name</b><span class=special><</span><b>arg set 2</b><span class=special>>&</span> <span class=identifier>y</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</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=keyword>template</span><span class=special><</span><b>arg set 1</b><span class=special>,</span><b>arg set 2</b><span class=special>></span>
|
||||
<span class=keyword>bool</span> <span class=keyword>operator</span><span class=special><=(</span>
|
||||
<span class=keyword>const</span> <b>index class name</b><span class=special><</span><b>arg set 1</b><span class=special>>&</span> <span class=identifier>x</span><span class=special>,</span>
|
||||
<span class=keyword>const</span> <b>index class name</b><span class=special><</span><b>arg set 2</b><span class=special>>&</span> <span class=identifier>y</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</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=comment>// index specialized algorithms:</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><b>implementation defined</b><span class=special>></span>
|
||||
<span class=keyword>void</span> <span class=identifier>swap</span><span class=special>(</span><b>index class name</b><span class=special>&</span> <span class=identifier>x</span><span class=special>,</span><b>index class name</b><span class=special>&</span> <span class=identifier>y</span><span class=special>);</span>
|
||||
|
||||
<span class=special>}</span> <span class=comment>// namespace boost::multi_index::detail</span>
|
||||
|
||||
<span class=special>}</span> <span class=comment>// namespace boost::multi_index</span>
|
||||
|
||||
<span class=special>}</span> <span class=comment>// namespace boost</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<h4><a name="complexity_signature">Complexity signature</a></h4>
|
||||
|
||||
<p>
|
||||
We follow the terminology described in the
|
||||
<a href="indices.html#complexity_signature">complexity signature
|
||||
section</a>. The complexity signature of ranked indices is:
|
||||
<ul>
|
||||
<li>copying: <code>c(n)=n*log(n)</code>,</li>
|
||||
<li>insertion: <code>i(n)=log(n)</code>,</li>
|
||||
<li>hinted insertion: <code>h(n)=1</code> (constant) if the hint element
|
||||
is immediately after the point of insertion, <code>h(n)=log(n)</code> otherwise,</li>
|
||||
<li>deletion: <b><code>d(n)=log(n)</code></b> ,</li>
|
||||
<li>replacement: <code>r(n)=1</code> (constant) if the element position does not
|
||||
change, <code>r(n)=log(n)</code> otherwise,</li>
|
||||
<li>modifying: <code>m(n)=1</code> (constant) if the element position does not
|
||||
change, <code>m(n)=log(n)</code> otherwise.</li>
|
||||
</ul>
|
||||
</p>
|
||||
<p>
|
||||
These complexity guarantees are the same as those of
|
||||
<a href="ord_indices.html#complexity_signature">ordered indices</a>
|
||||
except for deletion, which is <code>log(n)</code> here and amortized constant there.
|
||||
</p>
|
||||
|
||||
<h4><a name="instantiation_types">Instantiation types</a></h4>
|
||||
|
||||
<p>Ordered indices are instantiated internally to <code>multi_index_container</code> and
|
||||
specified by means of <a href="indices.html#indexed_by"><code>indexed_by</code></a>
|
||||
with <a href="#unique_non_unique"> index specifiers <code>ranked_unique</code>
|
||||
and <code>ranked_non_unique</code></a>. Instantiations are dependent on the
|
||||
following types:
|
||||
<ul>
|
||||
<li><code>Value</code> from <code>multi_index_container</code>,</li>
|
||||
<li><code>Allocator</code> from <code>multi_index_container</code>,</li>
|
||||
<li><code>TagList</code> from the index specifier (if provided, otherwise <code>tag<></code> is assumed),</li>
|
||||
<li><code>KeyFromValue</code> from the index specifier,</li>
|
||||
<li><code>Compare</code> from the index specifier.</li>
|
||||
</ul>
|
||||
These types are subject to the same requirements as specified for
|
||||
<a href="ord_indices.html#instantiation_types">ordered indices</a>.
|
||||
</p>
|
||||
|
||||
<h4><a name="rank_operations">Rank operations</a></h4>
|
||||
|
||||
<p>
|
||||
The <i>rank</i> of an iterator <code>it</code> of a given container <code>c</code> (and,
|
||||
by extension, of the element it points to if the iterator is dereferenceable)
|
||||
is <code>std::distance(c.begin(),it)</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
See the documentation of ordered indices for an explanation of the notions of
|
||||
<a href="ord_indices.html#set_operations"><i>compatible extension</i>,
|
||||
<i>compatible key</i></a>,
|
||||
<a href="ord_indices.html#range_operations"><i>lower bounder</i> and <i>upper bounder</i></a>, which are
|
||||
referred to below.
|
||||
</p>
|
||||
|
||||
<code>iterator nth(size_type n)const;</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b> Returns an iterator with rank <code>n</code>,
|
||||
or <code>end()</code> if <code>n>=size()</code>.<br>
|
||||
<b>Complexity:</b> <code>O(log(n))</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>size_type rank(iterator position)const;
|
||||
</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid iterator of the index.<br>
|
||||
<b>Effects:</b> Returns the rank of <code>position</code>.<br>
|
||||
<b>Complexity:</b> <code>O(log(n))</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename CompatibleKey> size_type find_rank(const CompatibleKey& x)const;
|
||||
</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
|
||||
<code>key_compare</code>.<br>
|
||||
<b>Effects:</b> Equivalent to <code>rank(find(k))</code>.<br>
|
||||
<b>Complexity:</b> <code>O(log(n))</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename CompatibleKey,typename CompatibleCompare><br>
|
||||
size_type find_rank(const CompatibleKey& x,const CompatibleCompare& comp)const;
|
||||
</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleCompare</code>)
|
||||
is a compatible extension of <code>key_compare</code>.<br>
|
||||
<b>Effects:</b> Equivalent to <code>rank(find(x,comp))</code>.<br>
|
||||
<b>Complexity:</b> <code>O(log(n))</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename CompatibleKey><br>
|
||||
size_type lower_bound_rank(const CompatibleKey& x)const;
|
||||
</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
|
||||
<code>key_compare</code>.<br>
|
||||
<b>Effects:</b> Equivalent to <code>rank(lower_bound(x))</code>.<br>
|
||||
<b>Complexity:</b> <code>O(log(n))</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename CompatibleKey,typename CompatibleCompare><br>
|
||||
size_type lower_bound_rank(const CompatibleKey& x,const CompatibleCompare& comp)const;
|
||||
</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleCompare</code>)
|
||||
is a compatible extension of <code>key_compare</code>.<br>
|
||||
<b>Effects:</b> Equivalent to <code>rank(lower_bound(x,comp))</code>.<br>
|
||||
<b>Complexity:</b> <code>O(log(n))</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename CompatibleKey><br>
|
||||
size_type upper_bound_rank(const CompatibleKey& x)const;
|
||||
</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
|
||||
<code>key_compare</code>.<br>
|
||||
<b>Effects:</b> Equivalent to <code>rank(upper_bound(x))</code>.<br>
|
||||
<b>Complexity:</b> <code>O(log(n))</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename CompatibleKey,typename CompatibleCompare><br>
|
||||
size_type upper_bound_rank(const CompatibleKey& x,const CompatibleCompare& comp)const;
|
||||
</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleCompare</code>)
|
||||
is a compatible extension of <code>key_compare</code>.<br>
|
||||
<b>Effects:</b> Equivalent to <code>rank(upper_bound(x,comp))</code>.<br>
|
||||
<b>Complexity:</b> <code>O(log(n))</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename CompatibleKey><br>
|
||||
std::pair<size_type,size_type> equal_range_rank(<br>
|
||||
const CompatibleKey& x)const;
|
||||
</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
|
||||
<code>key_compare</code>.<br>
|
||||
<b>Effects:</b> Equivalent to <code>make_pair(lower_bound_rank(x),upper_bound_rank(x))</code>.<br>
|
||||
<b>Complexity:</b> <code>O(log(n))</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename CompatibleKey,typename CompatibleCompare><br>
|
||||
std::pair<size_type,size_type> equal_range_rank(<br>
|
||||
const CompatibleKey& x,const CompatibleCompare& comp)const;
|
||||
</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleCompare</code>)
|
||||
is a compatible extension of <code>key_compare</code>.<br>
|
||||
<b>Effects:</b> Equivalent to
|
||||
<code>make_pair(lower_bound_rank(x,comp),upper_bound_rank(x,comp))</code>.<br>
|
||||
<b>Complexity:</b> <code>O(log(n))</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename LowerBounder,typename UpperBounder><br>
|
||||
std::pair<size_type,size_type> range_rank(<br>
|
||||
LowerBounder lower,UpperBounder upper)const;
|
||||
</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>LowerBounder</code> and <code>UpperBounder</code> are
|
||||
a lower and upper bounder of <code>key_compare</code>, respectively.<br>
|
||||
<b>Effects:</b> Equivalent to
|
||||
<blockquote><pre>
|
||||
<span class=keyword>auto</span> <span class=identifier>p</span><span class=special>=</span><span class=identifier>range</span><span class=special>(</span><span class=identifier>lower</span><span class=special>,</span><span class=identifier>upper</span><span class=special>);</span>
|
||||
<span class=keyword>return</span> <span class=identifier>make_pair</span><span class=special>(</span><span class=identifier>rank</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=identifier>rank</span><span class=special>(</span><span class=identifier>p</span><span class=special>.</span><span class=identifier>second</span><span class=special>));</span>
|
||||
</pre></blockquote>
|
||||
<b>Complexity:</b> <code>O(log(n))</code>.<br>
|
||||
<b>Variants:</b> In place of <code>lower</code> or <code>upper</code> (or both),
|
||||
the singular value <code>boost::multi_index::unbounded</code> can be
|
||||
provided. This acts as a predicate which all values of type <code>key_type</code>
|
||||
satisfy.<br>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="serialization">Serialization</a></h4>
|
||||
|
||||
<p>
|
||||
The prerequisites and postconditions associated to serialization of
|
||||
<code>multi_index_container</code>s with ranked indices are exactly the same
|
||||
as those of <a href="ord_indices.html#serialization">ordered indices</a>.
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="prev_link"><a href="ord_indices.html"><img src="../prev.gif" alt="ordered_indices" border="0"><br>
|
||||
Ordered indices
|
||||
</a></div>
|
||||
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.MultiIndex reference" border="0"><br>
|
||||
Boost.MultiIndex reference
|
||||
</a></div>
|
||||
<div class="next_link"><a href="hash_indices.html"><img src="../next.gif" alt="hashed indices" border="0"><br>
|
||||
Hashed indices
|
||||
</a></div><br clear="all" style="clear: all;">
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised May 4th 2015</p>
|
||||
|
||||
<p>© Copyright 2003-2015 Joaquín M López Muñoz.
|
||||
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">
|
||||
http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+123
-317
@@ -41,7 +41,6 @@ Random access indices
|
||||
<li><a href="#complexity_signature">Complexity signature</a></li>
|
||||
<li><a href="#instantiation_types">Instantiation types</a></li>
|
||||
<li><a href="#constructors">Constructors, copy and assignment</a></li>
|
||||
<li><a href="#iterators">Iterators</a></li>
|
||||
<li><a href="#capacity">Capacity operations</a></li>
|
||||
<li><a href="#modifiers">Modifiers</a></li>
|
||||
<li><a href="#list_operations">List operations</a></li>
|
||||
@@ -92,8 +91,6 @@ its associated <a href="#seq_indices">sequenced index</a> class.
|
||||
<code>"boost/multi_index/sequenced_index.hpp"</code></a> synopsis</a></h2>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=preprocessor>#include</span> <span class=special><</span><span class=identifier>initializer_list</span><span class=special>></span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>multi_index</span><span class=special>{</span>
|
||||
@@ -152,34 +149,35 @@ like <code>std::list</code>. Elements in a sequenced index are by default
|
||||
sorted according to their order of insertion: this means that new elements
|
||||
inserted through a different index of the <code>multi_index_container</code> are appended
|
||||
to the end of the sequenced index. Additionally, the index allows for free
|
||||
reordering of elements in the same vein as <code>std::list</code> does.
|
||||
Iterators (including to the end of the index) and pointers and references to an element
|
||||
remain valid during the lifetime of the associated container (which can change
|
||||
upon swapping), or until the referred-to element is erased or extracted;
|
||||
pointers and references to an extracted element, but not so for iterators,
|
||||
become valid again once the element is re-inserted.
|
||||
reordering of elements in the same vein as <code>std::list</code> does. Validity
|
||||
of iterators and references to elements is preserved in all operations.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Except where noted or if the corresponding interface does not exist, sequenced
|
||||
indices verify the same container requirements as <code>std::list</code>:
|
||||
we only provide descriptions of those types and operations that are either not
|
||||
present in <code>std::list</code> or behave differently. Some of the
|
||||
most important differences are:
|
||||
There are a number of differences with respect to <code>std::lists</code>:
|
||||
<ul>
|
||||
<li>The complexity of some operations, notably insertion and deletion, differ
|
||||
from those of <code>std::list</code>.
|
||||
</li>
|
||||
<li>Sequenced indices are not <a href="http://www.sgi.com/tech/stl/Assignable.html">
|
||||
<code>Assignable</code></a> (like any other index.)</li>
|
||||
<li>Unlike as in <code>std::list</code>, insertions into a sequenced index
|
||||
may fail due to clashings with other indices. This alters the semantics
|
||||
of the operations provided with respect to their analogues in
|
||||
<code>std::list</code>.
|
||||
</li>
|
||||
<li>Elements in a sequenced index are not mutable, and can only be changed
|
||||
in place by means of <a href="#replace"><code>replace</code></a> and
|
||||
by means of <a href="#replace"><code>replace</code></a> and
|
||||
<a href="#modify"><code>modify</code></a> member functions.
|
||||
</li>
|
||||
</ul>
|
||||
Having these restrictions into account, sequenced indices are models
|
||||
of <a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">
|
||||
<code>Reversible Container</code></a>,
|
||||
<a href="http://www.sgi.com/tech/stl/FrontInsertionSequence.html">
|
||||
<code>Front Insertion Sequence</code></a> and
|
||||
<a href="http://www.sgi.com/tech/stl/BackInsertionSequence.html">
|
||||
<code>Back Insertion Sequence</code></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>
|
||||
|
||||
<blockquote><pre>
|
||||
@@ -195,63 +193,50 @@ most important differences are:
|
||||
<span class=keyword>public</span><span class=special>:</span>
|
||||
<span class=comment>// types:</span>
|
||||
|
||||
<span class=keyword>typedef</span> <span class=identifier>Value</span> <span class=identifier>value_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>tuples</span><span class=special>::</span><span class=identifier>null_type</span> <span class=identifier>ctor_args</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>TagList</span> <span class=identifier>tag_list</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>Allocator</span> <span class=identifier>allocator_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>node_type</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=identifier>tuples</span><span class=special>::</span><span class=identifier>null_type</span> <span class=identifier>ctor_args</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>Allocator</span> <span class=identifier>allocator_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>allocator_type</span><span class=special>::</span><span class=identifier>reference</span> <span class=identifier>reference</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>allocator_type</span><span class=special>::</span><span class=identifier>const_reference</span> <span class=identifier>const_reference</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>const_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>size_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>difference_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>size_t</span> <span class=identifier>size_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>ptrdiff_t</span> <span class=identifier>difference_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>allocator_type</span><span class=special>::</span><span class=identifier>pointer</span> <span class=identifier>pointer</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>allocator_type</span><span class=special>::</span><span class=identifier>const_pointer</span> <span class=identifier>const_pointer</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>equivalent to
|
||||
std::reverse_iterator<iterator></b> <span class=identifier>reverse_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>equivalent to
|
||||
std::reverse_iterator<const_iterator></b> <span class=identifier>const_reverse_iterator</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>same as owning container </b><span class=identifier>node_type</span><span class=special>;</span>
|
||||
<span class=keyword>typedef</span> <b>following [container.insert.return] spec </b><span class=identifier>insert_return_type</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// construct/copy/destroy:</span>
|
||||
|
||||
<b>index class name</b><span class=special>&</span> <span class=keyword>operator</span><span class=special>=(</span><span class=keyword>const</span> <b>index class name</b><span class=special>&</span> <span class=identifier>x</span><span class=special>);</span>
|
||||
<b>index class name</b><span class=special>&</span> <span class=keyword>operator</span><span class=special>=(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special><</span><span class=identifier>value_type</span><span class=special>></span> <span class=identifier>list</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> <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>
|
||||
<span class=keyword>void</span> <span class=identifier>assign</span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special><</span><span class=identifier>value_type</span><span class=special>></span> <span class=identifier>list</span><span class=special>);</span>
|
||||
<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>
|
||||
|
||||
<span class=identifier>allocator_type</span> <span class=identifier>get_allocator</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</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=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>iterator</span> <span class=identifier>end</span><span class=special>()</span><span class=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>reverse_iterator</span> <span class=identifier>rbegin</span><span class=special>()</span><span class=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>reverse_iterator</span> <span class=identifier>rend</span><span class=special>()</span><span class=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_iterator</span> <span class=identifier>cbegin</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_iterator</span> <span class=identifier>cend</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_reverse_iterator</span> <span class=identifier>crbegin</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=identifier>const_reverse_iterator</span> <span class=identifier>crend</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
|
||||
|
||||
<span class=identifier>iterator</span> <span class=identifier>iterator_to</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>const_iterator</span> <span class=identifier>iterator_to</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>const</span><span class=special>;</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=keyword>noexcept</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=keyword>noexcept</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=keyword>noexcept</span><span class=special>;</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> <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>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=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>
|
||||
|
||||
<span class=comment>// access:</span>
|
||||
|
||||
@@ -260,42 +245,25 @@ most important differences are:
|
||||
|
||||
<span class=comment>// modifiers:</span>
|
||||
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span><span class=special>...</span> <span class=identifier>Args</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> <span class=identifier>emplace_front</span><span class=special>(</span><span class=identifier>Args</span><span class=special>&&...</span> <span class=identifier>args</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> <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>
|
||||
<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=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=keyword>template</span><span class=special><</span><span class=keyword>typename</span><span class=special>...</span> <span class=identifier>Args</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> <span class=identifier>emplace_back</span><span class=special>(</span><span class=identifier>Args</span><span class=special>&&...</span> <span class=identifier>args</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> <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>
|
||||
<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=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=keyword>template</span><span class=special><</span><span class=keyword>typename</span><span class=special>...</span> <span class=identifier>Args</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> <span class=identifier>emplace</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Args</span><span class=special>&&...</span> <span class=identifier>args</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> <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>
|
||||
<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=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>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>
|
||||
<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=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>
|
||||
<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>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special><</span><span class=identifier>value_type</span><span class=special>></span> <span class=identifier>list</span><span class=special>);</span>
|
||||
<span class=identifier>insert_return_type</span> <span class=identifier>insert</span><span class=special>(</span><span class=identifier>const_iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>node_type</span><span class=special>&&</span> <span class=identifier>nh</span><span class=special>);</span>
|
||||
|
||||
<span class=identifier>node_type</span> <span class=identifier>extract</span><span class=special>(</span><span class=identifier>const_iterator</span> <span class=identifier>position</span><span class=special>);</span>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<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=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>typename</span> <span class=identifier>Modifier</span><span class=special>></span> <span class=keyword>bool</span> <span class=identifier>modify</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Modifier</span> <span class=identifier>mod</span><span class=special>);</span>
|
||||
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Modifier</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Rollback</span><span class=special>></span>
|
||||
<span class=keyword>bool</span> <span class=identifier>modify</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Modifier</span> <span class=identifier>mod</span><span class=special>,</span><span class=identifier>Rollback</span> <span class=identifier>back</span><span class=special>);</span>
|
||||
|
||||
<span class=keyword>void</span> <span class=identifier>swap</span><span class=special>(</span><b>index class name</b><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=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=keyword>void</span> <span class=identifier>clear</span><span class=special>();</span>
|
||||
|
||||
<span class=comment>// list operations:</span>
|
||||
|
||||
@@ -317,7 +285,7 @@ most important differences are:
|
||||
<span class=keyword>void</span> <span class=identifier>sort</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> <span class=identifier>sort</span><span class=special>(</span><span class=identifier>Compare</span> <span class=identifier>comp</span><span class=special>);</span>
|
||||
|
||||
<span class=keyword>void</span> <span class=identifier>reverse</span><span class=special>()</span><span class=keyword>noexcept</span><span class=special>;</span>
|
||||
<span class=keyword>void</span> <span class=identifier>reverse</span><span class=special>();</span>
|
||||
|
||||
<span class=comment>// rearrange operations:</span>
|
||||
|
||||
@@ -414,7 +382,7 @@ index specifier. Instantiations are dependent on the following types:
|
||||
<ul>
|
||||
<li><code>Value</code> from <code>multi_index_container</code>,</li>
|
||||
<li><code>Allocator</code> from <code>multi_index_container</code>,</li>
|
||||
<li><code>TagList</code> from the index specifier (if provided, otherwise <code>tag<></code> is assumed).</li>
|
||||
<li><code>TagList</code> from the index specifier (if provided).</li>
|
||||
</ul>
|
||||
<code>TagList</code> must be an instantiation of
|
||||
<a href="indices.html#tag"><code>tag</code></a>.
|
||||
@@ -440,22 +408,17 @@ objects to which <code>*this</code> and <code>x</code> belong, respectively.<br>
|
||||
<b>Returns:</b> <code>*this</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code><b>index class name</b>& operator=(std::initializer_list<value_type> list);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>a</span><span class=special>=</span><span class=identifier>list</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
where <code>a</code> is the <code>multi_index_container</code>
|
||||
object to which <code>*this</code> belongs.<br>
|
||||
<b>Returns:</b> <code>*this</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template <class InputIterator><br>
|
||||
void assign(InputIterator first,InputIterator last);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>InputIterator</code> is a model of
|
||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">
|
||||
<code>Input Iterator</code></a> over elements of type
|
||||
<code>value_type</code> or a type convertible to <code>value_type</code>.
|
||||
<code>first</code> and <code>last</code> are not iterators into any
|
||||
index of the <code>multi_index_container</code> to which this index belongs.
|
||||
<code>last</code> is reachable from <code>first</code>.</br>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>clear</span><span class=special>();</span>
|
||||
@@ -463,15 +426,6 @@ void assign(InputIterator first,InputIterator last);</code>
|
||||
</pre></blockquote>
|
||||
</blockquote>
|
||||
|
||||
<code>void assign(std::initializer_list<value_type> list);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>assign</span><span class=special>(</span><span class=identifier>list</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>list</span><span class=special>.</span><span class=identifier>end</span><span class=special>());</span>
|
||||
</pre></blockquote>
|
||||
</blockquote>
|
||||
|
||||
<code>void assign(size_type n,const value_type& value);</code>
|
||||
|
||||
<blockquote>
|
||||
@@ -482,127 +436,58 @@ void assign(InputIterator first,InputIterator last);</code>
|
||||
</pre></blockquote>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="iterators">Iterators</a></h4>
|
||||
|
||||
<code>iterator iterator_to(const value_type& x);<br>
|
||||
const_iterator iterator_to(const value_type& x)const;</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>x</code> is a reference to an element of the container.<br>
|
||||
<b>Returns:</b> An iterator to <code>x</code>.<br>
|
||||
<b>Complexity:</b> Constant.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="capacity">Capacity operations</a></h4>
|
||||
|
||||
<code>void resize(size_type n);<br>
|
||||
void resize(size_type n,const value_type& x);</code>
|
||||
<code>void resize(size_type n,const value_type& x=value_type());</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires (first version):</b> <code>value_type</code> is <code>DefaultInsertable</code>
|
||||
into <code>multi_index_container</code>.<br>
|
||||
<b>Requires (second version):</b> <code>value_type</code> is <code>CopyInsertable</code>
|
||||
into <code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> If <code>size()<n</code>, tries to append <code>n-size()</code> default-inserted
|
||||
elements (first version) or copies of <code>x</code> (second version) at the end of
|
||||
the index. If <code>n<size()</code>, erases the last <code>size()-n</code> elements.<br>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<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=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>
|
||||
<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=identifier>iterator</span> <span class=identifier>it</span><span class=special>=</span><span class=identifier>begin</span><span class=special>();</span>
|
||||
<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>
|
||||
<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>
|
||||
<span class=special>}</span>
|
||||
</pre></blockquote>
|
||||
<b>Note:</b> If an expansion is requested, the size of the index is not guaranteed
|
||||
to be <code>n</code> after this operation (other indices may ban insertions.)
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="modifiers">Modifiers</a></h4>
|
||||
|
||||
<code>template<typename... Args><br>
|
||||
std::pair<iterator,bool> emplace_front(Args&&... args);</code>
|
||||
<code>std::pair<iterator,bool> push_front(const value_type& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>emplace</span><span class=special>(</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>forward</span><span class=special><</span><span class=identifier>Args</span><span class=special>>(</span><span class=identifier>args</span><span class=special>)...);</span>
|
||||
</pre></blockquote>
|
||||
<b>Effects:</b> Inserts <code>x</code> at the beginning of the sequence if
|
||||
no other index of the <code>multi_index_container</code> bans the insertion.<br>
|
||||
<b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
|
||||
is <code>true</code> if and only if insertion took place. On successful
|
||||
insertion, <code>p.first</code> points to the element inserted; otherwise,
|
||||
<code>p.first</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.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>std::pair<iterator,bool> push_front(const value_type& x);</code><br>
|
||||
<code>std::pair<iterator,bool> push_front(value_type&& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>insert</span><span class=special>(</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>x</span><span class=special>);</span> <span class=comment>// lvalue ref version</span>
|
||||
<span class=identifier>insert</span><span class=special>(</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>move</span><span class=special>(</span><span class=identifier>x</span><span class=special>));</span> <span class=comment>// rvalue ref version</span>
|
||||
</pre></blockquote>
|
||||
<b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
|
||||
is <code>true</code> if and only if insertion took place. On successful
|
||||
insertion, <code>p.first</code> points to the element inserted; otherwise,
|
||||
<code>p.first</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.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename... Args><br>
|
||||
std::pair<iterator,bool> emplace_back(Args&&... args);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>emplace</span><span class=special>(</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>forward</span><span class=special><</span><span class=identifier>Args</span><span class=special>>(</span><span class=identifier>args</span><span class=special>)...);</span>
|
||||
</pre></blockquote>
|
||||
<b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
|
||||
is <code>true</code> if and only if insertion took place. On successful
|
||||
insertion, <code>p.first</code> points to the element inserted; otherwise,
|
||||
<code>p.first</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.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>std::pair<iterator,bool> push_back(const value_type& x);</code><br>
|
||||
<code>std::pair<iterator,bool> push_back(value_type&& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>insert</span><span class=special>(</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>x</span><span class=special>);</span> <span class=comment>// lvalue ref version</span>
|
||||
<span class=identifier>insert</span><span class=special>(</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>move</span><span class=special>(</span><span class=identifier>x</span><span class=special>));</span> <span class=comment>// rvalue ref version</span>
|
||||
</pre></blockquote>
|
||||
<b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
|
||||
is <code>true</code> if and only if insertion took place. On successful
|
||||
insertion, <code>p.first</code> points to the element inserted; otherwise,
|
||||
<code>p.first</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.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename... Args><br>
|
||||
std::pair<iterator,bool> emplace(iterator position,Args&&... args);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>value_type</code> is <code>EmplaceConstructible</code>
|
||||
into <code>multi_index_container</code> from <code>args</code>.<br>
|
||||
<b>Effects:</b> Inserts a <code>value_type</code> object constructed with
|
||||
<code>std::forward<Args>(args)...</code> before <code>position</code> if insertion
|
||||
is allowed by all other indices of the <code>multi_index_container</code>.<br>
|
||||
<b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
|
||||
is <code>true</code> if and only if insertion took place. On successful insertion,
|
||||
<code>p.first</code> points to the element inserted; otherwise, <code>p.first</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.<br>
|
||||
<b>Complexity:</b> <code>O(I(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong.<br>
|
||||
<b>Exception safety:</b> Strong.
|
||||
</blockquote>
|
||||
|
||||
<code>std::pair<iterator,bool> insert(iterator position,const value_type& x);</code><br>
|
||||
<code>std::pair<iterator,bool> insert(iterator position,value_type&& x);</code>
|
||||
|
||||
<code>std::pair<iterator,bool> push_back(const value_type& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires (first version):</b> <code>value_type</code> is <code>CopyInsertable</code>
|
||||
into <code>multi_index_container</code>.
|
||||
<code>position</code> is a valid iterator of the index.<br>
|
||||
<b>Requires (second version):</b> <code>value_type</code> is <code>MoveInsertable</code>
|
||||
into <code>multi_index_container</code>.
|
||||
<code>position</code> is a valid iterator of the index.<br>
|
||||
<b>Effects:</b> Inserts <code>x</code> at the end of the sequence if
|
||||
no other index of the <code>multi_index_container</code> bans the insertion.<br>
|
||||
<b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
|
||||
is <code>true</code> if and only if insertion took place. On successful
|
||||
insertion, <code>p.first</code> points to the element inserted; otherwise,
|
||||
<code>p.first</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.<br>
|
||||
<b>Complexity:</b> <code>O(I(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong.
|
||||
</blockquote>
|
||||
|
||||
<code>std::pair<iterator,bool> insert(iterator position,const value_type& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid iterator of the index.</br>
|
||||
<b>Effects:</b> Inserts <code>x</code> before <code>position</code> if insertion
|
||||
is allowed by all other indices of the <code>multi_index_container</code>.<br>
|
||||
<b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
|
||||
@@ -617,6 +502,7 @@ Note that more than one element can be causing insertion not to be allowed.<br>
|
||||
<code>void insert(iterator position,size_type n,const value_type& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid iterator of the index.</br>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<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=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>
|
||||
@@ -628,70 +514,27 @@ void insert(iterator position,InputIterator first,InputIterator last);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid iterator of the index.
|
||||
<code>InputIterator</code> is an input iterator.
|
||||
<code>value_type</code> is
|
||||
<code>EmplaceConstructible</code> into
|
||||
<code>multi_index_container</code> from <code>*first</code>.
|
||||
<code>InputIterator</code> is a model of
|
||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">
|
||||
<code>Input Iterator</code></a> over elements of type
|
||||
<code>value_type</code> or a type convertible to <code>value_type</code>.
|
||||
<code>first</code> and <code>last</code> are not iterators into any
|
||||
index of the <code>multi_index_container</code> to which this index belongs.
|
||||
<code>last</code> is reachable from <code>first</code>.<br>
|
||||
<code>last</code> is reachable from <code>first</code>.</br>
|
||||
<b>Effects:</b>
|
||||
For each element of [<code>first</code>, <code>last</code>), in this
|
||||
order, inserts it before <code>position</code> if insertion is allowed by all
|
||||
other indices of the <code>multi_index_container</code>.<br>
|
||||
<blockquote><pre>
|
||||
<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>
|
||||
</pre></blockquote>
|
||||
<b>Complexity:</b> <code>O(m*I(n+m))</code>, where <code>m</code> is the
|
||||
number of elements in [<code>first</code>,<code>last</code>).<br>
|
||||
<b>Exception safety:</b> Basic.
|
||||
</blockquote>
|
||||
|
||||
<code>void insert(iterator position,std::initializer_list<value_type> list);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b>
|
||||
<blockquote><pre>
|
||||
<span class=identifier>insert</span><span class=special>(</span><span class=identifier>position</span><span class=special>,</span><span class=identifier>list</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>list</span><span class=special>.</span><span class=identifier>end</span><span class=special>());</span>
|
||||
</pre></blockquote>
|
||||
</blockquote>
|
||||
|
||||
<code>insert_return_type insert(const_iterator position,node_type&& nh);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>nh.empty() || get_allocator()==nh.get_allocator()</code>.<br>
|
||||
<b>Effects:</b> Does nothing if <code>nh</code> is empty; otherwise,
|
||||
inserts the node owned by <code>nh</code> before <code>position</code> if insertion
|
||||
is allowed by all other indices of the <code>multi_index_container</code>.<br>
|
||||
<b>Postconditions:</b> <code>nh</code> is empty.<br>
|
||||
<b>Returns:</b> A value <code>p</code> of type <code>insert_return_type</code>.
|
||||
If <code>nh</code> is empty, <code>p.position</code> is <code>end()</code>,
|
||||
<code>p.inserted</code> is <code>false</code> and <code>p.node</code> is empty;
|
||||
on successful insertion, <code>p.position</code> points to the element inserted,
|
||||
<code>p.inserted</code> is <code>true</code> and <code>p.node</code>
|
||||
is empty;
|
||||
if the insertion failed, <code>p.position</code> points to an element that caused
|
||||
the insertion to be banned, <code>p.inserted</code> is <code>false</code> and
|
||||
<code>p.node</code> owns the original node.
|
||||
Note that more than one element can be causing insertion not to be allowed.<br>
|
||||
<b>Complexity:</b> <code>O(I(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong. If an exception
|
||||
is thrown, <code>nh</code> is not changed.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>node_type extract(const_iterator position);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid dereferenceable iterator
|
||||
of the index.<br>
|
||||
<b>Effects:</b> Extracts the node of the element pointed to by <code>position</code>.<br>
|
||||
<b>Returns:</b> A node handle owning the extracted node.<br>
|
||||
<b>Complexity:</b> <code>O(D(n))</code>.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>iterator erase(iterator position);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid dereferenceable iterator
|
||||
of the index.<br>
|
||||
of the index.</br>
|
||||
<b>Effects:</b> Deletes the element pointed to by <code>position</code>.<br>
|
||||
<b>Returns:</b> An iterator pointing to the element immediately following
|
||||
the one that was deleted, or <code>end()</code>
|
||||
@@ -712,14 +555,11 @@ the number of elements in [<code>first</code>,<code>last</code>).<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.<br>
|
||||
</blockquote>
|
||||
|
||||
<a name="replace"><code>bool replace(iterator position,const value_type& x);</code></a><br>
|
||||
<code>bool replace(iterator position,value_type&& x);</code>
|
||||
<a name="replace"><code>bool replace(iterator position,const value_type& x);</code></a>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires (first version):</b> <code>value_type</code> is <code>CopyAssignable</code>.
|
||||
<code>position</code> is a valid dereferenceable iterator of the index.<br>
|
||||
<b>Requires (second version):</b> <code>value_type</code> is <code>MoveAssignable</code>.
|
||||
<code>position</code> is a valid dereferenceable iterator of the index.<br>
|
||||
<b>Requires:</b> <code>position</code> is a valid dereferenceable iterator
|
||||
of the index.</br>
|
||||
<b>Effects:</b> Assigns the value <code>x</code> to the element pointed
|
||||
to by <code>position</code> into the <code>multi_index_container</code> to which
|
||||
the index belongs if replacing is allowed by all other indices of the
|
||||
@@ -738,19 +578,16 @@ belongs remains in its original state.
|
||||
<code>template<typename Modifier> bool modify(iterator position,Modifier mod);</code></a>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>mod</code> is a unary function object
|
||||
accepting arguments of type
|
||||
<b>Requires:</b> <code>Modifier</code> is a model of
|
||||
<a href="http://www.sgi.com/tech/stl/UnaryFunction.html">
|
||||
<code>Unary Function</code></a> accepting arguments of type
|
||||
<code>value_type&</code>. <code>position</code> is a valid dereferenceable
|
||||
iterator of the index.
|
||||
The execution of <code>mod(e)</code>, where <code>e</code> is the element
|
||||
pointed to by <code>position</code>, does not invoke any operation of the
|
||||
<code>multi_index_container</code> after <code>e</code> is directly modified
|
||||
or, before modification, if the operation would invalidate <code>position</code>.<br>
|
||||
iterator of the index.</br>
|
||||
<b>Effects:</b> Calls <code>mod(e)</code> where <code>e</code> is the element
|
||||
pointed to by <code>position</code> and rearranges <code>*position</code> into
|
||||
all the indices of the <code>multi_index_container</code>. Rearrangement on sequenced
|
||||
indices does not change the position of the element with respect to the index;
|
||||
rearrangement on other indices may or might not succeed. If the rearrangement
|
||||
rearrangement on other indices may or might not suceed. If the rearrangement
|
||||
fails, the element is erased.<br>
|
||||
<b>Postconditions:</b> Validity of <code>position</code> is preserved if the
|
||||
operation succeeds.<br>
|
||||
@@ -758,46 +595,10 @@ operation succeeds.<br>
|
||||
otherwise.<br>
|
||||
<b>Complexity:</b> <code>O(M(n))</code>.<br>
|
||||
<b>Exception safety:</b> Basic. If an exception is thrown by some
|
||||
user-provided operation (including <code>mod</code>), then
|
||||
user-provided operation (except possibly <code>mod</code>), then
|
||||
the element pointed to by <code>position</code> is erased.
|
||||
</blockquote>
|
||||
|
||||
<code>template<typename Modifier,typename Rollback><br>
|
||||
bool modify(iterator position,Modifier mod,Rollback back);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>mod</code> and <code>back</code> are unary function
|
||||
objects accepting arguments of type
|
||||
<code>value_type&</code>. <code>position</code> is a valid dereferenceable
|
||||
iterator of the index.
|
||||
The execution of <code>mod(e)</code>, where <code>e</code> is the element
|
||||
pointed to by <code>position</code>, does not invoke any operation of the
|
||||
<code>multi_index_container</code> after <code>e</code> is directly modified
|
||||
or, before modification, if the operation would invalidate <code>position</code>.
|
||||
<code>back(e)</code> does not invoke any operation of the
|
||||
<code>multi_index_container</code>.<br>
|
||||
<b>Effects:</b> Calls <code>mod(e)</code> where <code>e</code> is the element
|
||||
pointed to by <code>position</code> and tries to rearrange <code>*position</code> into
|
||||
all the indices of the <code>multi_index_container</code>. Rearrangement on sequenced
|
||||
indices does not change the position of the element with respect to the index;
|
||||
rearrangement on other indices may or might not succeed.
|
||||
If the rearrangement fails, <code>back(e)</code> is invoked: if the resulting value
|
||||
of <code>e</code> is consistent with its original position and constraints in all
|
||||
indices, the element is kept, otherwise it is erased.<br>
|
||||
<b>Postconditions:</b> Validity of <code>position</code> is preserved except if
|
||||
the element is erased under the conditions described below.<br>
|
||||
<b>Returns:</b> <code>true</code> if the operation succeeded, <code>false</code>
|
||||
otherwise.<br>
|
||||
<b>Complexity:</b> <code>O(M(n))</code>.<br>
|
||||
<b>Exception safety:</b> Strong, except if <code>mod</code> or <code>back</code> throw an
|
||||
exception or <code>back(e)</code> fails to properly restore the element or there is
|
||||
a throwing user-provided operation after invoking <code>back(e)</code>, in which cases
|
||||
the modified element is erased. If <code>back</code>
|
||||
throws inside the handling code executing after some other user-provided
|
||||
operation has thrown, it is the exception generated by <code>back</code> that
|
||||
is rethrown.
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="list_operations">List operations</a></h4>
|
||||
|
||||
<p>
|
||||
@@ -813,9 +614,9 @@ same <code>multi_index_container</code>.
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>position</code> is a valid iterator of the index.
|
||||
<code>&x!=this</code>.<br>
|
||||
<code>&x!=this</code>.</br>
|
||||
<b>Effects:</b> Inserts the contents of <code>x</code> before <code>position</code>,
|
||||
in the same order as they were in <code>x</code>. Those elements successfully
|
||||
in the same order as they were in <code>x</code>. Those elements succesfully
|
||||
inserted are erased from <code>x</code>.<br>
|
||||
<b>Complexity:</b> <code>O(x.size()*I(n+x.size()) + x.size()*D(x.size()))</code>.<br>
|
||||
<b>Exception safety:</b> Basic.<br>
|
||||
@@ -827,9 +628,9 @@ inserted are erased from <code>x</code>.<br>
|
||||
<b>Requires:</b> <code>position</code> is a valid iterator of the index.
|
||||
<code>i</code> is a valid dereferenceable iterator <code>x</code>.<br>
|
||||
<b>Effects:</b> Inserts the element pointed to by <code>i</code> before
|
||||
<code>position</code>: if insertion is successful, the element is erased from
|
||||
<code>position</code>: if insertion is succesful, the element is erased from
|
||||
<code>x</code>. In the special case <code>&x==this</code>, no copy or
|
||||
deletion is performed, and the operation is always successful. If
|
||||
deletion is performed, and the operation is always succesful. If
|
||||
<code>position==i</code>, no operation is performed.<br>
|
||||
<b>Postconditions:</b> If <code>&x==this</code>, no iterator or reference
|
||||
is invalidated.<br>
|
||||
@@ -847,10 +648,10 @@ otherwise, strong.<br>
|
||||
<code>last</code> is reachable from <code>first</code>. <code>position</code>
|
||||
is not in the range [<code>first</code>,<code>last</code>).<br>
|
||||
<b>Effects:</b> For each element in the range [<code>first</code>,<code>last</code>),
|
||||
insertion is tried before <code>position</code>; if the operation is successful,
|
||||
insertion is tried before <code>position</code>; if the operation is succesful,
|
||||
the element is erased from <code>x</code>. In the special case
|
||||
<code>&x==this</code>, no copy or deletion is performed, and insertions are
|
||||
always successful.<br>
|
||||
always succesful.<br>
|
||||
<b>Postconditions:</b> If <code>&x==this</code>, no iterator or reference
|
||||
is invalidated.<br>
|
||||
<b>Complexity:</b> If <code>&x==this</code>, constant; otherwise
|
||||
@@ -906,10 +707,11 @@ is the number of elements erased.<br>
|
||||
<code>void merge(index class name& x);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>std::less<value_type></code> induces a
|
||||
strict weak ordering over <code>value_type</code>.
|
||||
<b>Requires:</b> <code>std::less<value_type></code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">
|
||||
<code>Strict Weak Ordering</code></a> over <code>value_type</code>.
|
||||
Both the index and <code>x</code> are sorted according to
|
||||
<code>std::less<value_type></code>.<br>
|
||||
<code>std::less<value_type></code>.<br>
|
||||
<b>Effects:</b> Attempts to insert every element of <code>x</code> into the
|
||||
corresponding position of the index (according to the order). Elements
|
||||
successfully inserted are erased from <code>x</code>. The resulting sequence
|
||||
@@ -926,11 +728,12 @@ references is preserved.<br>
|
||||
otherwise, basic.<br>
|
||||
</blockquote>
|
||||
|
||||
<code>template <typename Compare> void merge(index class name& x,Compare comp);</code>
|
||||
<code>template <typename Compare> void merge(index class name& x,Compare comp);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>Compare</code> induces a
|
||||
strict weak ordering over <code>value_type</code>.
|
||||
<b>Requires:</b> <code>Compare</code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">
|
||||
<code>Strict Weak Ordering</code></a> over <code>value_type</code>.
|
||||
Both the index and <code>x</code> are sorted according to <code>comp</code>.<br>
|
||||
<b>Effects:</b> Attempts to insert every element of <code>x</code> into the
|
||||
corresponding position of the index (according to <code>comp</code>).
|
||||
@@ -951,22 +754,24 @@ otherwise, basic.<br>
|
||||
<code>void sort();</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>std::less<value_type></code> induces a
|
||||
strict weark ordering over <code>value_type</code>.<br>
|
||||
<b>Requires:</b> <code>std::less<value_type></code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">
|
||||
<code>Strict Weak Ordering</code></a> over <code>value_type</code>.<br>
|
||||
<b>Effects:</b> Sorts the index according to
|
||||
<code>std::less<value_type></code>. The sorting is stable, i.e.
|
||||
<code>std::less<value_type></code>. The sorting is stable, i.e.
|
||||
equivalent elements preserve their relative position.<br>
|
||||
<b>Postconditions:</b> Validity of iterators and references is preserved.<br>
|
||||
<b>Complexity:</b> <code>O(n*log(n))</code>.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code> if
|
||||
<code>std::less<value_type></code> does not throw; otherwise, basic.
|
||||
<code>std::less<value_type></code> does not throw; otherwise, basic.
|
||||
</blockquote>
|
||||
|
||||
<code>template <typename Compare> void sort(Compare comp);</code>
|
||||
<code>template <typename Compare> void sort(Compare comp);</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> <code>Compare</code> induces a
|
||||
strict weak ordering over <code>value_type</code>.<br>
|
||||
<b>Requires:</b> <code>Compare</code> is a
|
||||
<a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">
|
||||
<code>Strict Weak Ordering</code></a> over <code>value_type</code>.<br>
|
||||
<b>Effects:</b> Sorts the index according to <code>comp</code>. The sorting
|
||||
is stable, i.e. equivalent elements preserve their relative position.<br>
|
||||
<b>Postconditions:</b> Validity of iterators and references is preserved.<br>
|
||||
@@ -975,12 +780,13 @@ is stable, i.e. equivalent elements preserve their relative position.<br>
|
||||
not throw; otherwise, basic.
|
||||
</blockquote>
|
||||
|
||||
<code>void reverse()noexcept;</code>
|
||||
<code>void reverse();</code>
|
||||
|
||||
<blockquote>
|
||||
<b>Effects:</b> Reverses the order of the elements in the index.<br>
|
||||
<b>Postconditions:</b> Validity of iterators and references is preserved.<br>
|
||||
<b>Complexity:</b> <code>O(n)</code>.<br>
|
||||
<b>Exception safety:</b> <code>nothrow</code>.
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="rearrange_operations">Rearrange operations</a></h4>
|
||||
@@ -1056,7 +862,7 @@ input archive (XML archive) <code>ar</code>.
|
||||
|
||||
<blockquote>
|
||||
<b>Requires:</b> No additional requirements to those imposed by the container.<br>
|
||||
<b>Postconditions:</b> On successful loading, each of the elements of
|
||||
<b>Postconditions:</b> On succesful loading, each of the elements of
|
||||
[<code>begin()</code>, <code>end()</code>) is a restored copy of the corresponding
|
||||
element in [<code>m.get<i>().begin()</code>, <code>m.get<i>().end()</code>),
|
||||
where <code>i</code> is the position of the sequenced index in the container.
|
||||
@@ -1074,7 +880,7 @@ Operation: loading of an <code>iterator</code> or <code>const_iterator</code>
|
||||
<code>it'</code> from an input archive (XML archive) <code>ar</code>.
|
||||
|
||||
<blockquote>
|
||||
<b>Postconditions:</b> On successful loading, if <code>it</code> was dereferenceable
|
||||
<b>Postconditions:</b> On succesful loading, if <code>it</code> was dereferenceable
|
||||
then <code>*it'</code> is the restored copy of <code>*it</code>, otherwise
|
||||
<code>it'==end()</code>.<br>
|
||||
<b>Note:</b> It is allowed that <code>it</code> be a <code>const_iterator</code>
|
||||
@@ -1095,9 +901,9 @@ Random access indices
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised May 9th 2020</p>
|
||||
<p>Revised February 6th 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2020 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
+3
-538
@@ -27,550 +27,15 @@ Acknowledgements
|
||||
|
||||
<hr>
|
||||
|
||||
|
||||
<h2>Contents</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="#boost_1_74">Boost 1.74 release</a></li>
|
||||
<li><a href="#boost_1_73">Boost 1.73 release</a></li>
|
||||
<li><a href="#boost_1_71">Boost 1.71 release</a></li>
|
||||
<li><a href="#boost_1_70">Boost 1.70 release</a></li>
|
||||
<li><a href="#boost_1_69">Boost 1.69 release</a></li>
|
||||
<li><a href="#boost_1_68">Boost 1.68 release</a></li>
|
||||
<li><a href="#boost_1_67">Boost 1.67 release</a></li>
|
||||
<li><a href="#boost_1_66">Boost 1.66 release</a></li>
|
||||
<li><a href="#boost_1_64">Boost 1.64 release</a></li>
|
||||
<li><a href="#boost_1_62">Boost 1.62 release</a></li>
|
||||
<li><a href="#boost_1_60">Boost 1.60 release</a></li>
|
||||
<li><a href="#boost_1_59">Boost 1.59 release</a></li>
|
||||
<li><a href="#boost_1_58">Boost 1.58 release</a></li>
|
||||
<li><a href="#boost_1_57">Boost 1.57 release</a></li>
|
||||
<li><a href="#boost_1_56">Boost 1.56 release</a></li>
|
||||
<li><a href="#boost_1_55">Boost 1.55 release</a></li>
|
||||
<li><a href="#boost_1_54">Boost 1.54 release</a></li>
|
||||
<li><a href="#boost_1_49">Boost 1.49 release</a></li>
|
||||
<li><a href="#boost_1_48">Boost 1.48 release</a></li>
|
||||
<li><a href="#boost_1_47">Boost 1.47 release</a></li>
|
||||
<li><a href="#boost_1_44">Boost 1.44 release</a></li>
|
||||
<li><a href="#boost_1_43">Boost 1.43 release</a></li>
|
||||
<li><a href="#boost_1_42">Boost 1.42 release</a></li>
|
||||
<li><a href="#boost_1_41">Boost 1.41 release</a></li>
|
||||
<li><a href="#boost_1_38">Boost 1.38 release</a></li>
|
||||
<li><a href="#boost_1_37">Boost 1.37 release</a></li>
|
||||
<li><a href="#boost_1_36">Boost 1.36 release</a></li>
|
||||
<li><a href="#boost_1_35">Boost 1.35 release</a></li>
|
||||
<li><a href="#boost_1_34">Boost 1.34 release</a></li>
|
||||
<li><a href="#boost_1_33_1">Boost 1.33.1 release</a></li>
|
||||
<li><a href="#boost_1_33">Boost 1.33 release</a></li>
|
||||
</ul>
|
||||
|
||||
<h2><a name="boost_1_74">Boost 1.74 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>
|
||||
Added <a href="tutorial/basics.html#node_handling">node extraction and insertion</a>
|
||||
following the analogous interface of associative containers as introduced in C++17.
|
||||
This feature has also been extended to non key-based indices, in contrast to C++
|
||||
standard library sequence containers, which do not provide such functionality.
|
||||
</li>
|
||||
<li>Clarified documentation on read/write key extractors
|
||||
(<a href="https://github.com/boostorg/multi_index/issues/32">issue #32</a>).
|
||||
</li>
|
||||
<li>Maintenance work.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_73">Boost 1.73 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li><code>multi_index_container</code> is now
|
||||
<a href="https://en.cppreference.com/w/cpp/named_req/AllocatorAwareContainer"><code>AllocatorAware</code></a>.
|
||||
</li>
|
||||
<li>Swapping of internal <code>KeyFromValue</code>, <code>Compare</code>, <code>Hash</code>
|
||||
and <code>Pred</code> objects now selects the appropriate <code>swap</code>
|
||||
function between <code>std::swap</code> and ADL candidates,
|
||||
in accordance with standard specifications in <b>[swappable.requirements]</b>
|
||||
(<a href="https://github.com/boostorg/multi_index/issues/29">issue #29</a>).
|
||||
</li>
|
||||
<li>Provided some internal copy constructors and assignment operators whose default
|
||||
implicit definition is deprecated in C++11 onwards (<b>[depr.impldec]</b>), which
|
||||
was warned about on some compilers.
|
||||
</li>
|
||||
<li>Maintenance work.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_71">Boost 1.71 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Added <a href="tutorial/key_extraction.html#x_mem_fun">variants of
|
||||
<code>const_mem_fun</code> and <code>mem_fun</code></a> for
|
||||
differently qualified member functions
|
||||
(<a href="https://github.com/boostorg/multi_index/issues/24">issue #24</a>).
|
||||
</li>
|
||||
<li>Terse <a href="reference/key_extraction.html#key">key</a> specification syntax
|
||||
now correctly handles <code>noexcept</code>-specified member functions
|
||||
(<a href="https://github.com/boostorg/multi_index/issues/24">issue #24</a>).
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_70">Boost 1.70 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li><code>size_type</code> and <code>difference_type</code> are now
|
||||
defined as the allocator's same-named types. This will not make any
|
||||
difference in the vast majority of cases, but allows for some degree
|
||||
of control of resulting internal structures via user-defined allocator
|
||||
types (see
|
||||
<a href="https://github.com/boostorg/multi_index/issues/17">issue #17</a>
|
||||
for motivation). For the moment being, this change is <i>not</i>
|
||||
documented in the reference section (i.e., it has semi-official status).
|
||||
</li>
|
||||
<li>Maintenance work.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_69">Boost 1.69 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Introduced an alternative
|
||||
<a href="tutorial/key_extraction.html#key">terse key specification syntax</a>
|
||||
for C++17 compliant environments.
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_68">Boost 1.68 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Containers of moveable but non-copyable elements can now be serialized
|
||||
(ticket <a href="https://svn.boost.org/trac10/ticket/13478">#13478</a>).
|
||||
Thanks to Sébastien Paris for the report.
|
||||
</li>
|
||||
<li><code>multi_index_container</code>'s default constructor is no longer
|
||||
<code>explicit</code>
|
||||
(ticket <a href="https://svn.boost.org/trac10/ticket/13518">#13518</a>).
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_67">Boost 1.67 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Elements with overloaded <code>operator&</code> are now fully accepted
|
||||
(ticket <a href="https://svn.boost.org/trac10/ticket/13307">#13307</a>).
|
||||
Thanks to Daniel Frey for his updating
|
||||
<a href="../../utility/operators.htm#deref">Boost.Operators</a> to help
|
||||
fix this issue.
|
||||
</li>
|
||||
<li>Avoided usage of <code>std::allocator</code> members deprecated in C++17.
|
||||
Contributed by Daniela Engert.
|
||||
</li>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_66">Boost 1.66 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Made <code>modify</code> and <code>modify_key</code> more robust so that
|
||||
the modified element is erased if the modifier throws or the rollback
|
||||
functor does not properly restore the element (full discussion at
|
||||
ticket <a href="https://svn.boost.org/trac/boost/ticket/12542">#12542</a>).
|
||||
This is technically backwards incompatible; for instance, the following code:
|
||||
<blockquote><pre>
|
||||
<span class=identifier>c</span><span class=special>.</span><span class=identifier>modify</span><span class=special>(</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),[](</span><span class=keyword>auto</span><span class=special>&){</span><span class=keyword>throw</span> <span class=number>0</span><span class=special>;});</span>
|
||||
</pre></blockquote>
|
||||
keeps the container <code>c</code> untouched in former versions of Boost whereas
|
||||
now <code>c.begin()</code> is erased. Thanks to Jon Kalb for raising the issue.
|
||||
</li>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_64">Boost 1.64 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Fixed a bug related to ambiguous references in the presence of more than
|
||||
one ranked index
|
||||
(ticket <a href="https://svn.boost.org/trac/boost/ticket/12955">#12955</a>).
|
||||
</li>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_62">Boost 1.62 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_60">Boost 1.60 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Fixed an interoperability problem with <a href="http://www.qt.io/">Qt</a> due to the
|
||||
optional definition of a macro with name <code>foreach</code> in this framework.</li>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_59">Boost 1.59 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Added <a href="tutorial/indices.html#rnk_indices">ranked indices</a>.</li>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_58">Boost 1.58 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>The efficiency of lookup operations has improved in situations where they involve
|
||||
the generation of temporary values of <code>key_type</code>. Consider for instance
|
||||
the following code:
|
||||
<blockquote><pre>
|
||||
<span class=keyword>typedef</span> <span class=identifier>multi_index_container</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>indexed_by</span><span class=special><</span>
|
||||
<span class=identifier>ordered_unique</span><span class=special><</span><span class=identifier>identity</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=special>></span>
|
||||
<span class=special>></span> <span class=identifier>multi_t</span><span class=special>;</span>
|
||||
<span class=special>...</span>
|
||||
<span class=identifier>multi_t</span> <span class=identifier>m</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>"boost"</span><span class=special>);</span> <span class=comment>// passed a const char*, not a std::string</span>
|
||||
</pre></blockquote>
|
||||
In previous versions of the library, the <code>find</code> operation generates
|
||||
several temporary <code>std::string</code>s (one every time an internal comparison is made).
|
||||
In sufficiently advanced compilers, this is now avoided so that only one temporary is
|
||||
created.
|
||||
</li>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_57">Boost 1.57 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>When <code>std::tuple</code>s are available, these can be used for lookup operations
|
||||
in indices equipped with composite keys. <code>boost::tuple</code>s are also supported
|
||||
for backwards compatibility.
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_56">Boost 1.56 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>The <code>erase(iterator)</code> member function of hashed indices
|
||||
used to have poor performance under low load conditions due to the requirement
|
||||
that an iterator to the next element must be returned (see ticket
|
||||
<a href="https://svn.boost.org/trac/boost/ticket/4264">#4264</a>). In accordance with
|
||||
the resolution of <a href="http://lwg.github.io/issues/lwg-closed.html#579">LWG
|
||||
issue #579</a>, this problem has been fixed while maintaining the interface of
|
||||
<code>erase</code>, at the expense of using one more
|
||||
word of memory per element. In fact, C++ complexity requirements on unordered
|
||||
associative containers have been improved for hashed indices so that
|
||||
<ul>
|
||||
<li>deletion of a given element is unconditionally constant-time,</li>
|
||||
<li>worst-case performance is not <code>O(n)</code> but <code>O(n<sub>dist</sub>)</code>,
|
||||
where <code>n<sub>dist</sub></code> is the number of non-equivalent elements in the index.
|
||||
</li>
|
||||
</ul>
|
||||
Due to the fact that hashed indices rely on a new data structure, the internal representation of
|
||||
their iterators and local iterators have changed, which affects serialization: their corresponding
|
||||
serialization <a href="../../serialization/doc/tutorial.html#versioning">class version</a> has been
|
||||
bumped from 0 to 1. Old archives involving hashed index (local) iterators can be loaded
|
||||
by Boost 1.56 version of Boost.MultiIndex, but not the other way around.
|
||||
</li>
|
||||
<li>Hashed indices now provide <code>reserve</code>.</li>
|
||||
<li>Hashed indices can now be checked for equality and inequality following the
|
||||
(suitably adapted) C++ standard specification in <b>[unord.req]</b>.</li>
|
||||
<li>The public interface of Boost.MultiIndex provide <code>noexcept</code> specifications
|
||||
where appropriate (for compliant compilers).
|
||||
</li>
|
||||
<li>Improved performance of failed insertions into a <code>multi_index_container</code>.</li>
|
||||
<li>Much internal code aimed at supporting MSVC++ 7.0 and prior has been removed.
|
||||
Compilation times without this legacy code might be slightly faster.
|
||||
</li>
|
||||
<li>Fixed a bug with insertion via iterators dereferencing to rvalues
|
||||
(ticket <a href="https://svn.boost.org/trac/boost/ticket/9665">#9665</a>).
|
||||
</li>
|
||||
<li>Made Boost.MultiIndex compatible with <code>BOOST_BIND_NO_PLACEHOLDERS</code>
|
||||
(ticket <a href="https://svn.boost.org/trac/boost/ticket/9798">#9798</a>).
|
||||
</li>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_55">Boost 1.55 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Boost.MultiIndex has been brought to a higher level of compliance
|
||||
with C++11.
|
||||
<ul>
|
||||
<li><code>multi_index_container</code> is now efficiently movable.</li>
|
||||
<li>Initializer lists supported.</li>
|
||||
<li>Emplace functions provided.</li>
|
||||
<li>Non-copyable elements (such as <code>std::unique_ptr<T></code>) supported. This includes
|
||||
insertion of a range [<code>first</code>,<code>last</code>) where the iterators point to a type that is
|
||||
convertible to that of the element: no copy construction happens in the process.
|
||||
</li>
|
||||
<li>Random access indices provide <code>shrink_to_fit()</code>.</li>
|
||||
</ul>
|
||||
Refer to the <a href="compiler_specifics.html">compiler specifics</a> section for limitations
|
||||
on pre-C++11 compilers.
|
||||
</li>
|
||||
<li>The following classes are deprecated:
|
||||
<ul>
|
||||
<li><a href="reference/key_extraction.html#member_offset"><code>member_offset</code></a>,</li>
|
||||
<li><a href="reference/key_extraction.html#const_mem_fun_explicit"><code>const_mem_fun_explicit</code></a>,</li>
|
||||
<li><a href="reference/key_extraction.html#const_mem_fun_explicit"><code>mem_fun_explicit</code></a>,</li>
|
||||
<li><a href="reference/key_extraction.html#composite_key_result_equal_to"><code>composite_key_result_equal_to</code></a>,</li>
|
||||
<li><a href="reference/key_extraction.html#composite_key_result_less"><code>composite_key_result_less</code></a>,</li>
|
||||
<li><a href="reference/key_extraction.html#composite_key_result_greater"><code>composite_key_result_greater</code></a>,</li>
|
||||
<li><a href="reference/key_extraction.html#composite_key_result_hash"><code>composite_key_result_hash</code></a>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_54">Boost 1.54 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Suppressed some potential warnings described in
|
||||
tickets <a href="https://svn.boost.org/trac/boost/ticket/8034">#8034</a> and <a href="https://svn.boost.org/trac/boost/ticket/8129">#8129</a>.
|
||||
</li>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_49">Boost 1.49 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Suppressed a potential narrow conversion warning described in
|
||||
ticket <a href="https://svn.boost.org/trac/boost/ticket/3365">#3365</a>.
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_48">Boost 1.48 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Fixed a compatibility problem with
|
||||
<a href="../../../doc/html/foreach.html">Boost.Foreach</a>
|
||||
(ticket <a href="https://svn.boost.org/trac/boost/ticket/5741">#5741</a>).
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_47">Boost 1.47 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Fixed an ADL problem in
|
||||
<a href="reference/key_extraction.html#composite_key_compare"><code>composite_key_compare</code></a>
|
||||
related with <a href="../../../doc/html/ref.html">Boost.Ref</a>.
|
||||
</li>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_44">Boost 1.44 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>
|
||||
Fixed a bug preventing the use of <code>modify_key</code> with
|
||||
rollback in <a href="reference/ord_indices.html#modify_key">ordered</a> and
|
||||
<a href="reference/hash_indices.html#modify_key">hashed</a> indices when
|
||||
<code>Modifier</code> and <code>Rollback</code> are different types
|
||||
(ticket <a href="https://svn.boost.org/trac/boost/ticket/4130">#4130</a>).
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_43">Boost 1.43 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="../../serialization/doc/serialization.html#constructors">Serialization
|
||||
of non default constructible values</a> is now properly supported
|
||||
through user-provided facilities <code>save_construct_data</code> and
|
||||
<code>load_construct_data</code>.
|
||||
<code>multi_index_container</code> serialization
|
||||
<a href="../../serialization/doc/tutorial.html#versioning">class version</a> has been
|
||||
bumped from 1 to 2.
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_42">Boost 1.42 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_41">Boost 1.41 release</a></h2>
|
||||
<p>
|
||||
<ul>
|
||||
<li>Serialization now uses the portable
|
||||
<a href="../../serialization/doc/wrappers.html#collection_size_type"><code>collection_size_type</code></a>
|
||||
type instead of the original <code>std::size_t</code> (ticket
|
||||
<a href="https://svn.boost.org/trac/boost/ticket/3365">#3365</a>).
|
||||
<code>multi_index_container</code> serialization
|
||||
<a href="../../serialization/doc/tutorial.html#versioning">class version</a> has been
|
||||
bumped from 0 to 1.
|
||||
</li>
|
||||
<li>Fixed a concurrency bug in the implementation of
|
||||
<a href="tutorial/debug.html#safe_mode">safe mode</a>
|
||||
(ticket <a href="https://svn.boost.org/trac/boost/ticket/3462">#3462</a>).
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_38">Boost 1.38 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>These constructs are deprecated:
|
||||
<ul>
|
||||
<li><code>nth_index_iterator<MultiIndexContainer,N>::type</code>,</li>
|
||||
<li><code>multi_index_container<...>::nth_index_iterator<N>::type</code>,</li>
|
||||
<li><code>nth_index_const_iterator<MultiIndexContainer,N>::type</code>,</li>
|
||||
<li><code>multi_index_container<...>::nth_index_const_iterator<N>::type</code>,</li>
|
||||
<li><code>index_iterator<MultiIndexContainer,Tag>::type</code>,</li>
|
||||
<li><code>multi_index_container<...>::index_iterator<Tag>::type</code>,</li>
|
||||
<li><code>index_const_iterator<MultiIndexContainer,Tag>::type</code>,</li>
|
||||
<li><code>multi_index_container<...>::index_const_iterator<Tag>::type</code>.</li>
|
||||
</ul>
|
||||
Use the following instead:
|
||||
<ul>
|
||||
<li><code>nth_index<MultiIndexContainer,N>::type::iterator</code>,</li>
|
||||
<li><code>multi_index_container<...>::nth_index<N>::type::iterator</code>,</li>
|
||||
<li><code>nth_index<MultiIndexContainer,N>::type::const_iterator</code>,</li>
|
||||
<li><code>multi_index_container<...>::nth_index<N>::type::const_iterator</code>,</li>
|
||||
<li><code>index<MultiIndexContainer,Tag>::type::iterator</code>,</li>
|
||||
<li><code>multi_index_container<...>::index<Tag>::type::iterator</code>,</li>
|
||||
<li><code>index<MultiIndexContainer,Tag>::type::const_iterator</code>,</li>
|
||||
<li><code>multi_index_container<...>::index<Tag>::type::const_iterator</code>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_37">Boost 1.37 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_36">Boost 1.36 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li><a name="stable_update">On prior versions of the library, the <a href="tutorial/indices.html#hash_updating">update
|
||||
member functions</a> of hashed indices could alter the position of an element even if the
|
||||
associated key did not change with the update. This is legal but probably unexpected behavior.
|
||||
The functions have been rewritten to provide the additional guarantee that elements with
|
||||
unmodified key will not change position in hashed indices, just as always was the case with
|
||||
ordered indices. These guarantees are now documented in the reference.</a></li>
|
||||
<li>Added the constructor <code>multi_index_container::multi_index_container(const allocator_type&)</code>
|
||||
to mimic the equivalent interface in STL sequence containers.
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_35">Boost 1.35 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>New <a href="tutorial/key_extraction.html#global_fun"><code>global_fun</code></a>
|
||||
predefined key extractor.
|
||||
</li>
|
||||
<li>Added <a href="tutorial/indices.html#iterator_to"><code>iterator_to</code></a>
|
||||
facility.
|
||||
</li>
|
||||
<li>Included <a href="tutorial/creation.html#special_allocator">support for
|
||||
non-standard allocators</a> such as those of
|
||||
<a href="../../interprocess/index.html">Boost.Interprocess</a>, which makes
|
||||
<code>multi_index_container</code>s placeable in shared memory.
|
||||
</li>
|
||||
<li>New versions of <code>modify</code> and <code>modify_key</code> with
|
||||
rollback, as described in the
|
||||
<a href="tutorial/basics.html#ord_updating">tutorial</a>.
|
||||
</li>
|
||||
<li>Indices provide the new <code>cbegin</code>, <code>cend</code> and,
|
||||
when applicable, <code>crbegin</code> and <code>crend</code>
|
||||
member functions, in accordance with the latest drafts of the next
|
||||
revision of the C++ standard.
|
||||
</li>
|
||||
<li>Hinted insertion in ordered indices fully conforms to the resolutions of
|
||||
C++ Standard Library
|
||||
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#233">Defect
|
||||
Report 233</a>. The new requirement that the point of insertion
|
||||
be always as close as possible to the hint induces a different behavior than
|
||||
exhibited in former releases of Boost.MultiIndex, which can potentially cause
|
||||
backwards compatibility problems; in any case, the likelihood of these
|
||||
compatibility issues arising in a real scenario is very low.
|
||||
</li>
|
||||
<li>Sequenced and random access indices now follow the requirements of the
|
||||
C++ standard for sequence containers with respect to the operations
|
||||
<code>assign(f,l)</code> and <code>insert(p,f,l)</code> (23.1.1/9): if
|
||||
<code>f</code> and <code>l</code> are of the same integral type, the
|
||||
iterator-based overloads of these member functions are avoided:
|
||||
<blockquote><pre>
|
||||
<span class=keyword>typedef</span> <span class=identifier>multi_index_container</span><span class=special><</span>
|
||||
<span class=keyword>int</span><span class=special>,</span><span class=identifier>indexed_by</span><span class=special><</span><span class=identifier>sequenced</span><span class=special><></span> <span class=special>></span>
|
||||
<span class=special>></span> <span class=identifier>sequenced_container</span><span class=special>;</span>
|
||||
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>list</span><span class=special><</span><span class=keyword>int</span><span class=special>></span> <span class=identifier>l</span><span class=special>(...);</span>
|
||||
<span class=identifier>sequenced_container</span> <span class=identifier>c</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// iterator-based overload of assign</span>
|
||||
<span class=identifier>c</span><span class=special>.</span><span class=identifier>assign</span><span class=special>(</span><span class=identifier>l</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>l</span><span class=special>.</span><span class=identifier>end</span><span class=special>());</span>
|
||||
|
||||
<span class=comment>// The following is equivalent to
|
||||
// c.assign(
|
||||
// static_cast<sequenced_container::size_type>(10),100);
|
||||
// that is, "10" and "100" are not taken to be iterators as
|
||||
// in the previous expression.</span>
|
||||
<span class=identifier>c</span><span class=special>.</span><span class=identifier>assign</span><span class=special>(</span><span class=number>10</span><span class=special>,</span><span class=number>100</span><span class=special>);</span>
|
||||
</pre></blockquote>
|
||||
</li>
|
||||
<li>The performance of ordered indices <code>range</code> and
|
||||
<code>equal_range</code> has been improved.
|
||||
</li>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_34">Boost 1.34 release</a></h2>
|
||||
|
||||
<p>
|
||||
@@ -675,9 +140,9 @@ Acknowledgements
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised June 6th 2020</p>
|
||||
<p>Revised February 6th 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2020 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
+13
-30
@@ -43,50 +43,41 @@ with some of the least common features offered by Boost.MultiIndex.
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="../test/test_alloc_awareness.cpp"><code>test_alloc_awareness.cpp</code></a></td>
|
||||
<td>Checks <a href="https://en.cppreference.com/w/cpp/named_req/AllocatorAwareContainer">allocator
|
||||
awareness</a>.</td>
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<td><a href="../test/test_basic.cpp"><code>test_basic.cpp</code></a></td>
|
||||
<td>Simple program along the lines of the employees example studied in the
|
||||
tutorial.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr class="odd_tr">
|
||||
<td><a href="../test/test_capacity.cpp"><code>test_capacity.cpp</code></a></td>
|
||||
<td><code>empty</code>, <code>size</code>, <code>resize</code>
|
||||
(non key-based indices) and <code>reserve</code>/<code>capacity</code>
|
||||
(random access indices only).</td>
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<tr>
|
||||
<td><a href="../test/test_comparison.cpp"><code>test_comparison.cpp</code></a></td>
|
||||
<td>Comparison between indices.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr class="odd_tr">
|
||||
<td><a href="../test/test_composite_key.cpp"><code>test_composite_key.cpp</code></a></td>
|
||||
<td><code>composite_key</code> and <code>composite_key_compare</code>.</td>
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<tr>
|
||||
<td><a href="../test/test_conv_iterators.cpp"><code>test_conv_iterators.cpp</code></a></td>
|
||||
<td>Checks convertibility of non-constant to constant iterators.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr class="odd_tr">
|
||||
<td><a href="../test/test_copy_assignment.cpp"><code>test_copy_assignment.cpp</code></a></td>
|
||||
<td>Various forms of assignment: copy, <code>operator =</code>, insertion,
|
||||
(non key-based indices only) <code>assign</code> .
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<tr>
|
||||
<td><a href="../test/test_hash_ops.cpp"><code>test_hash_ops.cpp</code></a></td>
|
||||
<td>Hashing operations.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr class="odd_tr">
|
||||
<td><a href="../test/test_iterators.cpp"><code>test_iterators.cpp</code></a></td>
|
||||
<td>Constant and non-constant iterators and their reverse variants.</td>
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<td><a href="../test/test_key.cpp"><code>test_key.cpp</code></a></td>
|
||||
<td>Terse key specification syntax.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="../test/test_key_extractors.cpp"><code>test_key_extractors.cpp</code></a></td>
|
||||
<td>Covers all use cases of key extractors shipped with the library.</td>
|
||||
@@ -104,25 +95,17 @@ with some of the least common features offered by Boost.MultiIndex.
|
||||
<td>Metaprogramming manipulations of <code>multi_index_container</code> types.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="../test/test_node_handling.cpp"><code>test_node_handling.cpp</code></a></td>
|
||||
<td>Operations involving node extraction and insertion.</td>
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<td><a href="../test/test_observers.cpp"><code>test_observers.cpp</code></a></td>
|
||||
<td>Checks observer member functions of ordered and hashed indices.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr class="odd_tr">
|
||||
<td><a href="../test/test_projection.cpp"><code>test_projection.cpp</code></a></td>
|
||||
<td>Projection of iterators among indices.</td>
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<tr>
|
||||
<td><a href="../test/test_range.cpp"><code>test_range.cpp</code></a></td>
|
||||
<td>Exercises the <code>range</code> facility (ordered indices only).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="../test/test_rank_ops.cpp"><code>test_rank_ops.cpp</code></a></td>
|
||||
<td>Specific operations of ranked indices.</td>
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<td><a href="../test/test_rearrange.cpp"><code>test_rearrange.cpp</code></a></td>
|
||||
<td>Rearrange functions of sequenced and random access indices.</td>
|
||||
@@ -133,8 +116,7 @@ with some of the least common features offered by Boost.MultiIndex.
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<td><a href="../test/test_serialization1.cpp"><code>test_serialization1.cpp</code></a><br>
|
||||
<a href="../test/test_serialization2.cpp"><code>test_serialization2.cpp</code></a><br>
|
||||
<a href="../test/test_serialization3.cpp"><code>test_serialization3.cpp</code></a></td>
|
||||
<a href="../test/test_serialization2.cpp"><code>test_serialization2.cpp</code></a></td>
|
||||
<td>Serialization support.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -166,9 +148,10 @@ Future work
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised May 9th 2020</p>
|
||||
|
||||
<p>© Copyright 2003-2020 Joaquín M López Muñoz.
|
||||
<p>Revised March 2nd 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
+42
-154
@@ -62,7 +62,6 @@ Index types
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#projection">Projection of iterators</a></li>
|
||||
<li><a href="#node_handling">Node handling operations</a></li>
|
||||
<li><a href="#complexity">Complexity and exception safety</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -154,8 +153,7 @@ thus can be solved with Boost.MultiIndex as follows:
|
||||
|
||||
<p>
|
||||
Instead of a single comparison predicate type, as it happens for STL associative
|
||||
containers, <code>multi_index_container</code> is passed a
|
||||
<a href="../reference/multi_index_container.html#multi_index_container">list</a> of index
|
||||
containers, <code>multi_index_container</code> is passed a <i>typelist</i> of index
|
||||
specifications (<code>indexed_by</code>), each one inducing the corresponding index.
|
||||
Indices are accessed via
|
||||
<a href="../reference/multi_index_container.html#index_retrieval"><code>get</code></a><code><N>()</code>
|
||||
@@ -476,17 +474,25 @@ means of user-defined <code>typedef</code>s:
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
The iterators provided by every index are <i>constant</i>, that is, the elements they point to
|
||||
cannot be mutated directly. This follows the interface of <code>std::set</code> for ordered
|
||||
indices but might come as a surprise for other types such as sequenced indices, which are modeled after
|
||||
<code>std::list</code>, where this limitation does not happen. This seemingly odd behavior
|
||||
is imposed by the way <code>multi_index_container</code>s work; if elements were
|
||||
allowed to be mutated indiscriminately, we could introduce inconsistencies
|
||||
in the ordered indices of the <code>multi_index_container</code> without the container
|
||||
being notified about it. Element modification is properly done by means of
|
||||
<a href="#ord_updating">update operations</a> on any index.
|
||||
Additionally, <code>multi_index_container</code>s provide shortcut
|
||||
definitions to the iterator types of their constituent indices:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=identifier>employee_set</span><span class=special>::</span><span class=identifier>nth_index_iterator</span><span class=special><</span><span class=number>1</span><span class=special>>::</span><span class=identifier>type</span> <span class=identifier>it</span><span class=special>=</span>
|
||||
<span class=identifier>es</span><span class=special>.</span><span class=identifier>get</span><span class=special><</span><span class=number>1</span><span class=special>>().</span><span class=identifier>find</span><span class=special>(</span><span class=string>"Judy Smith"</span><span class=special>);</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
There is a variation of the expression above for use with
|
||||
<a href="#tagging">tags</a>:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=identifier>employee_set</span><span class=special>::</span><span class=identifier>index_iterator</span><span class=special><</span><span class=identifier>name</span><span class=special>>::</span><span class=identifier>type</span> <span class=identifier>it</span><span class=special>=</span>
|
||||
<span class=identifier>es</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=identifier>find</span><span class=special>(</span><span class=string>"Judy Smith"</span><span class=special>);</span> <span class=comment>// get<1> would also work</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<h2>
|
||||
<a name="index_types">Index types</a>
|
||||
</h2>
|
||||
@@ -498,17 +504,15 @@ Currently, Boost.MultiIndex provides the following index types:
|
||||
provide a similar interface. There are <i>unique</i> and <i>non-unique</i>
|
||||
variants: the former do not allow for duplicates, while the latter permit
|
||||
them (like <code>std::multiset</code>.)</li>
|
||||
<li>Ranked indices are a variation of ordered indices providing extra capabilities
|
||||
for querying and accessing elements based on their <i>rank</i> (the numerical position
|
||||
they occupy in the index).
|
||||
</li>
|
||||
<li>Sequenced indices are modeled after the semantics and interface of
|
||||
<code>std::list</code>: they arrange the elements as if in a bidirectional
|
||||
list.</li>
|
||||
<li>Hashed indices provide fast access to the elements through hashing
|
||||
techniques, in a similar way as unordered associative containers
|
||||
<code>std::unordered_set</code> (if duplicates are not allowed) and
|
||||
<code>std::unordered_multiset</code> (if they are).</li>
|
||||
tecnhiques, in a similar way as non-standard <code>hash_set</code>s provided
|
||||
by some vendors. Recently, <i>unordered associative containers</i> have been
|
||||
proposed as part of an extension of the C++ standard library known
|
||||
in the standardization commitee as TR1. Hashed indices closely model this
|
||||
proposal.</li>
|
||||
<li>Random access indices provide an interface similar to that of
|
||||
sequenced indices, and additionally feature random access iterators
|
||||
and positional access to the elements.</li>
|
||||
@@ -952,69 +956,15 @@ original value is kept and the method returns without altering the container, bu
|
||||
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 <code>modify</code>, the element is erased and the method returns
|
||||
<code>false</code>. There is a further version of <code>modify</code> which
|
||||
accepts a <i>rollback</i> functor to undo the changes in case of collision:
|
||||
<code>false</code>. This difference in behavior between <code>replace</code> and
|
||||
<code>modify</code> has to be considered by the programmer on a case-by-case basis.
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=keyword>struct</span> <span class=identifier>change_id</span>
|
||||
<span class=special>{</span>
|
||||
<span class=identifier>change_id</span><span class=special>(</span><span class=keyword>int</span> <span class=identifier>new_id</span><span class=special>):</span><span class=identifier>new_id</span><span class=special>(</span><span class=identifier>new_id</span><span class=special>){}</span>
|
||||
|
||||
<span class=keyword>void</span> <span class=keyword>operator</span><span class=special>()(</span><span class=identifier>employee</span><span class=special>&</span> <span class=identifier>e</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=identifier>e</span><span class=special>.</span><span class=identifier>id</span><span class=special>=</span><span class=identifier>new_id</span><span class=special>;</span>
|
||||
<span class=special>}</span>
|
||||
|
||||
<span class=keyword>private</span><span class=special>:</span>
|
||||
<span class=keyword>int</span> <span class=identifier>new_id</span><span class=special>;</span>
|
||||
<span class=special>};</span>
|
||||
<span class=special>...</span>
|
||||
<span class=identifier>employee_set</span><span class=special>::</span><span class=identifier>iterator</span> <span class=identifier>it</span><span class=special>=...</span>
|
||||
|
||||
<span class=keyword>int</span> <span class=identifier>old_id</span><span class=special>=</span><span class=identifier>it</span><span class=special>-></span><span class=identifier>id</span><span class=special>;</span> <span class=comment>// keep the original id
|
||||
|
||||
// try to modify the id, restore it in case of collisions</span>
|
||||
<span class=identifier>es</span><span class=special>.</span><span class=identifier>modify</span><span class=special>(</span><span class=identifier>it</span><span class=special>,</span><span class=identifier>change_id</span><span class=special>(</span><span class=number>321</span><span class=special>),</span><span class=identifier>change_id</span><span class=special>(</span><span class=identifier>old_id</span><span class=special>));</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>In the example, <code>change_id(old_id)</code> is invoked to restore the original
|
||||
conditions when the modification results in collisions with some other element.
|
||||
The differences in behavior between <code>replace</code>, <code>modify</code> and
|
||||
<code>modify</code> with rollback have to be considered by the programmer on a
|
||||
case-by-case basis to determine the best updating mechanism.
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<table cellspacing="0">
|
||||
<caption><b>Behavior of the different updating mechanisms.</b></caption>
|
||||
<tr>
|
||||
<th align="center">updating function</th>
|
||||
<th>If there is a collision...</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><code>replace(it,x)</code></td>
|
||||
<td>replacement does not take place.</td>
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<td align="center"><code>modify(it,mod)</code></td>
|
||||
<td>the element is erased.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><code>modify(it,mod,back)</code></td>
|
||||
<td><code>back</code> is used to restore the original conditions.
|
||||
(If <code>back</code> throws, the element is erased.)
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
Key-based versions of <code>modify</code>, named
|
||||
<a href="../reference/ord_indices.html#modify_key"><code>modify_key</code></a>, are
|
||||
provided as well. In this case, the modifying functors are passed a reference to
|
||||
the <code>key_type</code> part of the element instead of the whole object.
|
||||
A key-based version of <code>modify</code>, named
|
||||
<a href="../reference/ord_indices.html#modify_key"><code>modify_key</code></a>, is
|
||||
provided as well. In this case, the modifying functor is passed a reference to
|
||||
the <code>key_value</code> part of the element instead of the whole object.
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
@@ -1040,8 +990,8 @@ the <code>key_type</code> part of the element instead of the whole object.
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
Like <code>modify</code>, there are versions of <code>modify_key</code> with and
|
||||
without rollback. <code>modify</code> and
|
||||
Just as <code>modify</code> does, <code>modify_key</code> erases the element if
|
||||
the modification results in collisions in some index. <code>modify</code> and
|
||||
<code>modify_key</code> are particularly well suited to use in conjunction to
|
||||
<a href="../../../../libs/lambda/index.html">Boost.Lambda</a>
|
||||
for defining the modifying functors:
|
||||
@@ -1075,9 +1025,9 @@ same way as <code>std::list</code> permits. The interface of sequenced indices
|
||||
is thus designed upon that of <code>std::list</code>; nearly every operation
|
||||
provided in the standard container is replicated here, occasionally with changes
|
||||
in the syntax and/or semantics to cope with the constraints imposed by
|
||||
Boost.MultiIndex. An important difference, commented <a href="#iterator_access">above</a>,
|
||||
is the fact that the values pointed to by sequenced index iterators are treated
|
||||
as <i>constant</i>:
|
||||
Boost.MultiIndex. In particular, there is an important limitation of sequenced
|
||||
indices with respect to <code>std::list</code>s, namely that elements of an
|
||||
<code>multi_index_container</code> are not mutable through an iterator:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
@@ -1091,7 +1041,11 @@ as <i>constant</i>:
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
As with any other type of index, element modification
|
||||
That is, iterators of a sequenced index (of all types of indices, actually)
|
||||
point to constant elements. This limitation might come as a surprise, but
|
||||
it is imposed by the way <code>multi_index_container</code>s work; if elements were
|
||||
allowed to be changed in this manner, we could introduce inconsistencies
|
||||
in other ordered indices of the <code>multi_index_container</code>. Element modification
|
||||
can nevertheless be done by means of
|
||||
<a href="#seq_updating">update operations</a>.
|
||||
</p>
|
||||
@@ -1200,7 +1154,7 @@ A slightly more interesting example:
|
||||
|
||||
<span class=comment>// prepend "older" to all occurrences of "sister"</span>
|
||||
|
||||
<span class=identifier>text_container</span><span class=special>::</span><span class=identifier>nth_index</span><span class=special><</span><span class=number>1</span><span class=special>>::</span><span class=identifier>type</span><span class=special>::</span><span class=identifier>iterator</span> <span class=identifier>it1</span><span class=special>=</span>
|
||||
<span class=identifier>text_container</span><span class=special>::</span><span class=identifier>nth_index_iterator</span><span class=special><</span><span class=number>1</span><span class=special>>::</span><span class=identifier>type</span> <span class=identifier>it1</span><span class=special>=</span>
|
||||
<span class=identifier>sorted_index</span><span class=special>.</span><span class=identifier>lower_bound</span><span class=special>(</span><span class=string>"sister"</span><span class=special>);</span>
|
||||
|
||||
<span class=keyword>while</span><span class=special>(</span><span class=identifier>it1</span><span class=special>!=</span><span class=identifier>sorted_index</span><span class=special>.</span><span class=identifier>end</span><span class=special>()&&*</span><span class=identifier>it1</span><span class=special>==</span><span class=string>"sister"</span><span class=special>){</span>
|
||||
@@ -1217,72 +1171,6 @@ When provided, <code>project</code> can also be used with
|
||||
<a href="#tagging">tags</a>.
|
||||
</p>
|
||||
|
||||
<h2><a name="node_handling">Node handling operations</a></h2>
|
||||
|
||||
<p>
|
||||
Using direct node manipulation, elements can be passed between
|
||||
<code>multi_index_container</code>s without actually copying them:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=comment>// move an employee to the retiree archive</span>
|
||||
<span class=keyword>void</span> <span class=identifier>move_to_retirement</span><span class=special>(</span><span class=keyword>int</span> <span class=identifier>ssnumber</span><span class=special>,</span><span class=identifier>employee_set</span><span class=special>&</span> <span class=identifier>es</span><span class=special>,</span><span class=identifier>employee_set</span><span class=special>&</span> <span class=identifier>archive</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=comment>// extract the employee with given SS number to a node handle</span>
|
||||
<span class=identifier>employee_set_by_ssn</span><span class=special>::</span><span class=identifier>node_type</span> <span class=identifier>node</span><span class=special>=</span><span class=identifier>es</span><span class=special>.</span><span class=identifier>get</span><span class=special><</span><span class=identifier>ssn</span><span class=special>>().</span><span class=identifier>extract</span><span class=special>(</span><span class=identifier>ssnumber</span><span class=special>);</span>
|
||||
|
||||
<span class=keyword>if</span><span class=special>(!</span><span class=identifier>node</span><span class=special>.</span><span class=identifier>empty</span><span class=special>()){</span> <span class=comment>// employee found
|
||||
// re-insert into archive (note the use of std::move)</span>
|
||||
<span class=identifier>archive</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>move</span><span class=special>(</span><span class=identifier>node</span><span class=special>));</span>
|
||||
<span class=special>}</span>
|
||||
<span class=special>}</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
In the example, the internal node is transferred as-is from <code>es</code> to <code>archive</code>,
|
||||
which is more efficient than erasing from the source and recreating in destination.
|
||||
<code>node_type</code> is a move-only class used to pass nodes around, and its interface follows
|
||||
that of the <a href="https://en.cppreference.com/w/cpp/container/node_handle">homonym type</a>
|
||||
for C++ associative containers (set containers version). Boost.MultiIndex provides node extraction
|
||||
and insertion operations for all index types, including sequenced ones (by contrast,
|
||||
<code>std::list</code> does not have such features):
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span>
|
||||
<span class=keyword>int</span><span class=special>,</span>
|
||||
<span class=identifier>indexed_by</span><span class=special><</span>
|
||||
<span class=identifier>sequenced</span><span class=special><>,</span>
|
||||
<span class=identifier>ordered_unique</span><span class=special><</span><span class=identifier>identity</span><span class=special><</span><span class=keyword>int</span><span class=special>></span> <span class=special>></span>
|
||||
<span class=special>></span>
|
||||
<span class=special>></span> <span class=identifier>src</span><span class=special>;</span>
|
||||
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span>
|
||||
<span class=keyword>int</span><span class=special>,</span>
|
||||
<span class=identifier>indexed_by</span><span class=special><</span>
|
||||
<span class=identifier>sequenced</span><span class=special><>,</span>
|
||||
<span class=identifier>ordered_non_unique</span><span class=special><</span><span class=identifier>identity</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=special>></span> <span class=identifier>dst</span><span class=special>;</span>
|
||||
|
||||
<span class=special>...</span>
|
||||
|
||||
<span class=comment>// transfer even numbers from src to dst</span>
|
||||
<span class=keyword>for</span><span class=special>(</span><span class=keyword>auto</span> <span class=identifier>first</span><span class=special>=</span><span class=identifier>src</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>last</span><span class=special>=</span><span class=identifier>src</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>
|
||||
<span class=keyword>if</span><span class=special>(*</span><span class=identifier>first</span><span class=special>%</span><span class=number>2</span><span class=special>==</span><span class=number>0</span><span class=special>)</span> <span class=identifier>dst</span><span class=special>.</span><span class=identifier>insert</span><span class=special>(</span><span class=identifier>dst</span><span class=special>.</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>src</span><span class=special>.</span><span class=identifier>extract</span><span class=special>(</span><span class=identifier>first</span><span class=special>++));</span>
|
||||
<span class=keyword>else</span> <span class=special>++</span><span class=identifier>first</span><span class=special>;</span>
|
||||
<span class=special>}</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
Note that <code>src</code> and <code>dst</code> are of different types,
|
||||
yet transfer is possible. Two <code>multi_index_container</code>s are
|
||||
node-compatible (that is, they use the same <code>node_type</code>) if
|
||||
they have the same element and allocator types and their respective indices match
|
||||
one by one without regard to whether they are unique or non-unique or to
|
||||
their particular configuration parameters: they are both ordered, or
|
||||
both sequenced, etc.
|
||||
</p>
|
||||
<h2><a name="complexity">Complexity and exception safety</a></h2>
|
||||
|
||||
<p>
|
||||
@@ -1317,9 +1205,9 @@ Index types
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised May 9th 2020</p>
|
||||
<p>Revised July 13th 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2020 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
@@ -32,7 +32,6 @@ Debugging support
|
||||
<ul>
|
||||
<li><a href="#value_semantics">Value semantics</a></li>
|
||||
<li><a href="#ctor_args_list">Use of <code>ctor_args_list</code></a></li>
|
||||
<li><a href="#special_allocator">Special allocator support</a></li>
|
||||
<li><a href="#serialization">Serialization</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -192,60 +191,6 @@ A program is provided in the <a href="../examples.html#example3">examples sectio
|
||||
puts in practise these concepts.
|
||||
</p>
|
||||
|
||||
<h2><a name="special_allocator">Special allocator support</a></h2>
|
||||
|
||||
<p>
|
||||
Boost.MultiIndex allows for a slightly more general class of allocators
|
||||
than strictly required by the C++ standard, as explained in detail in the
|
||||
<a href="../reference/multi_index_container.html#instantiation_types">reference</a>.
|
||||
An important type of non-standard allocators supported are those provided by the
|
||||
<a href="../../../interprocess/index.html">Boost Interprocess Library</a>;
|
||||
this opens up the possibility of placing <code>multi_index_container</code>s
|
||||
in shared memory.
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=preprocessor>#include</span> <span class=special><</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>interprocess</span><span class=special>/</span><span class=identifier>allocators</span><span class=special>/</span><span class=identifier>allocator</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>interprocess</span><span class=special>/</span><span class=identifier>managed_shared_memory</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>></span>
|
||||
|
||||
<span class=keyword>namespace</span> <span class=identifier>bip</span><span class=special>=</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>interprocess</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// a shared memory compatible allocator of ints</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>bip</span><span class=special>::</span><span class=identifier>allocator</span><span class=special><</span>
|
||||
<span class=keyword>int</span><span class=special>,</span><span class=identifier>bip</span><span class=special>::</span><span class=identifier>managed_shared_memory</span><span class=special>::</span><span class=identifier>segment_manager</span>
|
||||
<span class=special>></span> <span class=identifier>shared_int_allocator</span><span class=special>;</span>
|
||||
|
||||
<span class=comment>// define a shared memory compatible multi_index_container
|
||||
// using shared_int_allocator</span>
|
||||
<span class=keyword>typedef</span> <span class=identifier>multi_index_container</span><span class=special><</span>
|
||||
<span class=keyword>int</span><span class=special>,</span>
|
||||
<span class=identifier>indexed_by</span><span class=special><</span>
|
||||
<span class=identifier>sequenced</span><span class=special><>,</span>
|
||||
<span class=identifier>ordered_unique</span><span class=special><</span><span class=identifier>identity</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>shared_int_allocator</span>
|
||||
<span class=special>></span> <span class=identifier>unique_int_list</span><span class=special>;</span>
|
||||
|
||||
<span class=special>...</span>
|
||||
|
||||
<span class=comment>// create a managed memory segment</span>
|
||||
<span class=identifier>bip</span><span class=special>::</span><span class=identifier>managed_shared_memory</span> <span class=identifier>seg</span><span class=special>(</span>
|
||||
<span class=identifier>bip</span><span class=special>::</span><span class=identifier>create_only</span><span class=special>,</span><span class=string>"SharedMemoryID"</span><span class=special>,</span><span class=number>65536</span><span class=special>);</span>
|
||||
|
||||
<span class=comment>// construct a unique_int_list into the segment</span>
|
||||
<span class=identifier>unique_int_list</span><span class=special>*</span> <span class=identifier>puil</span><span class=special>=</span><span class=identifier>seg</span><span class=special>.</span><span class=identifier>construct</span><span class=special><</span><span class=identifier>unique_int_list</span><span class=special>></span>
|
||||
<span class=special>(</span><span class=string>"UniqueIntListID"</span><span class=special>)</span> <span class=comment>// object identifier within the segment
|
||||
// Construction args: first a ctor arg list, then a
|
||||
// shared memory allocator obtained from the segment object.</span>
|
||||
<span class=special>(</span><span class=identifier>unique_int_list</span><span class=special>::</span><span class=identifier>ctor_args_list</span><span class=special>(),</span>
|
||||
<span class=identifier>unique_int_list</span><span class=special>::</span><span class=identifier>allocator_type</span><span class=special>(</span><span class=identifier>seg</span><span class=special>.</span><span class=identifier>get_segment_manager</span><span class=special>()));</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
The examples section includes a <a href="../examples.html#example12">program</a>
|
||||
that further explores this capability.
|
||||
</p>
|
||||
|
||||
<h2><a name="serialization">Serialization</a></h2>
|
||||
|
||||
<p>
|
||||
@@ -340,7 +285,7 @@ Debugging support
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised July 17th 2007</p>
|
||||
<p>Revised February 27th 2007</p>
|
||||
|
||||
<p>© Copyright 2003-2007 Joaquín M López Muñoz.
|
||||
Distributed under the Boost Software
|
||||
|
||||
@@ -89,7 +89,7 @@ and functions of the library.
|
||||
Boost.MultiIndex safe mode is set by globally defining the macro
|
||||
<code>BOOST_MULTI_INDEX_ENABLE_SAFE_MODE</code>. Error conditions
|
||||
are checked via the macro <code>BOOST_MULTI_INDEX_SAFE_MODE_ASSERT</code>, which
|
||||
by default resolves to a call to <a href="../../../../libs/assert">
|
||||
by default resolves to a call to <a href="../../../../libs/utility/assert.html">
|
||||
<code>BOOST_ASSERT</code></a>.
|
||||
</p>
|
||||
|
||||
@@ -125,8 +125,7 @@ is one value of the <code>safe_mode::error_code</code> enumeration:
|
||||
<span class=identifier>invalid_range</span><span class=special>,</span> <span class=comment>// last not reachable from first</span>
|
||||
<span class=identifier>inside_range</span><span class=special>,</span> <span class=comment>// iterator lies within a range (and it mustn't)</span>
|
||||
<span class=identifier>out_of_bounds</span><span class=special>,</span> <span class=comment>// move attempted beyond container limits</span>
|
||||
<span class=identifier>same_container</span><span class=special>,</span> <span class=comment>// containers ought to be different</span>
|
||||
<span class=identifier>unequal_allocators</span> <span class=comment>// allocators ought to be equal</span>
|
||||
<span class=identifier>same_container</span> <span class=comment>// containers ought to be different</span>
|
||||
<span class=special>};</span>
|
||||
|
||||
<span class=special>}</span> <span class=comment>// namespace multi_index::safe_mode</span>
|
||||
@@ -214,7 +213,7 @@ internal invariants of the data structures managed are preserved.
|
||||
If an invariant test fails, Boost.MultiIndex will indicate the failure
|
||||
by means of the unary macro <code>BOOST_MULTI_INDEX_INVARIANT_ASSERT</code>.
|
||||
Unless the user provides a definition for this macro, it defaults to
|
||||
<a href="../../../../libs/assert">
|
||||
<a href="../../../../libs/utility/assert.html">
|
||||
<code>BOOST_ASSERT</code></a>. Any assertion of this kind should
|
||||
be regarded in principle as a bug in the library. Please report such
|
||||
problems, along with as much contextual information as possible, to the
|
||||
@@ -240,9 +239,9 @@ Techniques
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised May 9th 2020</p>
|
||||
<p>Revised February 6th 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2020 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
+44
-201
@@ -31,12 +31,6 @@ Key extraction
|
||||
|
||||
<ul>
|
||||
<li><a href="#classification">Classification</a>
|
||||
<li><a href="#rnk_indices">Ranked indices</a>
|
||||
<ul>
|
||||
<li><a href="#rnk_spec">Specification</a></li>
|
||||
<li><a href="#rnk_ops">Rank operations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#hashed_indices">Hashed indices</a>
|
||||
<ul>
|
||||
<li><a href="#hash_unique_non_unique">Unique and non-unique variants</a></li>
|
||||
@@ -54,14 +48,13 @@ Key extraction
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#rearrange">Index rearranging</a></li>
|
||||
<li><a href="#iterator_to"><code>iterator_to</code></a></li>
|
||||
<li><a href="#ordered_node_compression">Ordered indices node compression</a></li>
|
||||
</ul>
|
||||
|
||||
<h2><a name="classification">Classification</a></h2>
|
||||
|
||||
<p>
|
||||
Boost.MultiIndex provides eight different index types, which can be classified as
|
||||
Boost.MultiIndex provides six different index types, which can be classified as
|
||||
shown in the table below. <a href="basics.html#ord_indices">Ordered</a> and
|
||||
<a href="basics.html#seq_indices">sequenced</a> indices,
|
||||
which are the most commonly used, have been explained in the basics section;
|
||||
@@ -77,19 +70,13 @@ some added benefits, functionally or in the area of performance.
|
||||
<th align="center">specifier</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" rowspan="6"> key-based </td>
|
||||
<td align="center" rowspan="4"> ordered </td>
|
||||
<td align="center" rowspan="4"> key-based </td>
|
||||
<td align="center" rowspan="2"> ordered </td>
|
||||
<td align="center"> <code>ordered_unique</code> </td>
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<td align="center"> <code>ordered_non_unique</code> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"> <code>ranked_unique</code> </td>
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<td align="center"> <code>ranked_non_unique</code> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" rowspan="2"> hashed </td>
|
||||
<td align="center"> <code>hashed_unique</code> </td>
|
||||
@@ -103,7 +90,6 @@ some added benefits, functionally or in the area of performance.
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<td align="center"><code> random_access </code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
@@ -120,114 +106,6 @@ modeled after the interface of <code>std::list</code>, are the customary
|
||||
example of a non key-based index.
|
||||
</p>
|
||||
|
||||
<h2><a name="rnk_indices">Ranked indices</a></h2>
|
||||
|
||||
<p>
|
||||
Suppose we have a <code>std::multiset</code> of numbers and we want to output
|
||||
the values above the 75h <a href="http://en.wikipedia.org/wiki/Percentile">percentile</a>:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=keyword>typedef</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>multiset</span><span class=special><</span><span class=keyword>int</span><span class=special>></span> <span class=identifier>int_multiset</span><span class=special>;</span>
|
||||
|
||||
<span class=keyword>void</span> <span class=identifier>output_above_75th_percentile</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>int_multiset</span><span class=special>&</span> <span class=identifier>s</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=identifier>int_multiset</span><span class=special>::</span><span class=identifier>const_iterator</span> <span class=identifier>it</span><span class=special>=</span><span class=identifier>s</span><span class=special>.</span><span class=identifier>begin</span><span class=special>();</span>
|
||||
<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>s</span><span class=special>.</span><span class=identifier>size</span><span class=special>()*</span><span class=number>3</span><span class=special>/</span><span class=number>4</span><span class=special>);</span> <span class=comment>// linear on s.size();</span>
|
||||
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>copy</span><span class=special>(</span><span class=identifier>it</span><span class=special>,</span><span class=identifier>s</span><span class=special>.</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>ostream_iterator</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>cout</span><span class=special>,</span><span class=string>"\n"</span><span class=special>));</span>
|
||||
<span class=special>}</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
The problem with this code is that getting to the beginning of the desired subsequence
|
||||
involves a linear traversal of the container. Ranked indices provide the mechanisms to do this
|
||||
much faster:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=keyword>typedef</span> <span class=identifier>multi_index_container</span><span class=special><</span>
|
||||
<span class=keyword>int</span><span class=special>,</span>
|
||||
<span class=identifier>indexed_by</span><span class=special><</span>
|
||||
<span class=identifier>ranked_non_unique</span><span class=special><</span><span class=identifier>identity</span><span class=special><</span><span class=keyword>int</span><span class=special>></span> <span class=special>></span>
|
||||
<span class=special>></span>
|
||||
<span class=special>></span> <span class=identifier>int_multiset</span><span class=special>;</span>
|
||||
|
||||
<span class=keyword>void</span> <span class=identifier>output_above_75th_percentile</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>int_multiset</span><span class=special>&</span> <span class=identifier>s</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=identifier>int_multiset</span><span class=special>::</span><span class=identifier>const_iterator</span> <span class=identifier>it</span><span class=special>=</span><span class=identifier>s</span><span class=special>.</span><span class=identifier>nth</span><span class=special>(</span><span class=identifier>s</span><span class=special>.</span><span class=identifier>size</span><span class=special>()*</span><span class=number>3</span><span class=special>/</span><span class=number>4</span><span class=special>);</span> <span class=comment>// logarithmic</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>copy</span><span class=special>(</span><span class=identifier>it</span><span class=special>,</span><span class=identifier>s</span><span class=special>.</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>ostream_iterator</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>cout</span><span class=special>,</span><span class=string>"\n"</span><span class=special>));</span>
|
||||
<span class=special>}</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
<code>nth(n)</code> returns an iterator to the element whose <i>rank</i>, i.e. its distance
|
||||
from the beginning of the index, is <code>n</code>, and does so efficiently in logarithmic time.
|
||||
Conversely, <code>rank(it)</code> computes in logarithmic time the rank of the element
|
||||
pointed to by <code>it</code>, or <code>size()</code> if <code>it==end()</code>.
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=identifier>int_multiset</span><span class=special>::</span><span class=identifier>iterator</span> <span class=identifier>it</span><span class=special>=</span><span class=identifier>s</span><span class=special>.</span><span class=identifier>insert</span><span class=special>(</span><span class=number>10</span><span class=special>).</span><span class=identifier>first</span><span class=special>;</span>
|
||||
<span class=identifier>int_multiset</span><span class=special>::</span><span class=identifier>size_type</span> <span class=identifier>r</span><span class=special>=</span><span class=identifier>s</span><span class=special>.</span><span class=identifier>rank</span><span class=special>(</span><span class=identifier>it</span><span class=special>);</span> <span class=comment>// rank of 10;</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
Ranked indices provide the same interface as ordered indices plus several rank-related operations.
|
||||
The cost of this extra functionality is higher memory consumption due to some internal additional
|
||||
data (one word per element) and somewhat longer execution times in insertion and erasure
|
||||
—in particular, erasing an element takes time proportional to <code>log(n)</code>, where
|
||||
<code>n</code> is the number of elements in the index, whereas for ordered indices this time is
|
||||
constant.
|
||||
The <a href="../reference/rnk_indices.html">reference</a> describes these indices in complete detail.
|
||||
</p>
|
||||
|
||||
<h3><a name="rnk_spec">Specification</a></h3>
|
||||
|
||||
<p>
|
||||
The specification of ranked indices is done exactly as with <a href="basics.html#ord_spec">ordered indices</a>,
|
||||
except that <code>ranked_unique</code> and <code>ranked_non_unique</code> are used instead.
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=special>(</span><span class=identifier>ranked_unique</span> <span class=special>|</span> <span class=identifier>ranked_non_unique</span><span class=special>)
|
||||
</span><span class=special><[</span><i>(tag)</i><span class=special>[,</span><i>(key extractor)</i><span class=special>[,</span><i>(comparison predicate)</i><span class=special>]]]></span>
|
||||
|
||||
<span class=special>(</span><span class=identifier>ranked_unique</span> <span class=special>|</span> <span class=identifier>ranked_non_unique</span><span class=special>)</span>
|
||||
<span class=special><[</span><i>(key extractor)</i><span class=special>[,</span><i>(comparison predicate)</i><span class=special>]]></span>
|
||||
</pre></blockquote>
|
||||
|
||||
<h3><a name="rnk_ops">Rank operations</a></h3>
|
||||
|
||||
<p>
|
||||
Besides <code>nth</code> and <code>rank</code>, ranked indices provide member functions
|
||||
<ul>
|
||||
<li><code>find_rank</code>,</li>
|
||||
<li><code>lower_bound_rank</code>,</li>
|
||||
<li><code>upper_bound_rank</code>,</li>
|
||||
<li><code>equal_range_rank</code> and </li>
|
||||
<li><code>range_rank</code></li>
|
||||
</ul>
|
||||
that behave as their normal
|
||||
<a href="basics.html#special_lookup">lookup</a> and <a href="basics.html#range">range retrieval</a>
|
||||
counterparts (<code>find</code>, <code>lower_bound</code> etc.) but return ranks rather than iterators.
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=keyword>void</span> <span class=identifier>percentile</span><span class=special>(</span><span class=keyword>int</span> <span class=identifier>n</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>int_multiset</span><span class=special>&</span> <span class=identifier>s</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>n</span><span class=special><<</span><span class=string>" lies in the "</span><span class=special><<</span>
|
||||
<span class=identifier>s</span><span class=special>.</span><span class=identifier>upper_bound_rank</span><span class=special>(</span><span class=identifier>n</span><span class=special>)*</span><span class=number>100.0</span><span class=special>/</span><span class=identifier>s</span><span class=special>.</span><span class=identifier>size</span><span class=special>()<<</span><span class=string>" percentile\n"</span><span class=special>;</span>
|
||||
<span class=special>}</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
You might think that <code>upper_bound_rank(n)</code> is mere shorthand for
|
||||
<code>rank(upper_bound(n))</code>: in reality, though, you should prefer using
|
||||
<code>*_rank</code> operations directly as they run faster than the
|
||||
alternative formulations.
|
||||
</p>
|
||||
|
||||
<h2><a name="hashed_indices">Hashed indices</a></h2>
|
||||
|
||||
<p>
|
||||
@@ -282,10 +160,25 @@ determining whether a hashed index is preferred over an ordered one.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Hashed indices replicate the interface as <code>std::unordered_set</code> and
|
||||
<code>std::unordered_multiset</code>, with only minor differences where required
|
||||
by the general constraints of <code>multi_index_container</code>s, and provide
|
||||
additional useful capabilities like in-place updating of elements.
|
||||
If you are familiar with non-standard <code>hash_set</code>s provided
|
||||
by some compiler vendors, then learning to use hashed indices should be straightforward.
|
||||
However, the interface of hashed indices is modeled after the specification
|
||||
for unordered associative containers by the
|
||||
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1836.pdf">C++ Standard
|
||||
Library Technical Report</a> (TR1),
|
||||
which differs in some significant aspects from existing pre-standard
|
||||
implementations:
|
||||
<ul>
|
||||
<li>As there is no notion of ordering between keys, the <a href="#hash_lookup">lookup
|
||||
interface</a> does not offer <code>lower_bound</code> or <code>upper_bound</code>
|
||||
member functions (unlike Dinkumware's solution.)</li>
|
||||
<li>A set of member functions is provided for handling the internal
|
||||
bucket structure on which hashed indices rely. This includes facilities
|
||||
for <a href="../reference/hash_indices.html#hash_policy">rehashing</a>,
|
||||
control of the load factor (number of elements divided by number of buckets),
|
||||
and inspection of the buckets contents. Pre-standard implementations
|
||||
do not have such an extensive functionality.</li>
|
||||
</ul>
|
||||
Check the <a href="../reference/hash_indices.html">reference</a> for a
|
||||
complete specification of the interface of hashed indices,
|
||||
and <a href="../examples.html#example8">example 8</a> and
|
||||
@@ -327,8 +220,9 @@ element.
|
||||
|
||||
<p>
|
||||
The hash function is the very core of the fast lookup capabilities of this type of
|
||||
indices: a hasher is just a unary function object
|
||||
returning an <code>std::size_t</code> value for any given
|
||||
indices: a hasher
|
||||
is just a <a href="http://www.sgi.com/tech/stl/UnaryFunction.html"><code>Unary
|
||||
Function</code></a> returning an <code>std::size_t</code> 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
|
||||
@@ -457,18 +351,19 @@ member functions, with the same functionality as in ordered indices.
|
||||
Due to the internal constraints imposed by the Boost.MultiIndex framework,
|
||||
hashed indices provide guarantees on iterator validity and
|
||||
exception safety that are actually stronger than required by the
|
||||
C++ standard with respect to unordered associative containers:
|
||||
C++ Standard Library Technical Report (TR1) with respect
|
||||
to unordered associative containers:
|
||||
<ul>
|
||||
<li>Iterator validity is preserved in any case during insertion or rehashing:
|
||||
C++ unordered associative containers can invalidate iterators when a rehash (implicit or explicit)
|
||||
TR1 allows for iterator invalidation when a rehash (implicit or explicit)
|
||||
is performed.</li>
|
||||
<li>Erasing an element or range of elements via iterators does not throw ever,
|
||||
as the internal hash function and equality predicate objects are not actually
|
||||
invoked.</li>
|
||||
<li><code>rehash</code> provides the strong exception safety guarantee
|
||||
unconditionally. The standard only warrants it for unordered associative containers if the internal hash function and
|
||||
unconditionally. TR1 only warrants it if the internal hash function and
|
||||
equality predicate objects do not throw. The somewhat surprising consequence
|
||||
is that a standard-compliant <code>std::unordered_set</code> might erase
|
||||
is that a TR1-compliant unordered associative container might erase
|
||||
elements if an exception is thrown during rehashing!</li>
|
||||
</ul>
|
||||
In general, these stronger guarantees play in favor of the user's convenience,
|
||||
@@ -631,16 +526,15 @@ indices), but induces important limitations in non key-based indices:
|
||||
<span class=special>></span>
|
||||
<span class=special>></span> <span class=identifier>container</span><span class=special>;</span>
|
||||
|
||||
<span class=identifier>container</span> <span class=identifier>c</span><span class=special>;</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>mt19937</span> <span class=identifier>rng</span><span class=special>;</span>
|
||||
<span class=identifier>container</span> <span class=identifier>c</span><span class=special>;</span>
|
||||
<span class=special>...</span>
|
||||
<span class=comment>// compiler error: assignment to read-only objects</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>shuffle</span><span class=special>(</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>rng</span><span class=special>);</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>random_shuffle</span><span class=special>(</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>end</span><span class=special>());</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
What is unfortunate about the previous example is that the operation
|
||||
performed by <code>std::shuffle</code> is potentially compatible
|
||||
performed by <code>std::random_shuffle</code> is potentially compatible
|
||||
with <code>multi_index_container</code> invariants, as its result can be
|
||||
described by a permutation of the elements in the random access index
|
||||
with no actual modifications to the elements themselves. There are many
|
||||
@@ -655,7 +549,7 @@ a preliminary concept: a <i>view</i> of an index is defined as
|
||||
some iterator range [<code>first</code>,<code>last</code>) over the
|
||||
elements of the index such that all its elements are contained in the
|
||||
range exactly once. Continuing with our example, we can apply
|
||||
<code>std::shuffle</code> on an ad hoc view obtained from the
|
||||
<code>std::random_suffle</code> on an ad hoc view obtained from the
|
||||
container:
|
||||
</p>
|
||||
|
||||
@@ -665,16 +559,17 @@ container:
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>vector</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>reference_wrapper</span><span class=special><</span><span class=keyword>const</span> <span class=keyword>int</span><span class=special>></span> <span class=special>></span> <span class=identifier>v</span><span class=special>;</span>
|
||||
<span class=identifier>BOOST_FOREACH</span><span class=special>(</span><span class=keyword>const</span> <span class=keyword>int</span><span class=special>&</span> <span class=identifier>i</span><span class=special>,</span><span class=identifier>c</span><span class=special>)</span><span class=identifier>v</span><span class=special>.</span><span class=identifier>push_back</span><span class=special>(</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>cref</span><span class=special>(</span><span class=identifier>i</span><span class=special>));</span>
|
||||
|
||||
<span class=comment>// this compiles OK, as reference_wrappers are swappable</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>shuffle</span><span class=special>(</span><span class=identifier>v</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>v</span><span class=special>.</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>rng</span><span class=special>);</span>
|
||||
<span class=comment>// this compiles OK, as reference_wrappers are assignable</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>random_shuffle</span><span class=special>(</span><span class=identifier>v</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>v</span><span class=special>.</span><span class=identifier>end</span><span class=special>());</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
Elements of <code>v</code> are <code>reference_wrapper</code>s (from
|
||||
<a href="../../../../doc/html/ref.html">Boost.Ref</a>) to the actual elements
|
||||
in the multi-index container. These objects still do not allow modification
|
||||
of the referenced entities, but they are swappable,
|
||||
which is the only requirement <code>std::shuffle</code> imposes. Once
|
||||
of the referenced entities, but they are
|
||||
<a href="http://www.sgi.com/tech/stl/Assignable.html"><code>Assignable</code></a>,
|
||||
which is the only requirement <code>std::random_suffle</code> imposes. Once
|
||||
we have our desired rearrange stored in the view, we can transfer it to
|
||||
the container with
|
||||
</p>
|
||||
@@ -713,8 +608,7 @@ thus, <code>rearrange</code> does not accept the following:
|
||||
<blockquote><pre>
|
||||
<span class=comment>// undefined behavior: [rbegin(),rend()) is not free with respect
|
||||
// to the base index</span>
|
||||
<span class=identifier>c</span><span class=special>.</span><span class=identifier>rearrange</span><span class=special>(</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>rbegin</span><span class=special>());</span>
|
||||
</pre></blockquote>
|
||||
<span class=identifier>c</span><span class=special>.</span><span class=identifier>rearrange</span><span class=special>(</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>rbegin</span><span class=special>());</span></pre></blockquote>
|
||||
|
||||
<p>
|
||||
The view concept is defined in detail in the
|
||||
@@ -723,61 +617,10 @@ See <a href="../examples.html#example11">example 11</a> in the examples section
|
||||
for a demonstration of use of <code>rearrange</code>.
|
||||
</p>
|
||||
|
||||
<h2><a name="iterator_to"><code>iterator_to</code></a></h2>
|
||||
|
||||
<p>
|
||||
All indices of Boost.MultiIndex provide a member function called <code>iterator_to</code>
|
||||
which returns an iterator to a given element of the container:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=identifier>multi_index_container</span><span class=special><</span>
|
||||
<span class=keyword>int</span><span class=special>,</span>
|
||||
<span class=identifier>indexed_by</span><span class=special><</span><span class=identifier>sequenced</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=comment>// convoluted way to do c.pop_back()</span>
|
||||
<span class=identifier>c</span><span class=special>.</span><span class=identifier>erase</span><span class=special>(</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>iterator_to</span><span class=special>(</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>back</span><span class=special>()));</span>
|
||||
|
||||
<span class=comment>// The following, though similar to the previous code,
|
||||
// does not work: iterator_to accepts a reference to
|
||||
// the element in the container, not a copy.</span>
|
||||
<span class=keyword>int</span> <span class=identifier>x</span><span class=special>=</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>back</span><span class=special>();</span>
|
||||
<span class=identifier>c</span><span class=special>.</span><span class=identifier>erase</span><span class=special>(</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>iterator_to</span><span class=special>(</span><span class=identifier>x</span><span class=special>));</span> <span class=comment>// run-time failure ensues</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
<code>iterator_to</code> provides a way to retrieve an iterator to an element
|
||||
from a pointer to the element, thus making iterators and pointers interchangeable
|
||||
for the purposes of element pointing (not so for traversal) in many situations.
|
||||
This notwithstanding, it is not the aim of <code>iterator_to</code> to
|
||||
promote the usage of pointers as substitutes for real iterators: the latter are
|
||||
specifically designed for handling the elements of a container,
|
||||
and not only benefit from the iterator orientation of container interfaces,
|
||||
but are also capable of exposing many more programming bugs than raw pointers, both
|
||||
at compile and run time. <code>iterator_to</code> is thus meant to be used
|
||||
in scenarios where access via iterators is not suitable or desireable:
|
||||
<ul>
|
||||
<li>Interoperability with preexisting APIs based on pointers or references.</li>
|
||||
<li>Publication of pointer-based interfaces (for instance, when
|
||||
designing a C-compatible library).
|
||||
</li>
|
||||
<li>The exposure of pointers in place of iterators can act as a <i>type
|
||||
erasure</i> barrier effectively decoupling the user of the code
|
||||
from the implementation detail of which particular container is being
|
||||
used. Similar techniques, like the famous Pimpl idiom, are used
|
||||
in large projects to reduce dependencies and build times.
|
||||
</li>
|
||||
<li>Self-referencing contexts where an element acts upon its owner
|
||||
container and no iterator to itself is available.
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="ordered_node_compression">Ordered indices node compression</a></h2>
|
||||
|
||||
<p>
|
||||
Ordered and ranked indices are implemented by means of a data structure
|
||||
Ordered indices are implemented by means of a data structure
|
||||
known as a <i>red-black tree</i>. Nodes of a red-back tree contain pointers
|
||||
to the parent and the two children nodes, plus a 1-bit field referred to as
|
||||
the <i>node color</i> (hence the name of the structure). Due to alignment
|
||||
@@ -791,7 +634,7 @@ significant bit of the address must always be zero.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Boost.MultiIndex ordered and ranked indices implement this type of node compression
|
||||
Boost.MultiIndex ordered indices implement this type of node compression
|
||||
whenever applicable. As compared with common implementations of the STL
|
||||
container <code>std::set</code>, node compression can
|
||||
result in a reduction of header overload by 25% (from 16 to 12 bytes on
|
||||
@@ -821,9 +664,9 @@ Key extraction
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised August 6th 2018</p>
|
||||
<p>Revised February 6th 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2018 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
@@ -39,12 +39,8 @@ Container creation
|
||||
<ul>
|
||||
<li><a href="#identity"><code>identity</code></a></li>
|
||||
<li><a href="#member"><code>member</code></a></li>
|
||||
<li><a href="#const_mem_fun"><code>const_mem_fun</code> and <code>mem_fun</code></a>
|
||||
<ul>
|
||||
<li><a href="#x_mem_fun">Variants for other types of member functions</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#global_fun"><code>global_fun</code></a></li>
|
||||
<li><a href="#const_mem_fun"><code>const_mem_fun</code>
|
||||
and <code>mem_fun</code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#user_defined_key_extractors">User-defined key extractors</a></li>
|
||||
@@ -53,7 +49,6 @@ Container creation
|
||||
<li><a href="#composite_keys_hash">Composite keys and hashed indices</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#key">C++17 terse key specification syntax</a></li>
|
||||
<li><a href="#advanced_key_extractors">Advanced features of Boost.MultiIndex key
|
||||
extractors</a></li>
|
||||
</ul>
|
||||
@@ -98,10 +93,10 @@ of the element and do not depend on external data.
|
||||
A key extractor is called <i>read/write</i> if it returns a non-constant reference
|
||||
to the key when passed a non-constant element, and it is called <i>read-only</i>
|
||||
otherwise. Boost.MultiIndex requires that the key extractor be read/write
|
||||
when using the <code>modify_key</code> member function of key-based
|
||||
when using the <code>modify_key</code> member function of ordered and hashed
|
||||
indices. In all other situations, read-only extractors suffice.
|
||||
The section on <a href="#advanced_key_extractors">advanced features
|
||||
of Boost.MultiIndex key extractors</a> shows typical situations on which the predefined
|
||||
of Boost.MultiIndex key extractors</a> details which of the predefined
|
||||
key extractors are read/write.
|
||||
</p>
|
||||
|
||||
@@ -249,155 +244,6 @@ of Boost.MultiIndex key extractors</a>.
|
||||
provides a complete program showing how to use <code>const_mem_fun</code>.
|
||||
<p>
|
||||
|
||||
<h4><a name="x_mem_fun">Variants for other types of member functions</a></h4>
|
||||
|
||||
<p>
|
||||
Consider the following, non-compiling code:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=keyword>struct</span> <span class=identifier>employee</span>
|
||||
<span class=special>{</span>
|
||||
<span class=special>...</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>size_t</span> <span class=identifier>salary</span><span class=special>()</span><span class=keyword>const</span><span class=special><b>&</b>;</span> <span class=comment>// note the &</span>
|
||||
<span class=special>};</span>
|
||||
|
||||
<span class=keyword>typedef</span> <span class=identifier>multi_index_container</span><span class=special><</span>
|
||||
<span class=identifier>employee</span><span class=special>,</span>
|
||||
<span class=identifier>indexed_by</span><span class=special><</span>
|
||||
<span class=special>...</span>
|
||||
<span class=identifier>ordered_non_unique</span><span class=special><</span>
|
||||
<span class=comment>// compiler error: can't convert &employee::salary to
|
||||
// std::size_t (employee::*)() const</span>
|
||||
<span class=identifier><b>const_mem_fun</b></span><span class=special><</span><span class=identifier>employee</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>employee</span><span class=special>::</span><span class=identifier>salary</span><span class=special>></span>
|
||||
<span class=special>></span>
|
||||
<span class=special>></span>
|
||||
<span class=special>></span> <span class=identifier>employee_set</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
The problem here is that the type of <code>&employee::salary</code>, which is
|
||||
<a href="https://en.cppreference.com/w/cpp/language/member_functions#const-.2C_volatile-.2C_and_ref-qualified_member_functions">ref-qualified</a>,
|
||||
does not match exactly what <code>const_mem_fun</code> expects. Fortunately, Boost.MultiIndex
|
||||
provides a variant to fit:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=keyword>typedef</span> <span class=identifier>multi_index_container</span><span class=special><</span>
|
||||
<span class=identifier>employee</span><span class=special>,</span>
|
||||
<span class=identifier>indexed_by</span><span class=special><</span>
|
||||
<span class=special>...</span>
|
||||
<span class=identifier>ordered_non_unique</span><span class=special><</span>
|
||||
<span class=identifier><b>cref_mem_fun</b></span><span class=special><</span><span class=identifier>employee</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>employee</span><span class=special>::</span><span class=identifier>salary</span><span class=special>></span>
|
||||
<span class=special>></span>
|
||||
<span class=special>></span>
|
||||
<span class=special>></span> <span class=identifier>employee_set</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
This is the list of all available variants of <code>const_mem_fun</code> and
|
||||
<code>mem_fun</code>:
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<table cellspacing="0">
|
||||
<caption><b>Variants of <code>const_mem_fun</code> and <code>mem_fun</code>.</b></caption>
|
||||
<tr>
|
||||
<th> Member function example </th>
|
||||
<th>Suitable extractor</th>
|
||||
<th>Behaves as</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>int f()const volatile</code></td>
|
||||
<td><a href="../reference/key_extraction.html#cv_mem_fun"><code>cv_mem_fun</code></a><code><int,X,&X::f></code></td>
|
||||
<td align="center" rowspan="3"> <code>const_mem_fun</code> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>int f()const&</code></td>
|
||||
<td><a href="../reference/key_extraction.html#cv_mem_fun"><code>cref_mem_fun</code></a><code><int,X,&X::f></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>int f()const volatile&</code></td>
|
||||
<td><a href="../reference/key_extraction.html#cv_mem_fun"><code>cvref_mem_fun</code></a><code><int,X,&X::f></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>int f()volatile</code></td>
|
||||
<td><a href="../reference/key_extraction.html#volatile_mem_fun"><code>volatile_mem_fun</code></a><code><int,X,&X::f></code></td>
|
||||
<td align="center" rowspan="3"><code>mem_fun</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>int f()&</code></td>
|
||||
<td><a href="../reference/key_extraction.html#volatile_mem_fun"><code>ref_mem_fun</code></a><code><int,X,&X::f></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>int f()volatile&</code></td>
|
||||
<td><a href="../reference/key_extraction.html#volatile_mem_fun"><code>vref_mem_fun</code></a><code><int,X,&X::f></code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<h3><a name="global_fun"><code>global_fun</code></a></h3>
|
||||
|
||||
<p>
|
||||
Whereas <code>const_mem_fun</code> and its variants are based on a
|
||||
given member function of the base type from where the key is extracted,
|
||||
<a href="../reference/key_extraction.html#global_fun"><code>global_fun</code></a>
|
||||
takes a global function (or static member function) accepting the base
|
||||
type as its parameter and returning the key:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<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>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>global_fun</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>></span>
|
||||
|
||||
<span class=keyword>struct</span> <span class=identifier>rectangle</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>int</span> <span class=identifier>x0</span><span class=special>,</span><span class=identifier>y0</span><span class=special>;</span>
|
||||
<span class=keyword>int</span> <span class=identifier>x1</span><span class=special>,</span><span class=identifier>y1</span><span class=special>;</span>
|
||||
<span class=special>};</span>
|
||||
|
||||
<span class=keyword>unsigned</span> <span class=keyword>long</span> <span class=identifier>area</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>rectangle</span><span class=special>&</span> <span class=identifier>r</span><span class=special>)</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>return</span> <span class=special>(</span><span class=keyword>unsigned</span> <span class=keyword>long</span><span class=special>)(</span><span class=identifier>r</span><span class=special>.</span><span class=identifier>x1</span><span class=special>-</span><span class=identifier>r</span><span class=special>.</span><span class=identifier>x0</span><span class=special>)*(</span><span class=identifier>r</span><span class=special>.</span><span class=identifier>x1</span><span class=special>-</span><span class=identifier>r</span><span class=special>.</span><span class=identifier>x0</span><span class=special>)+</span>
|
||||
<span class=special>(</span><span class=keyword>unsigned</span> <span class=keyword>long</span><span class=special>)(</span><span class=identifier>r</span><span class=special>.</span><span class=identifier>y1</span><span class=special>-</span><span class=identifier>r</span><span class=special>.</span><span class=identifier>y0</span><span class=special>)*(</span><span class=identifier>r</span><span class=special>.</span><span class=identifier>y1</span><span class=special>-</span><span class=identifier>r</span><span class=special>.</span><span class=identifier>y0</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>rectangle</span><span class=special>,</span>
|
||||
<span class=identifier>indexed_by</span><span class=special><</span>
|
||||
<span class=comment>// sort by increasing area</span>
|
||||
<span class=identifier>ordered_non_unique</span><span class=special><</span><span class=identifier>global_fun</span><span class=special><</span><span class=keyword>const</span> <span class=identifier>rectangle</span><span class=special>&,</span><span class=keyword>unsigned</span> <span class=keyword>long</span><span class=special>,&</span><span class=identifier>area</span><span class=special>></span> <span class=special>></span>
|
||||
<span class=special>></span>
|
||||
<span class=special>></span> <span class=identifier>rectangle_container</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
The specification of <code>global_fun</code> obeys the following syntax:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=identifier>global_fun</span><span class=special><</span><span class=identifier><i>(argument type)</i></span><span class=special>,</span><span class=identifier><i>(key type)</i></span><span class=special>,</span><span class=identifier><i>(pointer to function)</i></span><span class=special>></span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
where the argument type and key type must match <i>exactly</i> those in the
|
||||
signature of the function used; for instance, in the example above the argument
|
||||
type is <code>const rectangle&</code>, without omitting the "<code>const</code>"
|
||||
and "<code>&</code>" parts. So, although most of the time the base type will be
|
||||
accepted by constant reference, <code>global_fun</code> is also prepared to take
|
||||
functions accepting their argument by value or by non-constant reference: this
|
||||
latter case cannot generally be used directly in the specification of
|
||||
<code>multi_index_container</code>s as their elements are treated as constant,
|
||||
but the section on <a href="#advanced_key_extractors">advanced features
|
||||
of Boost.MultiIndex key extractors</a> describes valid use cases of
|
||||
key extraction based on such functions with a non-constant reference argument.
|
||||
</p>
|
||||
|
||||
<p><a href="../examples.html#example2">Example 2</a> in the examples section
|
||||
uses <code>gobal_fun</code>.
|
||||
<p>
|
||||
|
||||
<h2><a name="user_defined_key_extractors">User-defined key extractors</a></h2>
|
||||
|
||||
<p>
|
||||
@@ -478,7 +324,7 @@ The analogous concept in Boost.MultiIndex is modeled by means of
|
||||
<span class=keyword>typedef</span> <span class=identifier>multi_index_container</span><span class=special><</span>
|
||||
<span class=identifier>phonebook_entry</span><span class=special>,</span>
|
||||
<span class=identifier>indexed_by</span><span class=special><</span>
|
||||
<span class=comment>// non-unique as some subscribers might have more than one number</span>
|
||||
<span class=comment>//non-unique as some subscribers might have more than one number</span>
|
||||
<span class=identifier>ordered_non_unique</span><span class=special><</span>
|
||||
<span class=identifier>composite_key</span><span class=special><</span>
|
||||
<span class=identifier>phonebook_entry</span><span class=special>,</span>
|
||||
@@ -503,7 +349,7 @@ key are accomplished by passing tuples with the values searched:
|
||||
<span class=identifier>phonebook</span> <span class=identifier>pb</span><span class=special>;</span>
|
||||
<span class=special>...</span>
|
||||
<span class=comment>// search for Dorothea White's number</span>
|
||||
<span class=identifier>phonebook</span><span class=special>::</span><span class=identifier>iterator</span> <span class=identifier>it</span><span class=special>=</span><span class=identifier>pb</span><span class=special>.</span><span class=identifier>find</span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>make_tuple</span><span class=special>(</span><span class=string>"White"</span><span class=special>,</span><span class=string>"Dorothea"</span><span class=special>));</span>
|
||||
<span class=identifier>phonebook</span><span class=special>::</span><span class=identifier>iterator</span> <span class=identifier>it</span><span class=special>=</span><span class=identifier>pb</span><span class=special>.</span><span class=identifier>find</span><span class=special>(</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>make_tuple</span><span class=special>(</span><span class=string>"White"</span><span class=special>,</span><span class=string>"Dorothea"</span><span class=special>));</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>number</span><span class=special>=</span><span class=identifier>it</span><span class=special>-></span><span class=identifier>phone_number</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
|
||||
@@ -518,7 +364,7 @@ order allows for partial searches where only the first keys are specified:
|
||||
<span class=special>...</span>
|
||||
<span class=comment>// look for all Whites</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>pair</span><span class=special><</span><span class=identifier>phonebook</span><span class=special>::</span><span class=identifier>iterator</span><span class=special>,</span><span class=identifier>phonebook</span><span class=special>::</span><span class=identifier>iterator</span><span class=special>></span> <span class=identifier>p</span><span class=special>=</span>
|
||||
<span class=identifier>pb</span><span class=special>.</span><span class=identifier>equal_range</span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>make_tuple</span><span class=special>(</span><span class=string>"White"</span><span class=special>));</span>
|
||||
<span class=identifier>pb</span><span class=special>.</span><span class=identifier>equal_range</span><span class=special>(</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>make_tuple</span><span class=special>(</span><span class=string>"White"</span><span class=special>));</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
@@ -613,7 +459,7 @@ Composite keys can also be used with hashed indices in a straightforward manner:
|
||||
<span class=keyword>void</span> <span class=identifier>streets_in_quadrant</span><span class=special>(</span><span class=keyword>int</span> <span class=identifier>x</span><span class=special>,</span><span class=keyword>int</span> <span class=identifier>y</span><span class=special>)</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>street_locator</span><span class=special>::</span><span class=identifier>iterator</span><span class=special>,</span><span class=identifier>street_locator</span><span class=special>::</span><span class=identifier>iterator</span><span class=special>></span> <span class=identifier>p</span><span class=special>=</span>
|
||||
<span class=identifier>sl</span><span class=special>.</span><span class=identifier>equal_range</span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>make_tuple</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>sl</span><span class=special>.</span><span class=identifier>equal_range</span><span class=special>(</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>make_tuple</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=keyword>while</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=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>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=identifier>name</span><span class=special><<</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>endl</span><span class=special>;</span>
|
||||
@@ -678,7 +524,7 @@ only the first elements of a composite key:
|
||||
<span class=comment>// try to locate streets in quadrants with x==0
|
||||
// compile-time error: hashed indices do not allow such operations</span>
|
||||
<span class=identifier>std</span><span class=special>::</span><span class=identifier>pair</span><span class=special><</span><span class=identifier>street_locator</span><span class=special>::</span><span class=identifier>iterator</span><span class=special>,</span><span class=identifier>street_locator</span><span class=special>::</span><span class=identifier>iterator</span><span class=special>></span> <span class=identifier>p</span><span class=special>=</span>
|
||||
<span class=identifier>sl</span><span class=special>.</span><span class=identifier>equal_range</span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>make_tuple</span><span class=special>(</span><span class=number>0</span><span class=special>));</span>
|
||||
<span class=identifier>sl</span><span class=special>.</span><span class=identifier>equal_range</span><span class=special>(</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>make_tuple</span><span class=special>(</span><span class=number>0</span><span class=special>));</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
@@ -687,86 +533,6 @@ key depends on all of its elements, it is impossible to calculate it from
|
||||
partial information.
|
||||
</p>
|
||||
|
||||
<h2><a name="key">C++17 terse key specification syntax</a></h2>
|
||||
|
||||
<p>
|
||||
C++17 introduces the declaration of <code>auto</code> template parameters, which can be
|
||||
taken advantage of to eliminate some redundancy in the specification of Boost.MultiIndex
|
||||
predefined key extractors. For instance, instead of the classical:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=keyword>typedef</span> <span class=identifier>multi_index_container</span><span class=special><</span>
|
||||
<span class=identifier>employee</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>identity</span><span class=special><</span><span class=identifier>employee</span><span class=special>></span> <span class=special>>,</span>
|
||||
<span class=identifier>ordered_non_unique</span><span class=special><</span><span class=identifier>member</span><span class=special><</span><span class=identifier>employee</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>employee</span><span class=special>::</span><span class=identifier>name</span><span class=special>></span> <span class=special>>,</span>
|
||||
<span class=identifier>ordered_non_unique</span><span class=special><</span>
|
||||
<span class=identifier>const_mem_fun</span><span class=special><</span><span class=identifier>employee</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>employee</span><span class=special>::</span><span class=identifier>name_length</span><span class=special>></span>
|
||||
<span class=special>></span>
|
||||
<span class=special>></span>
|
||||
<span class=special>></span> <span class=identifier>employee_set</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
|
||||
one can now write:
|
||||
|
||||
<blockquote><pre>
|
||||
<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</span><span class=special>.</span><span class=identifier>hpp</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>employee</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>identity</span><span class=special><</span><span class=identifier>employee</span><span class=special>>>,</span>
|
||||
<span class=identifier>ordered_non_unique</span><span class=special><</span><span class=identifier><b>key</b></span><span class=special><b><&</b></span><span class=identifier><b>employee</b></span><span class=special><b>::</b></span><span class=identifier><b>name</b></span><span class=special><b>></b>>,</span>
|
||||
<span class=identifier>ordered_non_unique</span><span class=special><</span><span class=identifier><b>key</b></span><span class=special><b><&</b></span><span class=identifier><b>employee</b></span><span class=special><b>::</b></span><span class=identifier><b>name_length</b></span><span class=special><b>></b>></span>
|
||||
<span class=special>></span>
|
||||
<span class=special>></span> <span class=identifier>employee_set</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
which results in the exact same defined type, as
|
||||
<a href="../reference/key_extraction.html#key"><code>key</code></a> constructs are mere
|
||||
aliases for the old syntax. <code>key</code> can be used to shorten the specification of
|
||||
<a href="../reference/key_extraction.html#member"><code>member</code></a>,
|
||||
<a href="../reference/key_extraction.html#const_mem_fun"><code>const_mem_fun</code></a>
|
||||
(and <a href="../reference/key_extraction.html#cv_mem_fun">variants</a>),
|
||||
<a href="../reference/key_extraction.html#mem_fun"><code>mem_fun</code></a>
|
||||
(and <a href="../reference/key_extraction.html#volatile_mem_fun">variants</a>),
|
||||
<a href="../reference/key_extraction.html#global_fun"><code>global_fun</code></a>
|
||||
and, with additional terseness benefits,
|
||||
<a href="../reference/key_extraction.html#composite_key"><code>composite_key</code></a>:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=keyword>typedef</span> <span class=identifier>multi_index_container</span><span class=special><</span>
|
||||
<span class=identifier>phonebook_entry</span><span class=special>,</span>
|
||||
<span class=identifier>indexed_by</span><span class=special><</span>
|
||||
<span class=comment>// composite key on family name and given name</span>
|
||||
<span class=identifier>ordered_non_unique</span><span class=special><
|
||||
</span><span class=identifier><b>key</b></span><span class=special><b><&</b></span><span class=identifier><b>phonebook_entry</b></span><span class=special><b>::</b></span><span class=identifier><b>family_name</b></span><span class=special><b>,&</b></span><span class=identifier><b>phonebook_entry</b></span><span class=special><b>::</b></span><span class=identifier><b>given_name</b></span><span class=special><b>></b></span>
|
||||
<span class=special>>,</span>
|
||||
<span class=comment>// unique index on phone number</span>
|
||||
<span class=identifier>ordered_unique</span><span class=special><</span><span class=identifier>key</span><span class=special><&</span><span class=identifier>phonebook_entry</span><span class=special>::</span><span class=identifier>phone_number</span><span class=special>>></span>
|
||||
<span class=special>></span>
|
||||
<span class=special>></span> <span class=identifier>phonebook</span><span class=special>;</span>
|
||||
</pre></blockquote>
|
||||
|
||||
In this example, the first usage of <code>key</code> substitutes for the
|
||||
decidedly more cumbersome:
|
||||
|
||||
<blockquote><pre>
|
||||
<span class=identifier>composite_key</span><span class=special><</span>
|
||||
<span class=identifier>phonebook_entry</span><span class=special>,</span>
|
||||
<span class=identifier>member</span><span class=special><</span><span class=identifier>phonebook_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>phonebook_entry</span><span class=special>::</span><span class=identifier>family_name</span><span class=special>>,</span>
|
||||
<span class=identifier>member</span><span class=special><</span><span class=identifier>phonebook_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>phonebook_entry</span><span class=special>::</span><span class=identifier>given_name</span><span class=special>></span>
|
||||
<span class=special>></span>
|
||||
</pre></blockquote>
|
||||
|
||||
Note that we did not even have to specify the first <code>phonebook_entry</code>
|
||||
argument: the internal machinery of <code>key</code> automatically deduces it for
|
||||
us. Check the <a href="../reference/key_extraction.html#key_synopsis">reference</a>
|
||||
for technical details.
|
||||
|
||||
<h2><a name="advanced_key_extractors">Advanced features of Boost.MultiIndex key
|
||||
extractors</a></h2>
|
||||
|
||||
@@ -846,7 +612,7 @@ pointers to <code>employee</code> are:
|
||||
<ul>
|
||||
<li><code>employee *</code>,</li>
|
||||
<li><code>const employee *</code>,</li>
|
||||
<li><code>std::unique_ptr<employee></code>,</li>
|
||||
<li><code>std::auto_ptr<employee></code>,</li>
|
||||
<li><code>std::list<boost::reference_wrapper<employee> >::iterator</code>,</li>
|
||||
<li><code>employee **</code>,</li>
|
||||
<li><code>boost::shared_ptr<const employee *></code>.</li>
|
||||
@@ -866,12 +632,10 @@ following final type:
|
||||
<blockquote><pre>
|
||||
<span class=keyword>struct</span> <span class=identifier>T</span>
|
||||
<span class=special>{</span>
|
||||
<span class=keyword>int</span> <span class=identifier>i</span><span class=special>;</span>
|
||||
<span class=keyword>const</span> <span class=keyword>int</span> <span class=identifier>j</span><span class=special>;</span>
|
||||
<span class=keyword>int</span> <span class=identifier>f</span><span class=special>()</span><span class=keyword>const</span><span class=special>;</span>
|
||||
<span class=keyword>int</span> <span class=identifier>g</span><span class=special>();</span>
|
||||
<span class=keyword>static</span> <span class=keyword>int</span> <span class=identifier>gf</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>T</span><span class=special>&);</span>
|
||||
<span class=keyword>static</span> <span class=keyword>int</span> <span class=identifier>gg</span><span class=special>(</span><span class=identifier>T</span><span class=special>&);</span>
|
||||
<span class=keyword>int</span> <span class=identifier>i</span><span class=special>;</span>
|
||||
<span class=keyword>const</span> <span class=keyword>int</span> <span class=identifier>j</span><span class=special>;</span>
|
||||
<span class=keyword>int</span> <span class=identifier>f</span><span class=special>()</span><span class=keyword>const</span><span class=special>;</span>
|
||||
<span class=keyword>int</span> <span class=identifier>g</span><span class=special>();</span>
|
||||
<span class=special>};</span>
|
||||
</pre></blockquote>
|
||||
|
||||
@@ -892,7 +656,7 @@ each of its members.
|
||||
<th>read/write?</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" rowspan="6"><code>T</code></td>
|
||||
<td align="center" rowspan="4"><code>T</code></td>
|
||||
<td><code>i</code></td>
|
||||
<td><code>member<T,int,&T::i></code></td>
|
||||
<td align="center">yes</td>
|
||||
@@ -916,21 +680,9 @@ each of its members.
|
||||
<td align="center">no</td>
|
||||
<td align="center">no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>gf()</code></td>
|
||||
<td><code>global_fun<const T&,int,&T::gf></code></td>
|
||||
<td align="center">yes</td>
|
||||
<td align="center">no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>gg()</code></td>
|
||||
<td><code>global_fun<T&,int,&T::gg></code></td>
|
||||
<td align="center">no</td>
|
||||
<td align="center">no</td>
|
||||
</tr>
|
||||
|
||||
<tr class="odd_tr">
|
||||
<td align="center" rowspan="6"><code>reference_wrapper<T></code></td>
|
||||
<td align="center" rowspan="4"><code>reference_wrapper<T></code></td>
|
||||
<td><code>i</code></td>
|
||||
<td><code>member<T,int,&T::i></code></td>
|
||||
<td align="center">yes</td>
|
||||
@@ -954,21 +706,9 @@ each of its members.
|
||||
<td align="center">yes</td>
|
||||
<td align="center">no</td>
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<td><code>gf()</code></td>
|
||||
<td><code>global_fun<const T&,int,&T::gf></code></td>
|
||||
<td align="center">yes</td>
|
||||
<td align="center">no</td>
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<td><code>gg()</code></td>
|
||||
<td><code>global_fun<T&,int,&T::gg></code></td>
|
||||
<td align="center">yes</td>
|
||||
<td align="center">no</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="center" rowspan="6"><code>reference_wrapper<const T></code></td>
|
||||
<td align="center" rowspan="4"><code>reference_wrapper<const T></code></td>
|
||||
<td><code>i</code></td>
|
||||
<td><code>member<T,const int,&T::i></code></td>
|
||||
<td align="center">yes</td>
|
||||
@@ -990,19 +730,9 @@ each of its members.
|
||||
<td><code>g()</code></td>
|
||||
<td colspan="3"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>gf()</code></td>
|
||||
<td><code>global_fun<const T&,int,&T::gf></code></td>
|
||||
<td align="center">yes</td>
|
||||
<td align="center">no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>gg()</code></td>
|
||||
<td colspan="3"> </td>
|
||||
</tr>
|
||||
|
||||
<tr class="odd_tr">
|
||||
<td align="center" rowspan="6">chained pointer to <code>T</code><br>
|
||||
<td align="center" rowspan="4">chained pointer to <code>T</code><br>
|
||||
or to <code>reference_wrapper<T></code></td>
|
||||
<td><code>i</code></td>
|
||||
<td><code>member<T,int,&T::i></code></td>
|
||||
@@ -1027,21 +757,9 @@ each of its members.
|
||||
<td align="center">yes</td>
|
||||
<td align="center">no</td>
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<td><code>gf()</code></td>
|
||||
<td><code>global_fun<const T&,int,&T::gf></code></td>
|
||||
<td align="center">yes</td>
|
||||
<td align="center">no</td>
|
||||
</tr>
|
||||
<tr class="odd_tr">
|
||||
<td><code>gg()</code></td>
|
||||
<td><code>global_fun<T&,int,&T::gg></code></td>
|
||||
<td align="center">yes</td>
|
||||
<td align="center">no</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="center" rowspan="6">chained pointer to <code>const T</code><br>
|
||||
<td align="center" rowspan="4">chained pointer to <code>const T</code><br>
|
||||
or to <code>reference_wrapper<const T></code></td>
|
||||
<td><code>i</code></td>
|
||||
<td><code>member<T,const int,&T::i></code></td>
|
||||
@@ -1064,16 +782,6 @@ each of its members.
|
||||
<td><code>g()</code></td>
|
||||
<td colspan="3"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>gf()</code></td>
|
||||
<td><code>global_fun<const T&,int,&T::gf></code></td>
|
||||
<td align="center">yes</td>
|
||||
<td align="center">no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>gg()</code></td>
|
||||
<td colspan="3"> </td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</p>
|
||||
@@ -1082,12 +790,10 @@ each of its members.
|
||||
The column "applicable to <code>const</code> elements?" states whether the
|
||||
corresponding key extractor can be used when passed constant elements (this
|
||||
relates to the elements specified in the first column, not the referenced
|
||||
<code>T</code> objects). The only negative cases are for <code>T::g</code> and
|
||||
<code>T:gg</code> when the elements are raw <code>T</code> objects, which make sense
|
||||
as we are dealing with a non-constant member function (<code>T::g</code>)
|
||||
and a function taking <code>T</code> by
|
||||
non-constant reference: this also implies that <code>multi_index_container</code>s
|
||||
of elements of <code>T</code> cannot be sorted by <code>T::g</code> or <code>T::gg</code>, because
|
||||
<code>T</code> objects). The only negative case is for <code>T::g</code> when
|
||||
the elements are raw <code>T</code> objects, which make sense as we are dealing
|
||||
with a non-constant member function: this also implies that <code>multi_index_container</code>s
|
||||
of elements of <code>T</code> cannot be sorted by <code>T::g</code>, because
|
||||
elements contained within a <code>multi_index_container</code> are treated as constant.
|
||||
</p>
|
||||
|
||||
@@ -1098,7 +804,7 @@ The column "read/write?" shows which combinations yield
|
||||
|
||||
<p>
|
||||
Some care has to be taken to preserve <code>const</code>-correctness in the
|
||||
specification of <code>member</code> key extractors: in some sense, the <code>const</code>
|
||||
specification of the key extractors: in some sense, the <code>const</code>
|
||||
qualifier is carried along to the member part, even if that particular
|
||||
member is not defined as <code>const</code>. For instance, if the elements
|
||||
are of type <code>const T *</code>, sorting by <code>T::i</code> is <i>not</i>
|
||||
@@ -1126,9 +832,9 @@ Container creation
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised April 19th 2020</p>
|
||||
<p>Revised February 6th 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2020 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
@@ -285,7 +285,7 @@ definition of the <code>multi_index_container</code>:
|
||||
Each of these types is an MPL sequence with as many elements as indices
|
||||
comprise the <code>multi_index_container</code>: for instance, the <code>n</code>-th
|
||||
element of <code>iterator_type_list</code> is the same as
|
||||
<code>nth_index<n>::type::iterator</code>.
|
||||
<code>nth_index_iterator<n>::type</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -392,9 +392,9 @@ Boost.MultiIndex reference
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised November 7th 2008</p>
|
||||
<p>Revised February 6th 2006</p>
|
||||
|
||||
<p>© Copyright 2003-2008 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
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">
|
||||
|
||||
+4
-9
@@ -1,6 +1,6 @@
|
||||
# Boost.MultiIndex examples Jamfile
|
||||
#
|
||||
# Copyright 2003-2007 Joaquín M López Muñoz.
|
||||
# Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
# 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)
|
||||
@@ -27,19 +27,14 @@ exe composite_keys
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
exe fun_key
|
||||
: fun_key.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
exe hashed
|
||||
: hashed.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
exe ip_allocator
|
||||
: ip_allocator.cpp
|
||||
: <include>$(BOOST_ROOT) <threading>multi
|
||||
exe memfun_key
|
||||
: memfun_key.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
exe non_default_ctor
|
||||
|
||||
+5
-2
@@ -1,6 +1,6 @@
|
||||
/* Boost.MultiIndex basic example.
|
||||
*
|
||||
* Copyright 2003-2013 Joaquin M Lopez Munoz.
|
||||
* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -69,7 +69,10 @@ typedef multi_index_container<
|
||||
> employee_set;
|
||||
|
||||
template<typename Tag,typename MultiIndexContainer>
|
||||
void print_out_by(const MultiIndexContainer& s)
|
||||
void print_out_by(
|
||||
const MultiIndexContainer& s,
|
||||
Tag* =0 /* fixes a MSVC++ 6.0 bug with implicit template function parms */
|
||||
)
|
||||
{
|
||||
/* obtain a reference to the index tagged by Tag */
|
||||
|
||||
|
||||
+5
-12
@@ -1,6 +1,6 @@
|
||||
/* Boost.MultiIndex example of a bidirectional map.
|
||||
*
|
||||
* Copyright 2003-2009 Joaquin M Lopez Munoz.
|
||||
* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <boost/multi_index/ordered_index.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
using boost::multi_index_container;
|
||||
using namespace boost::multi_index;
|
||||
@@ -34,15 +35,7 @@ struct to{};
|
||||
template<typename FromType,typename ToType>
|
||||
struct bidirectional_map
|
||||
{
|
||||
struct value_type
|
||||
{
|
||||
value_type(const FromType& first_,const ToType& second_):
|
||||
first(first_),second(second_)
|
||||
{}
|
||||
|
||||
FromType first;
|
||||
ToType second;
|
||||
};
|
||||
typedef std::pair<FromType,ToType> value_type;
|
||||
|
||||
#if defined(BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS) ||\
|
||||
defined(BOOST_MSVC)&&(BOOST_MSVC<1300) ||\
|
||||
@@ -115,7 +108,7 @@ int main()
|
||||
std::cout<<word<<" is said "<<it->second<<" in English"<<std::endl;
|
||||
}
|
||||
else{
|
||||
nth_index<dictionary,1>::type::iterator it2=get<1>(d).find(word);
|
||||
nth_index_iterator<dictionary,1>::type it2=get<1>(d).find(word);
|
||||
if(it2!=get<1>(d).end()){
|
||||
std::cout<<word<<" is said "<<it2->first<<" in Spanish"<<std::endl;
|
||||
}
|
||||
@@ -136,7 +129,7 @@ int main()
|
||||
else{
|
||||
/* word not found in Spanish, try our luck in English */
|
||||
|
||||
dictionary::index<to>::type::iterator it2=d.get<to>().find(word);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Boost.MultiIndex example: complex searches and foreign keys.
|
||||
*
|
||||
* Copyright 2003-2008 Joaquin M Lopez Munoz.
|
||||
* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -245,7 +245,7 @@ int main()
|
||||
|
||||
/* find all the cars for the manufacturer given */
|
||||
|
||||
boost::multi_index::index<car_table,manufacturer>::type::iterator ic0,ic1;
|
||||
index_iterator<car_table,manufacturer>::type ic0,ic1;
|
||||
boost::tuples::tie(ic0,ic1)=get<manufacturer>(ct).equal_range(cm);
|
||||
|
||||
/* construct a view (indexed by price) with these */
|
||||
@@ -280,7 +280,7 @@ int main()
|
||||
|
||||
/* find the cars in the range given */
|
||||
|
||||
boost::multi_index::index<car_table,price>::type::iterator ic0,ic1;
|
||||
index_iterator<car_table,price>::type ic0,ic1;
|
||||
ic0=get<price>(ct).lower_bound(min_price);
|
||||
ic1=get<price>(ct).upper_bound(max_price);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Boost.MultiIndex example of composite keys.
|
||||
*
|
||||
* Copyright 2003-2008 Joaquin M Lopez Munoz.
|
||||
* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <boost/multi_index/composite_key.hpp>
|
||||
#include <boost/multi_index/member.hpp>
|
||||
#include <boost/multi_index/ordered_index.hpp>
|
||||
#include <boost/next_prior.hpp>
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@@ -81,9 +80,19 @@ typedef multi_index_container<
|
||||
file_entry,
|
||||
indexed_by<
|
||||
/* primary index sorted by name (inside the same directory) */
|
||||
ordered_unique<name_key>,
|
||||
ordered_unique<
|
||||
name_key
|
||||
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
,composite_key_result_less<name_key::result_type>
|
||||
#endif
|
||||
>,
|
||||
/* secondary index sorted by size (inside the same directory) */
|
||||
ordered_non_unique<size_key>
|
||||
ordered_non_unique<
|
||||
size_key
|
||||
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
,composite_key_result_less<size_key::result_type>
|
||||
#endif
|
||||
>
|
||||
>
|
||||
> file_system;
|
||||
|
||||
@@ -278,7 +287,7 @@ int main()
|
||||
continue;
|
||||
}
|
||||
|
||||
it->second->execute(boost::next(tok.begin()),tok.end());
|
||||
it->second->execute(++tok.begin(),tok.end());
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
+1
-3
@@ -1,6 +1,6 @@
|
||||
/* Boost.MultiIndex example of use of hashed indices.
|
||||
*
|
||||
* Copyright 2003-2008 Joaquin M Lopez Munoz.
|
||||
* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -66,8 +66,6 @@ typedef boost::tokenizer<boost::char_separator<char> > text_tokenizer;
|
||||
|
||||
int main()
|
||||
{
|
||||
/* boostinspect:noascii */
|
||||
|
||||
std::string text=
|
||||
"En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha "
|
||||
"mucho tiempo que vivía un hidalgo de los de lanza en astillero, adarga "
|
||||
|
||||
@@ -1,293 +0,0 @@
|
||||
/* Boost.MultiIndex example of use of Boost.Interprocess allocators.
|
||||
*
|
||||
* Copyright 2003-2008 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
#define BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING
|
||||
#define BOOST_MULTI_INDEX_ENABLE_SAFE_MODE
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <algorithm>
|
||||
#include <boost/interprocess/allocators/allocator.hpp>
|
||||
#include <boost/interprocess/containers/string.hpp>
|
||||
#include <boost/interprocess/managed_mapped_file.hpp>
|
||||
#include <boost/interprocess/sync/named_mutex.hpp>
|
||||
#include <boost/interprocess/sync/scoped_lock.hpp>
|
||||
#include <boost/multi_index_container.hpp>
|
||||
#include <boost/multi_index/ordered_index.hpp>
|
||||
#include <boost/multi_index/member.hpp>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
using boost::multi_index_container;
|
||||
using namespace boost::multi_index;
|
||||
namespace bip=boost::interprocess;
|
||||
|
||||
/* shared_string is a string type placeable in shared memory,
|
||||
* courtesy of Boost.Interprocess.
|
||||
*/
|
||||
|
||||
typedef bip::basic_string<
|
||||
char,std::char_traits<char>,
|
||||
bip::allocator<char,bip::managed_mapped_file::segment_manager>
|
||||
> shared_string;
|
||||
|
||||
/* Book record. All its members can be placed in shared memory,
|
||||
* hence the structure itself can too.
|
||||
*/
|
||||
|
||||
struct book
|
||||
{
|
||||
shared_string name;
|
||||
shared_string author;
|
||||
unsigned pages;
|
||||
unsigned prize;
|
||||
|
||||
book(const shared_string::allocator_type& al):
|
||||
name(al),author(al),pages(0),prize(0)
|
||||
{}
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os,const book& b)
|
||||
{
|
||||
os<<b.author<<": \""<<b.name<<"\", $"<<b.prize<<", "<<b.pages<<" pages\n";
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
/* partial_str_less allows for partial searches taking into account
|
||||
* only the first n chars of the strings compared against. See
|
||||
* Tutorial: Basics: Special lookup operations for more info on this
|
||||
* type of comparison functors.
|
||||
*/
|
||||
|
||||
/* partial_string is a mere string holder used to differentiate from
|
||||
* a plain string.
|
||||
*/
|
||||
|
||||
struct partial_string
|
||||
{
|
||||
partial_string(const shared_string& str):str(str){}
|
||||
shared_string str;
|
||||
};
|
||||
|
||||
struct partial_str_less
|
||||
{
|
||||
bool operator()(const shared_string& x,const shared_string& y)const
|
||||
{
|
||||
return x<y;
|
||||
}
|
||||
|
||||
bool operator()(const shared_string& x,const partial_string& y)const
|
||||
{
|
||||
return x.substr(0,y.str.size())<y.str;
|
||||
}
|
||||
|
||||
bool operator()(const partial_string& x,const shared_string& y)const
|
||||
{
|
||||
return x.str<y.substr(0,x.str.size());
|
||||
}
|
||||
};
|
||||
|
||||
/* Define a multi_index_container of book records with indices on
|
||||
* author, name and prize. The index on names allows for partial
|
||||
* searches. This container can be placed in shared memory because:
|
||||
* * book can be placed in shared memory.
|
||||
* * We are using a Boost.Interprocess specific allocator.
|
||||
*/
|
||||
|
||||
/* see Compiler specifics: Use of member_offset for info on
|
||||
* BOOST_MULTI_INDEX_MEMBER
|
||||
*/
|
||||
|
||||
typedef multi_index_container<
|
||||
book,
|
||||
indexed_by<
|
||||
ordered_non_unique<
|
||||
BOOST_MULTI_INDEX_MEMBER(book,shared_string,author)
|
||||
>,
|
||||
ordered_non_unique<
|
||||
BOOST_MULTI_INDEX_MEMBER(book,shared_string,name),
|
||||
partial_str_less
|
||||
>,
|
||||
ordered_non_unique<
|
||||
BOOST_MULTI_INDEX_MEMBER(book,unsigned,prize)
|
||||
>
|
||||
>,
|
||||
bip::allocator<book,bip::managed_mapped_file::segment_manager>
|
||||
> book_container;
|
||||
|
||||
/* A small utility to get data entered via std::cin */
|
||||
|
||||
template<typename T>
|
||||
void enter(const char* msg,T& t)
|
||||
{
|
||||
std::cout<<msg;
|
||||
std::string str;
|
||||
std::getline(std::cin,str);
|
||||
std::istringstream iss(str);
|
||||
iss>>t;
|
||||
}
|
||||
|
||||
void enter(const char* msg,std::string& str)
|
||||
{
|
||||
std::cout<<msg;
|
||||
std::getline(std::cin,str);
|
||||
}
|
||||
|
||||
void enter(const char* msg,shared_string& str)
|
||||
{
|
||||
std::cout<<msg;
|
||||
std::string stdstr;
|
||||
std::getline(std::cin,stdstr);
|
||||
str=stdstr.c_str();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
/* Create (or open) the memory mapped file where the book container
|
||||
* is stored, along with a mutex for synchronized access.
|
||||
*/
|
||||
|
||||
bip::managed_mapped_file seg(
|
||||
bip::open_or_create,"./book_container.db",
|
||||
65536);
|
||||
bip::named_mutex mutex(
|
||||
bip::open_or_create,"7FD6D7E8-320B-11DC-82CF-F0B655D89593");
|
||||
|
||||
/* create or open the book container in shared memory */
|
||||
|
||||
book_container* pbc=seg.find_or_construct<book_container>("book container")(
|
||||
book_container::ctor_args_list(),
|
||||
book_container::allocator_type(seg.get_segment_manager()));
|
||||
|
||||
std::string command_info=
|
||||
"1. list books by author\n"
|
||||
"2. list all books by prize\n"
|
||||
"3. insert a book\n"
|
||||
"4. delete a book\n"
|
||||
"0. exit\n";
|
||||
|
||||
std::cout<<command_info;
|
||||
|
||||
/* main loop */
|
||||
|
||||
for(bool exit=false;!exit;){
|
||||
int command=-1;
|
||||
enter("command: ",command);
|
||||
|
||||
switch(command){
|
||||
case 0:{ /* exit */
|
||||
exit=true;
|
||||
break;
|
||||
}
|
||||
case 1:{ /* list books by author */
|
||||
std::string author;
|
||||
enter("author (empty=all authors): ",author);
|
||||
|
||||
/* operations with the container must be mutex protected */
|
||||
|
||||
bip::scoped_lock<bip::named_mutex> lock(mutex);
|
||||
|
||||
std::pair<book_container::iterator,book_container::iterator> rng;
|
||||
if(author.empty()){
|
||||
rng=std::make_pair(pbc->begin(),pbc->end());
|
||||
}
|
||||
else{
|
||||
rng=pbc->equal_range(
|
||||
shared_string(
|
||||
author.c_str(),
|
||||
shared_string::allocator_type(seg.get_segment_manager())));
|
||||
}
|
||||
|
||||
if(rng.first==rng.second){
|
||||
std::cout<<"no entries\n";
|
||||
}
|
||||
else{
|
||||
std::copy(
|
||||
rng.first,rng.second,std::ostream_iterator<book>(std::cout));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:{ /* list all books by prize */
|
||||
bip::scoped_lock<bip::named_mutex> lock(mutex);
|
||||
|
||||
std::copy(
|
||||
get<2>(*pbc).begin(),get<2>(*pbc).end(),
|
||||
std::ostream_iterator<book>(std::cout));
|
||||
break;
|
||||
}
|
||||
case 3:{ /* insert a book */
|
||||
book b(shared_string::allocator_type(seg.get_segment_manager()));
|
||||
|
||||
enter("author: ",b.author);
|
||||
enter("name: " ,b.name);
|
||||
enter("prize: " ,b.prize);
|
||||
enter("pages: " ,b.pages);
|
||||
|
||||
std::cout<<"insert the following?\n"<<b<<"(y/n): ";
|
||||
char yn='n';
|
||||
enter("",yn);
|
||||
if(yn=='y'||yn=='Y'){
|
||||
bip::scoped_lock<bip::named_mutex> lock(mutex);
|
||||
pbc->insert(b);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 4:{ /* delete a book */
|
||||
shared_string name(
|
||||
shared_string::allocator_type(seg.get_segment_manager()));
|
||||
enter(
|
||||
"name of the book (you can enter\nonly the first few characters): ",
|
||||
name);
|
||||
|
||||
typedef nth_index<book_container,1>::type index_by_name;
|
||||
index_by_name& idx=get<1>(*pbc);
|
||||
index_by_name::iterator it;
|
||||
book b(shared_string::allocator_type(seg.get_segment_manager()));
|
||||
|
||||
{
|
||||
/* Look for a book whose title begins with name. Note that we
|
||||
* are unlocking after doing the search so as to not leave the
|
||||
* container blocked during user prompting. That is also why a
|
||||
* local copy of the book is done.
|
||||
*/
|
||||
|
||||
bip::scoped_lock<bip::named_mutex> lock(mutex);
|
||||
|
||||
it=idx.find(partial_string(name));
|
||||
if(it==idx.end()){
|
||||
std::cout<<"no such book found\n";
|
||||
break;
|
||||
}
|
||||
b=*it;
|
||||
}
|
||||
|
||||
std::cout<<"delete the following?\n"<<b<<"(y/n): ";
|
||||
char yn='n';
|
||||
enter("",yn);
|
||||
if(yn=='y'||yn=='Y'){
|
||||
bip::scoped_lock<bip::named_mutex> lock(mutex);
|
||||
idx.erase(it);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
std::cout<<"select one option:\n"<<command_info;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Boost.MultiIndex example of functions used as key extractors.
|
||||
/* Boost.MultiIndex example of member functions used as key extractors.
|
||||
*
|
||||
* Copyright 2003-2008 Joaquin M Lopez Munoz.
|
||||
* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -14,7 +14,6 @@
|
||||
#endif
|
||||
|
||||
#include <boost/multi_index_container.hpp>
|
||||
#include <boost/multi_index/global_fun.hpp>
|
||||
#include <boost/multi_index/mem_fun.hpp>
|
||||
#include <boost/multi_index/ordered_index.hpp>
|
||||
#include <iostream>
|
||||
@@ -47,13 +46,7 @@ private:
|
||||
std::string family_name;
|
||||
};
|
||||
|
||||
std::string::size_type name_record_length(const name_record& r)
|
||||
{
|
||||
return r.name().size();
|
||||
}
|
||||
|
||||
/* multi_index_container with indices based on name_record::name()
|
||||
* and name_record_length().
|
||||
/* multi_index_container with only one index based on name_record::name().
|
||||
* See Compiler specifics: Use of const_mem_fun_explicit and
|
||||
* mem_fun_explicit for info on BOOST_MULTI_INDEX_CONST_MEM_FUN.
|
||||
*/
|
||||
@@ -63,9 +56,6 @@ typedef multi_index_container<
|
||||
indexed_by<
|
||||
ordered_unique<
|
||||
BOOST_MULTI_INDEX_CONST_MEM_FUN(name_record,std::string,name)
|
||||
>,
|
||||
ordered_non_unique<
|
||||
global_fun<const name_record&,std::string::size_type,name_record_length>
|
||||
>
|
||||
>
|
||||
> name_record_set;
|
||||
@@ -81,20 +71,9 @@ int main()
|
||||
|
||||
/* list the names in ns in phonebook order */
|
||||
|
||||
std::cout<<"Phonenook order\n"
|
||||
<<"---------------"<<std::endl;
|
||||
for(name_record_set::iterator it=ns.begin();it!=ns.end();++it){
|
||||
std::cout<<it->name()<<std::endl;
|
||||
}
|
||||
|
||||
/* list the names in ns according to their length*/
|
||||
|
||||
std::cout<<"\nLength order\n"
|
||||
<< "------------"<<std::endl;
|
||||
for(nth_index<name_record_set,1>::type::iterator it1=get<1>(ns).begin();
|
||||
it1!=get<1>(ns).end();++it1){
|
||||
std::cout<<it1->name()<<std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Boost.MultiIndex example of use of multi_index_container::ctor_args_list.
|
||||
*
|
||||
* Copyright 2003-2008 Joaquin M Lopez Munoz.
|
||||
* Copyright 2003-2004 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Boost.MultiIndex example of use of random access indices.
|
||||
*
|
||||
* Copyright 2003-2008 Joaquin M Lopez Munoz.
|
||||
* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
|
||||
+10
-29
@@ -1,6 +1,6 @@
|
||||
/* Boost.MultiIndex example of use of rearrange facilities.
|
||||
*
|
||||
* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -14,6 +14,7 @@
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/multi_index_container.hpp>
|
||||
#include <boost/multi_index/random_access_index.hpp>
|
||||
#include <boost/random/binomial_distribution.hpp>
|
||||
@@ -24,10 +25,6 @@
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_RANDOM)
|
||||
#include <random>
|
||||
#endif
|
||||
|
||||
using boost::multi_index_container;
|
||||
using namespace boost::multi_index;
|
||||
|
||||
@@ -139,11 +136,11 @@ void riffle_shuffle(
|
||||
{
|
||||
static boost::mt19937 rnd_gen;
|
||||
|
||||
typedef typename std::iterator_traits<
|
||||
RandomAccessIterator>::difference_type difference_type;
|
||||
typedef typename boost::detail::iterator_traits<
|
||||
RandomAccessIterator>::difference_type difference_type;
|
||||
typedef boost::binomial_distribution<
|
||||
difference_type> rnd_cut_select_type;
|
||||
typedef boost::uniform_real<> rnd_deck_select_type;
|
||||
difference_type> rnd_cut_select_type;
|
||||
typedef boost::uniform_real<> rnd_deck_select_type;
|
||||
|
||||
rnd_cut_select_type cut_select(last-first);
|
||||
RandomAccessIterator middle=first+cut_select(rnd_gen);
|
||||
@@ -181,38 +178,22 @@ private:
|
||||
};
|
||||
|
||||
/* A truly random shuffle (up to stdlib implementation quality) using
|
||||
* std::shuffle.
|
||||
* std::random_shuffle.
|
||||
*/
|
||||
|
||||
struct random_shuffler
|
||||
{
|
||||
void operator()(deck& d)
|
||||
void operator()(deck& d)const
|
||||
{
|
||||
dv.clear();
|
||||
dv.reserve(d.size());
|
||||
std::copy(d.begin(),d.end(),std::back_inserter(dv));
|
||||
shuffle_view();
|
||||
std::random_shuffle(dv.begin(),dv.end()); /* do the shuffling */
|
||||
d.rearrange(dv.begin()); /* apply to the deck */
|
||||
}
|
||||
|
||||
private:
|
||||
deck_view dv;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_RANDOM)
|
||||
std::mt19937 e;
|
||||
|
||||
void shuffle_view()
|
||||
{
|
||||
std::shuffle(dv.begin(),dv.end(),e);
|
||||
}
|
||||
#else
|
||||
/* for pre-C++11 compilers we use std::random_shuffle */
|
||||
|
||||
void shuffle_view()
|
||||
{
|
||||
std::random_shuffle(dv.begin(),dv.end());
|
||||
}
|
||||
#endif
|
||||
mutable deck_view dv;
|
||||
};
|
||||
|
||||
/* Repeat a given shuffling algorithm repeats_num times
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Boost.MultiIndex example of use of sequenced indices.
|
||||
*
|
||||
* Copyright 2003-2008 Joaquin M Lopez Munoz.
|
||||
* Copyright 2003-2005 Joaqu匤 M L�ez Mu�z.
|
||||
* 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)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Boost.MultiIndex example of serialization of a MRU list.
|
||||
*
|
||||
* Copyright 2003-2008 Joaquin M Lopez Munoz.
|
||||
* Copyright 2003-2006 Joaqu匤 M L�ez Mu�z.
|
||||
* 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)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2015 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,17 +9,18 @@
|
||||
#ifndef BOOST_MULTI_INDEX_COMPOSITE_KEY_HPP
|
||||
#define BOOST_MULTI_INDEX_COMPOSITE_KEY_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/functional/hash_fwd.hpp>
|
||||
#include <boost/multi_index/detail/access_specifier.hpp>
|
||||
#include <boost/multi_index/detail/prevent_eti.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/mpl/aux_/nttp_decl.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/control/expr_if.hpp>
|
||||
#include <boost/preprocessor/list/at.hpp>
|
||||
@@ -39,11 +40,6 @@
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)&&\
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#include <boost/multi_index/detail/cons_stdtuple.hpp>
|
||||
#endif
|
||||
|
||||
/* A composite key stores n key extractors and "computes" the
|
||||
* result on a given value as a packed reference to the value and
|
||||
* the composite key itself. Actual invocations to the component
|
||||
@@ -62,8 +58,12 @@
|
||||
*/
|
||||
|
||||
#if !defined(BOOST_MULTI_INDEX_LIMIT_COMPOSITE_KEY_SIZE)
|
||||
#if defined(BOOST_MSVC)&&(BOOST_MSVC<1300)
|
||||
#define BOOST_MULTI_INDEX_LIMIT_COMPOSITE_KEY_SIZE 5
|
||||
#else
|
||||
#define BOOST_MULTI_INDEX_LIMIT_COMPOSITE_KEY_SIZE 10
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* maximum number of key extractors in a composite key */
|
||||
|
||||
@@ -106,6 +106,7 @@
|
||||
namespace boost{
|
||||
|
||||
template<class T> class reference_wrapper; /* fwd decl. */
|
||||
template<class T> struct hash; /* fwd decl. */
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
@@ -113,14 +114,17 @@ namespace detail{
|
||||
|
||||
/* n-th key extractor of a composite key */
|
||||
|
||||
template<typename CompositeKey,int N>
|
||||
template<typename CompositeKey,BOOST_MPL_AUX_NTTP_DECL(int, N)>
|
||||
struct nth_key_from_value
|
||||
{
|
||||
typedef typename CompositeKey::key_extractor_tuple key_extractor_tuple;
|
||||
typedef typename mpl::eval_if_c<
|
||||
N<tuples::length<key_extractor_tuple>::value,
|
||||
typedef typename prevent_eti<
|
||||
tuples::element<N,key_extractor_tuple>,
|
||||
mpl::identity<tuples::null_type>
|
||||
typename mpl::eval_if_c<
|
||||
N<tuples::length<key_extractor_tuple>::value,
|
||||
tuples::element<N,key_extractor_tuple>,
|
||||
mpl::identity<tuples::null_type>
|
||||
>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
@@ -142,7 +146,7 @@ struct BOOST_PP_CAT(key_,name)<tuples::null_type> \
|
||||
typedef tuples::null_type type; \
|
||||
}; \
|
||||
\
|
||||
template<typename CompositeKey,int N> \
|
||||
template<typename CompositeKey,BOOST_MPL_AUX_NTTP_DECL(int, N)> \
|
||||
struct BOOST_PP_CAT(nth_composite_key_,name) \
|
||||
{ \
|
||||
typedef typename nth_key_from_value<CompositeKey,N>::type key_from_value; \
|
||||
@@ -559,11 +563,6 @@ struct hash_cval:
|
||||
|
||||
/* composite_key_result */
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4512)
|
||||
#endif
|
||||
|
||||
template<typename CompositeKey>
|
||||
struct composite_key_result
|
||||
{
|
||||
@@ -579,12 +578,18 @@ struct composite_key_result
|
||||
const value_type& value;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
/* composite_key */
|
||||
|
||||
/* NB. Some overloads of operator() have an extra dummy parameter int=0.
|
||||
* This disambiguator serves several purposes:
|
||||
* - Without it, MSVC++ 6.0 incorrectly regards some overloads as
|
||||
* specializations of a previous member function template.
|
||||
* - MSVC++ 6.0/7.0 seem to incorrectly treat some different memfuns
|
||||
* as if they have the same signature.
|
||||
* - If remove_const is broken due to lack of PTS, int=0 avoids the
|
||||
* declaration of memfuns with identical signature.
|
||||
*/
|
||||
|
||||
template<
|
||||
typename Value,
|
||||
BOOST_MULTI_INDEX_CK_ENUM(BOOST_MULTI_INDEX_CK_TEMPLATE_PARM,KeyFromValue)
|
||||
@@ -634,7 +639,7 @@ public:
|
||||
return result_type(*this,x.get());
|
||||
}
|
||||
|
||||
result_type operator()(const reference_wrapper<value_type>& x)const
|
||||
result_type operator()(const reference_wrapper<value_type>& x,int=0)const
|
||||
{
|
||||
return result_type(*this,x.get());
|
||||
}
|
||||
@@ -717,55 +722,6 @@ inline bool operator==(
|
||||
y.value,detail::generic_operator_equal_tuple());
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)&&\
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<typename CompositeKey,typename... Values>
|
||||
inline bool operator==(
|
||||
const composite_key_result<CompositeKey>& x,
|
||||
const std::tuple<Values...>& y)
|
||||
{
|
||||
typedef typename CompositeKey::key_extractor_tuple key_extractor_tuple;
|
||||
typedef typename CompositeKey::value_type value_type;
|
||||
typedef std::tuple<Values...> key_tuple;
|
||||
typedef typename detail::cons_stdtuple_ctor<
|
||||
key_tuple>::result_type cons_key_tuple;
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
static_cast<std::size_t>(tuples::length<key_extractor_tuple>::value)==
|
||||
std::tuple_size<key_tuple>::value);
|
||||
|
||||
return detail::equal_ckey_cval<
|
||||
key_extractor_tuple,value_type,
|
||||
cons_key_tuple,detail::generic_operator_equal_tuple
|
||||
>::compare(
|
||||
x.composite_key.key_extractors(),x.value,
|
||||
detail::make_cons_stdtuple(y),detail::generic_operator_equal_tuple());
|
||||
}
|
||||
|
||||
template<typename CompositeKey,typename... Values>
|
||||
inline bool operator==(
|
||||
const std::tuple<Values...>& x,
|
||||
const composite_key_result<CompositeKey>& y)
|
||||
{
|
||||
typedef typename CompositeKey::key_extractor_tuple key_extractor_tuple;
|
||||
typedef typename CompositeKey::value_type value_type;
|
||||
typedef std::tuple<Values...> key_tuple;
|
||||
typedef typename detail::cons_stdtuple_ctor<
|
||||
key_tuple>::result_type cons_key_tuple;
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
static_cast<std::size_t>(tuples::length<key_extractor_tuple>::value)==
|
||||
std::tuple_size<key_tuple>::value);
|
||||
|
||||
return detail::equal_ckey_cval<
|
||||
key_extractor_tuple,value_type,
|
||||
cons_key_tuple,detail::generic_operator_equal_tuple
|
||||
>::compare(
|
||||
detail::make_cons_stdtuple(x),y.composite_key.key_extractors(),
|
||||
y.value,detail::generic_operator_equal_tuple());
|
||||
}
|
||||
#endif
|
||||
|
||||
/* < */
|
||||
|
||||
template<typename CompositeKey1,typename CompositeKey2>
|
||||
@@ -830,47 +786,6 @@ inline bool operator<(
|
||||
y.value,detail::generic_operator_less_tuple());
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)&&\
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<typename CompositeKey,typename... Values>
|
||||
inline bool operator<(
|
||||
const composite_key_result<CompositeKey>& x,
|
||||
const std::tuple<Values...>& y)
|
||||
{
|
||||
typedef typename CompositeKey::key_extractor_tuple key_extractor_tuple;
|
||||
typedef typename CompositeKey::value_type value_type;
|
||||
typedef std::tuple<Values...> key_tuple;
|
||||
typedef typename detail::cons_stdtuple_ctor<
|
||||
key_tuple>::result_type cons_key_tuple;
|
||||
|
||||
return detail::compare_ckey_cval<
|
||||
key_extractor_tuple,value_type,
|
||||
cons_key_tuple,detail::generic_operator_less_tuple
|
||||
>::compare(
|
||||
x.composite_key.key_extractors(),x.value,
|
||||
detail::make_cons_stdtuple(y),detail::generic_operator_less_tuple());
|
||||
}
|
||||
|
||||
template<typename CompositeKey,typename... Values>
|
||||
inline bool operator<(
|
||||
const std::tuple<Values...>& x,
|
||||
const composite_key_result<CompositeKey>& y)
|
||||
{
|
||||
typedef typename CompositeKey::key_extractor_tuple key_extractor_tuple;
|
||||
typedef typename CompositeKey::value_type value_type;
|
||||
typedef std::tuple<Values...> key_tuple;
|
||||
typedef typename detail::cons_stdtuple_ctor<
|
||||
key_tuple>::result_type cons_key_tuple;
|
||||
|
||||
return detail::compare_ckey_cval<
|
||||
key_extractor_tuple,value_type,
|
||||
cons_key_tuple,detail::generic_operator_less_tuple
|
||||
>::compare(
|
||||
detail::make_cons_stdtuple(x),y.composite_key.key_extractors(),
|
||||
y.value,detail::generic_operator_less_tuple());
|
||||
}
|
||||
#endif
|
||||
|
||||
/* rest of comparison operators */
|
||||
|
||||
#define BOOST_MULTI_INDEX_CK_COMPLETE_COMP_OPS(t1,t2,a1,a2) \
|
||||
@@ -915,23 +830,6 @@ BOOST_MULTI_INDEX_CK_COMPLETE_COMP_OPS(
|
||||
composite_key_result<CompositeKey>
|
||||
)
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)&&\
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
BOOST_MULTI_INDEX_CK_COMPLETE_COMP_OPS(
|
||||
typename CompositeKey,
|
||||
typename... Values,
|
||||
composite_key_result<CompositeKey>,
|
||||
std::tuple<Values...>
|
||||
)
|
||||
|
||||
BOOST_MULTI_INDEX_CK_COMPLETE_COMP_OPS(
|
||||
typename CompositeKey,
|
||||
typename... Values,
|
||||
std::tuple<Values...>,
|
||||
composite_key_result<CompositeKey>
|
||||
)
|
||||
#endif
|
||||
|
||||
/* composite_key_equal_to */
|
||||
|
||||
template
|
||||
@@ -1032,59 +930,6 @@ public:
|
||||
key_tuple,key_eq_tuple
|
||||
>::compare(x,y.composite_key.key_extractors(),y.value,key_eqs());
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)&&\
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<typename CompositeKey,typename... Values>
|
||||
bool operator()(
|
||||
const composite_key_result<CompositeKey>& x,
|
||||
const std::tuple<Values...>& y)const
|
||||
{
|
||||
typedef typename CompositeKey::key_extractor_tuple key_extractor_tuple;
|
||||
typedef typename CompositeKey::value_type value_type;
|
||||
typedef std::tuple<Values...> key_tuple;
|
||||
typedef typename detail::cons_stdtuple_ctor<
|
||||
key_tuple>::result_type cons_key_tuple;
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
tuples::length<key_extractor_tuple>::value<=
|
||||
tuples::length<key_eq_tuple>::value&&
|
||||
static_cast<std::size_t>(tuples::length<key_extractor_tuple>::value)==
|
||||
std::tuple_size<key_tuple>::value);
|
||||
|
||||
return detail::equal_ckey_cval<
|
||||
key_extractor_tuple,value_type,
|
||||
cons_key_tuple,key_eq_tuple
|
||||
>::compare(
|
||||
x.composite_key.key_extractors(),x.value,
|
||||
detail::make_cons_stdtuple(y),key_eqs());
|
||||
}
|
||||
|
||||
template<typename CompositeKey,typename... Values>
|
||||
bool operator()(
|
||||
const std::tuple<Values...>& x,
|
||||
const composite_key_result<CompositeKey>& y)const
|
||||
{
|
||||
typedef typename CompositeKey::key_extractor_tuple key_extractor_tuple;
|
||||
typedef typename CompositeKey::value_type value_type;
|
||||
typedef std::tuple<Values...> key_tuple;
|
||||
typedef typename detail::cons_stdtuple_ctor<
|
||||
key_tuple>::result_type cons_key_tuple;
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
std::tuple_size<key_tuple>::value<=
|
||||
static_cast<std::size_t>(tuples::length<key_eq_tuple>::value)&&
|
||||
std::tuple_size<key_tuple>::value==
|
||||
static_cast<std::size_t>(tuples::length<key_extractor_tuple>::value));
|
||||
|
||||
return detail::equal_ckey_cval<
|
||||
key_extractor_tuple,value_type,
|
||||
cons_key_tuple,key_eq_tuple
|
||||
>::compare(
|
||||
detail::make_cons_stdtuple(x),y.composite_key.key_extractors(),
|
||||
y.value,key_eqs());
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
/* composite_key_compare */
|
||||
@@ -1144,7 +989,7 @@ public:
|
||||
const composite_key_result<CompositeKey>& x,
|
||||
const Value& y)const
|
||||
{
|
||||
return operator()(x,boost::make_tuple(boost::cref(y)));
|
||||
return operator()(x,make_tuple(cref(y)));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1179,7 +1024,7 @@ public:
|
||||
const Value& x,
|
||||
const composite_key_result<CompositeKey>& y)const
|
||||
{
|
||||
return operator()(boost::make_tuple(boost::cref(x)),y);
|
||||
return operator()(make_tuple(cref(x)),y);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1207,59 +1052,6 @@ public:
|
||||
key_tuple,key_comp_tuple
|
||||
>::compare(x,y.composite_key.key_extractors(),y.value,key_comps());
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)&&\
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<typename CompositeKey,typename... Values>
|
||||
bool operator()(
|
||||
const composite_key_result<CompositeKey>& x,
|
||||
const std::tuple<Values...>& y)const
|
||||
{
|
||||
typedef typename CompositeKey::key_extractor_tuple key_extractor_tuple;
|
||||
typedef typename CompositeKey::value_type value_type;
|
||||
typedef std::tuple<Values...> key_tuple;
|
||||
typedef typename detail::cons_stdtuple_ctor<
|
||||
key_tuple>::result_type cons_key_tuple;
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
tuples::length<key_extractor_tuple>::value<=
|
||||
tuples::length<key_comp_tuple>::value||
|
||||
std::tuple_size<key_tuple>::value<=
|
||||
static_cast<std::size_t>(tuples::length<key_comp_tuple>::value));
|
||||
|
||||
return detail::compare_ckey_cval<
|
||||
key_extractor_tuple,value_type,
|
||||
cons_key_tuple,key_comp_tuple
|
||||
>::compare(
|
||||
x.composite_key.key_extractors(),x.value,
|
||||
detail::make_cons_stdtuple(y),key_comps());
|
||||
}
|
||||
|
||||
template<typename CompositeKey,typename... Values>
|
||||
bool operator()(
|
||||
const std::tuple<Values...>& x,
|
||||
const composite_key_result<CompositeKey>& y)const
|
||||
{
|
||||
typedef typename CompositeKey::key_extractor_tuple key_extractor_tuple;
|
||||
typedef typename CompositeKey::value_type value_type;
|
||||
typedef std::tuple<Values...> key_tuple;
|
||||
typedef typename detail::cons_stdtuple_ctor<
|
||||
key_tuple>::result_type cons_key_tuple;
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
std::tuple_size<key_tuple>::value<=
|
||||
static_cast<std::size_t>(tuples::length<key_comp_tuple>::value)||
|
||||
tuples::length<key_extractor_tuple>::value<=
|
||||
tuples::length<key_comp_tuple>::value);
|
||||
|
||||
return detail::compare_ckey_cval<
|
||||
key_extractor_tuple,value_type,
|
||||
cons_key_tuple,key_comp_tuple
|
||||
>::compare(
|
||||
detail::make_cons_stdtuple(x),y.composite_key.key_extractors(),
|
||||
y.value,key_comps());
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
/* composite_key_hash */
|
||||
@@ -1317,25 +1109,6 @@ public:
|
||||
key_tuple,key_hasher_tuple
|
||||
>::hash(x,key_hash_functions());
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)&&\
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<typename... Values>
|
||||
std::size_t operator()(const std::tuple<Values...>& x)const
|
||||
{
|
||||
typedef std::tuple<Values...> key_tuple;
|
||||
typedef typename detail::cons_stdtuple_ctor<
|
||||
key_tuple>::result_type cons_key_tuple;
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
std::tuple_size<key_tuple>::value==
|
||||
static_cast<std::size_t>(tuples::length<key_hasher_tuple>::value));
|
||||
|
||||
return detail::hash_cval<
|
||||
cons_key_tuple,key_hasher_tuple
|
||||
>::hash(detail::make_cons_stdtuple(x),key_hash_functions());
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Instantiations of the former functors with "natural" basic components:
|
||||
@@ -1456,6 +1229,7 @@ public:
|
||||
* for composite_key_results enabling interoperation with tuples of values.
|
||||
*/
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
namespace std{
|
||||
|
||||
template<typename CompositeKey>
|
||||
@@ -1495,6 +1269,34 @@ struct hash<boost::multi_index::composite_key_result<CompositeKey> >:
|
||||
};
|
||||
|
||||
} /* namespace boost */
|
||||
#else
|
||||
/* Lacking template partial specialization, std::equal_to, std::less and
|
||||
* std::greater will still work for composite_key_results although without
|
||||
* tuple interoperability. To achieve the same graceful degrading with
|
||||
* boost::hash, we define the appropriate hash_value overload.
|
||||
*/
|
||||
|
||||
namespace boost{
|
||||
|
||||
#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
|
||||
namespace multi_index{
|
||||
#endif
|
||||
|
||||
template<typename CompositeKey>
|
||||
inline std::size_t hash_value(
|
||||
const boost::multi_index::composite_key_result<CompositeKey>& x)
|
||||
{
|
||||
boost::multi_index::composite_key_result_hash<
|
||||
boost::multi_index::composite_key_result<CompositeKey> > h;
|
||||
return h(x);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
|
||||
} /* namespace multi_index */
|
||||
#endif
|
||||
|
||||
} /* namespace boost */
|
||||
#endif
|
||||
|
||||
#undef BOOST_MULTI_INDEX_CK_RESULT_HASH_SUPER
|
||||
#undef BOOST_MULTI_INDEX_CK_RESULT_GREATER_SUPER
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2013 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_ACCESS_SPECIFIER_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_ACCESS_SPECIFIER_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
* official Sun Studio 12.
|
||||
*/
|
||||
|
||||
#if BOOST_WORKAROUND(__GNUC__,==3)&&(__GNUC_MINOR__<4)||\
|
||||
#if BOOST_WORKAROUND(__GNUC__, <3)||\
|
||||
BOOST_WORKAROUND(__GNUC__,==3)&&(__GNUC_MINOR__<4)||\
|
||||
BOOST_WORKAROUND(BOOST_MSVC,==1310)||\
|
||||
BOOST_WORKAROUND(BOOST_MSVC,==1400)||\
|
||||
BOOST_WORKAROUND(__SUNPRO_CC,BOOST_TESTED_AT(0x590))
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/* Copyright 2003-2013 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_ADL_SWAP_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_ADL_SWAP_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
template<typename T>
|
||||
void adl_swap(T& x,T& y)
|
||||
{
|
||||
|
||||
#if !defined(BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL)
|
||||
using std::swap;
|
||||
swap(x,y);
|
||||
#else
|
||||
std::swap(x,y);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif
|
||||
@@ -1,173 +0,0 @@
|
||||
/* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_ALLOCATOR_TRAITS_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_ALLOCATOR_TRAITS_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <boost/type_traits/is_empty.hpp>
|
||||
#include <memory>
|
||||
#else
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/move/core.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/multi_index/detail/vartempl_support.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/type_traits/is_empty.hpp>
|
||||
#include <new>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
/* poor man's replacement of std::allocator_traits */
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
|
||||
template<typename T> struct void_helper{typedef void type;};
|
||||
|
||||
template<typename Allocator,typename=void>
|
||||
struct allocator_is_always_equal:boost::is_empty<Allocator>{};
|
||||
|
||||
template<typename Allocator>
|
||||
struct allocator_is_always_equal<
|
||||
Allocator,
|
||||
typename void_helper<
|
||||
typename std::allocator_traits<Allocator>::is_always_equal
|
||||
>::type
|
||||
>:std::allocator_traits<Allocator>::is_always_equal{};
|
||||
|
||||
template<typename Allocator>
|
||||
struct allocator_traits:std::allocator_traits<Allocator>
|
||||
{
|
||||
/* wrap std::allocator_traits alias templates for use in C++03 codebase */
|
||||
|
||||
typedef std::allocator_traits<Allocator> super;
|
||||
|
||||
/* pre-C++17 compatibilty */
|
||||
|
||||
typedef allocator_is_always_equal<Allocator> is_always_equal;
|
||||
|
||||
template<typename T>
|
||||
struct rebind_alloc
|
||||
{
|
||||
typedef typename super::template rebind_alloc<T> type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct rebind_traits
|
||||
{
|
||||
typedef typename super::template rebind_traits<T> type;
|
||||
};
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
/* not a full std::allocator_traits rewrite (not needed) */
|
||||
|
||||
template<typename Allocator>
|
||||
struct allocator_traits
|
||||
{
|
||||
typedef Allocator allocator_type;
|
||||
typedef typename Allocator::value_type value_type;
|
||||
typedef typename Allocator::pointer pointer;
|
||||
typedef typename Allocator::const_pointer const_pointer;
|
||||
|
||||
/* [const_]void_pointer not provided as boost::pointer_traits's
|
||||
* rebind_to has been seen to fail with things like
|
||||
* boost::interprocess::offset_ptr in relatively old environments.
|
||||
*/
|
||||
|
||||
typedef typename Allocator::difference_type difference_type;
|
||||
typedef typename Allocator::size_type size_type;
|
||||
|
||||
typedef boost::false_type propagate_on_container_copy_assignment;
|
||||
typedef boost::false_type propagate_on_container_move_assignment;
|
||||
typedef boost::false_type propagate_on_container_swap;
|
||||
typedef boost::is_empty<Allocator> is_always_equal;
|
||||
|
||||
template<typename T>
|
||||
struct rebind_alloc
|
||||
{
|
||||
typedef typename Allocator::template rebind<T>::other type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct rebind_traits
|
||||
{
|
||||
typedef allocator_traits<typename rebind_alloc<T>::type> type;
|
||||
};
|
||||
|
||||
static pointer allocate(Allocator& a,size_type n){return a.allocate(n);}
|
||||
static pointer allocate(Allocator& a,size_type n,const_pointer p)
|
||||
/* should've been const_void_pointer p */
|
||||
{return a.allocate(n,p);}
|
||||
static void deallocate(Allocator& a,pointer p,size_type n)
|
||||
{a.deallocate(p,n);}
|
||||
template<typename T>
|
||||
static void construct(Allocator&,T* p,const T& x)
|
||||
{::new (static_cast<void*>(p)) T(x);}
|
||||
template<typename T>
|
||||
static void construct(Allocator&,T* p,BOOST_RV_REF(T) x)
|
||||
{::new (static_cast<void*>(p)) T(boost::move(x));}
|
||||
|
||||
template<typename T,BOOST_MULTI_INDEX_TEMPLATE_PARAM_PACK>
|
||||
static void construct(Allocator&,T* p,BOOST_MULTI_INDEX_FUNCTION_PARAM_PACK)
|
||||
{
|
||||
vartempl_placement_new(p,BOOST_MULTI_INDEX_FORWARD_PARAM_PACK);
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1500))
|
||||
/* MSVC issues spurious warnings about unreferencend formal parameters in
|
||||
* destroy<T> when T is a class with trivial dtor.
|
||||
*/
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4100)
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
static void destroy(Allocator&,T* p){p->~T();}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1500))
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
static size_type max_size(Allocator& a)BOOST_NOEXCEPT{return a.max_size();}
|
||||
|
||||
static Allocator select_on_container_copy_construction(const Allocator& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template<typename Allocator,typename T>
|
||||
struct rebind_alloc_for
|
||||
{
|
||||
typedef typename allocator_traits<Allocator>::
|
||||
template rebind_alloc<T>::type type;
|
||||
};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,12 +9,12 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_ARCHIVE_CONSTRUCTED_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_ARCHIVE_CONSTRUCTED_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/detail/no_exceptions_support.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
#include <boost/type_traits/aligned_storage.hpp>
|
||||
@@ -64,11 +64,7 @@ struct archive_constructed:private noncopyable
|
||||
(&get())->~T();
|
||||
}
|
||||
|
||||
#include <boost/multi_index/detail/ignore_wstrict_aliasing.hpp>
|
||||
|
||||
T& get(){return *reinterpret_cast<T*>(&space);}
|
||||
|
||||
#include <boost/multi_index/detail/restore_wstrict_aliasing.hpp>
|
||||
T& get(){return *static_cast<T*>(static_cast<void*>(&space));}
|
||||
|
||||
private:
|
||||
typename aligned_storage<sizeof(T),alignment_of<T>::value>::type space;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,16 +9,14 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_AUTO_SPACE_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_AUTO_SPACE_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <algorithm>
|
||||
#include <boost/multi_index/detail/adl_swap.hpp>
|
||||
#include <boost/multi_index/detail/allocator_traits.hpp>
|
||||
#include <boost/detail/allocator_utilities.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace boost{
|
||||
@@ -40,54 +38,36 @@ namespace detail{
|
||||
* "of zero length", http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14176
|
||||
* C++ Standard Library Defect Report List (Revision 28), issue 199
|
||||
* "What does allocate(0) return?",
|
||||
* http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#199
|
||||
* http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html#199
|
||||
*/
|
||||
|
||||
template<typename T,typename Allocator=std::allocator<T> >
|
||||
struct auto_space:private noncopyable
|
||||
{
|
||||
typedef typename rebind_alloc_for<
|
||||
Allocator,T>
|
||||
::type allocator;
|
||||
typedef allocator_traits<allocator> alloc_traits;
|
||||
typedef typename alloc_traits::pointer pointer;
|
||||
typedef typename alloc_traits::size_type size_type;
|
||||
|
||||
explicit auto_space(const Allocator& al=Allocator(),size_type n=1):
|
||||
al_(al),n_(n),data_(n_?alloc_traits::allocate(al_,n_):pointer(0))
|
||||
explicit auto_space(const Allocator& al=Allocator(),std::size_t n=1):
|
||||
al_(al),n_(n),data_(n_?al_.allocate(n_):0)
|
||||
{}
|
||||
|
||||
~auto_space(){if(n_)alloc_traits::deallocate(al_,data_,n_);}
|
||||
~auto_space()
|
||||
{
|
||||
if(n_)al_.deallocate(data_,n_);
|
||||
}
|
||||
|
||||
Allocator get_allocator()const{return al_;}
|
||||
|
||||
pointer data()const{return data_;}
|
||||
T* data()const{return data_;}
|
||||
|
||||
void swap(auto_space& x)
|
||||
{
|
||||
swap(
|
||||
x,
|
||||
boost::integral_constant<
|
||||
bool,alloc_traits::propagate_on_container_swap::value>());
|
||||
}
|
||||
|
||||
void swap(auto_space& x,boost::true_type /* swap_allocators */)
|
||||
{
|
||||
adl_swap(al_,x.al_);
|
||||
std::swap(n_,x.n_);
|
||||
std::swap(data_,x.data_);
|
||||
}
|
||||
|
||||
void swap(auto_space& x,boost::false_type /* swap_allocators */)
|
||||
{
|
||||
std::swap(n_,x.n_);
|
||||
std::swap(data_,x.data_);
|
||||
}
|
||||
|
||||
private:
|
||||
allocator al_;
|
||||
size_type n_;
|
||||
pointer data_;
|
||||
typename boost::detail::allocator::rebind_to<
|
||||
Allocator,T>::type al_;
|
||||
std::size_t n_;
|
||||
T* data_;
|
||||
};
|
||||
|
||||
template<typename T,typename Allocator>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2013 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_BASE_TYPE_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_BASE_TYPE_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <boost/mpl/size.hpp>
|
||||
#include <boost/multi_index/detail/index_base.hpp>
|
||||
#include <boost/multi_index/detail/is_index_list.hpp>
|
||||
#include <boost/multi_index/detail/msvc_index_specifier.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace boost{
|
||||
@@ -32,6 +33,17 @@ namespace detail{
|
||||
* a index list.
|
||||
*/
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC,<1310)
|
||||
struct index_applier
|
||||
{
|
||||
template<typename IndexSpecifierMeta,typename SuperMeta>
|
||||
struct apply:
|
||||
msvc_index_specifier<IndexSpecifierMeta::type>::
|
||||
template result_index_class<SuperMeta>
|
||||
{
|
||||
};
|
||||
};
|
||||
#else
|
||||
struct index_applier
|
||||
{
|
||||
template<typename IndexSpecifierMeta,typename SuperMeta>
|
||||
@@ -42,6 +54,7 @@ struct index_applier
|
||||
BOOST_NESTED_TEMPLATE index_class<SuperMeta>::type type;
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
||||
template<int N,typename Value,typename IndexSpecifierList,typename Allocator>
|
||||
struct nth_layer
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2018 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_BIDIR_NODE_ITERATOR_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_BIDIR_NODE_ITERATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -31,17 +31,16 @@ namespace detail{
|
||||
* iterators (ordered and sequenced indices.)
|
||||
*/
|
||||
|
||||
template<typename Node>
|
||||
template<typename Node,typename Derived=mpl::na>
|
||||
class bidir_node_iterator:
|
||||
public bidirectional_iterator_helper<
|
||||
bidir_node_iterator<Node>,
|
||||
bidir_node_iterator<Node,Derived>,
|
||||
typename Node::value_type,
|
||||
typename Node::difference_type,
|
||||
std::ptrdiff_t,
|
||||
const typename Node::value_type*,
|
||||
const typename Node::value_type&>
|
||||
{
|
||||
public:
|
||||
/* coverity[uninit_ctor]: suppress warning */
|
||||
bidir_node_iterator(){}
|
||||
explicit bidir_node_iterator(Node* node_):node(node_){}
|
||||
|
||||
@@ -50,6 +49,12 @@ public:
|
||||
return node->value();
|
||||
}
|
||||
|
||||
friend bool operator==(
|
||||
const bidir_node_iterator& x,const bidir_node_iterator& y)
|
||||
{
|
||||
return x.node==y.node;
|
||||
}
|
||||
|
||||
bidir_node_iterator& operator++()
|
||||
{
|
||||
Node::increment(node);
|
||||
@@ -97,14 +102,6 @@ private:
|
||||
Node* node;
|
||||
};
|
||||
|
||||
template<typename Node>
|
||||
bool operator==(
|
||||
const bidir_node_iterator<Node>& x,
|
||||
const bidir_node_iterator<Node>& y)
|
||||
{
|
||||
return x.get_node()==y.get_node();
|
||||
}
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,20 +9,15 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_BUCKET_ARRAY_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_BUCKET_ARRAY_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <algorithm>
|
||||
#include <boost/multi_index/detail/allocator_traits.hpp>
|
||||
#include <boost/multi_index/detail/auto_space.hpp>
|
||||
#include <boost/multi_index/detail/hash_index_node.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||
#include <boost/preprocessor/seq/elem.hpp>
|
||||
#include <boost/preprocessor/seq/enum.hpp>
|
||||
#include <boost/preprocessor/seq/size.hpp>
|
||||
#include <cstddef>
|
||||
#include <limits.h>
|
||||
|
||||
@@ -40,154 +35,103 @@ namespace detail{
|
||||
|
||||
/* bucket structure for use by hashed indices */
|
||||
|
||||
#define BOOST_MULTI_INDEX_BA_SIZES_32BIT \
|
||||
(53ul)(97ul)(193ul)(389ul)(769ul) \
|
||||
(1543ul)(3079ul)(6151ul)(12289ul)(24593ul) \
|
||||
(49157ul)(98317ul)(196613ul)(393241ul)(786433ul) \
|
||||
(1572869ul)(3145739ul)(6291469ul)(12582917ul)(25165843ul) \
|
||||
(50331653ul)(100663319ul)(201326611ul)(402653189ul)(805306457ul) \
|
||||
(1610612741ul)(3221225473ul)
|
||||
|
||||
#if ((((ULONG_MAX>>16)>>16)>>16)>>15)==0 /* unsigned long less than 64 bits */
|
||||
#define BOOST_MULTI_INDEX_BA_SIZES \
|
||||
BOOST_MULTI_INDEX_BA_SIZES_32BIT \
|
||||
(4294967291ul)
|
||||
#else
|
||||
/* obtained with aid from
|
||||
* http://javaboutique.internet.com/prime_numb/
|
||||
* http://www.rsok.com/~jrm/next_ten_primes.html
|
||||
* and verified with
|
||||
* http://www.alpertron.com.ar/ECM.HTM
|
||||
*/
|
||||
|
||||
#define BOOST_MULTI_INDEX_BA_SIZES \
|
||||
BOOST_MULTI_INDEX_BA_SIZES_32BIT \
|
||||
(6442450939ul)(12884901893ul)(25769803751ul)(51539607551ul) \
|
||||
(103079215111ul)(206158430209ul)(412316860441ul)(824633720831ul) \
|
||||
(1649267441651ul)(3298534883309ul)(6597069766657ul)(13194139533299ul) \
|
||||
(26388279066623ul)(52776558133303ul)(105553116266489ul)(211106232532969ul) \
|
||||
(422212465066001ul)(844424930131963ul)(1688849860263953ul) \
|
||||
(3377699720527861ul)(6755399441055731ul)(13510798882111483ul) \
|
||||
(27021597764222939ul)(54043195528445957ul)(108086391056891903ul) \
|
||||
(216172782113783843ul)(432345564227567621ul)(864691128455135207ul) \
|
||||
(1729382256910270481ul)(3458764513820540933ul)(6917529027641081903ul) \
|
||||
(13835058055282163729ul)(18446744073709551557ul)
|
||||
#endif
|
||||
|
||||
template<bool _=true> /* templatized to have in-header static var defs */
|
||||
class bucket_array_base:private noncopyable
|
||||
{
|
||||
protected:
|
||||
static const std::size_t sizes[
|
||||
BOOST_PP_SEQ_SIZE(BOOST_MULTI_INDEX_BA_SIZES)];
|
||||
|
||||
static std::size_t size_index(std::size_t n)
|
||||
inline static std::size_t next_prime(std::size_t n)
|
||||
{
|
||||
const std::size_t *bound=std::lower_bound(sizes,sizes+sizes_length,n);
|
||||
if(bound==sizes+sizes_length)--bound;
|
||||
return bound-sizes;
|
||||
static const std::size_t prime_list[]={
|
||||
53ul, 97ul, 193ul, 389ul, 769ul,
|
||||
1543ul, 3079ul, 6151ul, 12289ul, 24593ul,
|
||||
49157ul, 98317ul, 196613ul, 393241ul, 786433ul,
|
||||
1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul,
|
||||
50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul,
|
||||
1610612741ul, 3221225473ul,
|
||||
|
||||
#if ((((ULONG_MAX>>16)>>16)>>16)>>15)==0 /* unsigned long less than 64 bits */
|
||||
4294967291ul
|
||||
#else
|
||||
/* obtained with aid from
|
||||
* http://javaboutique.internet.com/prime_numb/
|
||||
* http://www.rsok.com/~jrm/next_ten_primes.html
|
||||
* and verified with
|
||||
* http://www.alpertron.com.ar/ECM.HTM
|
||||
*/
|
||||
|
||||
6442450939ul, 12884901893ul, 25769803751ul, 51539607551ul,
|
||||
103079215111ul, 206158430209ul, 412316860441ul, 824633720831ul,
|
||||
1649267441651ul, 3298534883309ul, 6597069766657ul, 13194139533299ul,
|
||||
26388279066623ul, 52776558133303ul, 105553116266489ul, 211106232532969ul,
|
||||
422212465066001ul, 844424930131963ul, 1688849860263953ul,
|
||||
3377699720527861ul, 6755399441055731ul, 13510798882111483ul,
|
||||
27021597764222939ul, 54043195528445957ul, 108086391056891903ul,
|
||||
216172782113783843ul, 432345564227567621ul, 864691128455135207ul,
|
||||
1729382256910270481ul, 3458764513820540933ul, 6917529027641081903ul,
|
||||
13835058055282163729ul, 18446744073709551557ul
|
||||
#endif
|
||||
|
||||
};
|
||||
static const std::size_t prime_list_size=
|
||||
sizeof(prime_list)/sizeof(prime_list[0]);
|
||||
|
||||
std::size_t const *bound=
|
||||
std::lower_bound(prime_list,prime_list+prime_list_size,n);
|
||||
if(bound==prime_list+prime_list_size)bound--;
|
||||
return *bound;
|
||||
}
|
||||
|
||||
#define BOOST_MULTI_INDEX_BA_POSITION_CASE(z,n,_) \
|
||||
case n:return hash%BOOST_PP_SEQ_ELEM(n,BOOST_MULTI_INDEX_BA_SIZES);
|
||||
|
||||
static std::size_t position(std::size_t hash,std::size_t size_index_)
|
||||
{
|
||||
/* Accelerate hash%sizes[size_index_] by replacing with a switch on
|
||||
* hash%Ci expressions, each Ci a compile-time constant, which the
|
||||
* compiler can implement without using integer division.
|
||||
*/
|
||||
|
||||
switch(size_index_){
|
||||
default: /* never used */
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_PP_SEQ_SIZE(BOOST_MULTI_INDEX_BA_SIZES),
|
||||
BOOST_MULTI_INDEX_BA_POSITION_CASE,~)
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static const std::size_t sizes_length;
|
||||
};
|
||||
|
||||
template<bool _>
|
||||
const std::size_t bucket_array_base<_>::sizes[]={
|
||||
BOOST_PP_SEQ_ENUM(BOOST_MULTI_INDEX_BA_SIZES)
|
||||
};
|
||||
|
||||
template<bool _>
|
||||
const std::size_t bucket_array_base<_>::sizes_length=
|
||||
sizeof(bucket_array_base<_>::sizes)/
|
||||
sizeof(bucket_array_base<_>::sizes[0]);
|
||||
|
||||
#undef BOOST_MULTI_INDEX_BA_POSITION_CASE
|
||||
#undef BOOST_MULTI_INDEX_BA_SIZES
|
||||
#undef BOOST_MULTI_INDEX_BA_SIZES_32BIT
|
||||
|
||||
template<typename Allocator>
|
||||
class bucket_array:bucket_array_base<>
|
||||
class bucket_array:public bucket_array_base
|
||||
{
|
||||
typedef bucket_array_base<> super;
|
||||
typedef hashed_index_base_node_impl<
|
||||
typename rebind_alloc_for<
|
||||
Allocator,
|
||||
char
|
||||
>::type
|
||||
> base_node_impl_type;
|
||||
|
||||
public:
|
||||
typedef typename base_node_impl_type::base_pointer base_pointer;
|
||||
typedef typename base_node_impl_type::pointer pointer;
|
||||
|
||||
bucket_array(const Allocator& al,pointer end_,std::size_t size_):
|
||||
size_index_(super::size_index(size_)),
|
||||
spc(al,static_cast<auto_space_size_type>(super::sizes[size_index_]+1))
|
||||
bucket_array(const Allocator& al,hashed_index_node_impl* end_,std::size_t size):
|
||||
size_(bucket_array_base::next_prime(size)),
|
||||
spc(al,size_+1)
|
||||
{
|
||||
clear(end_);
|
||||
clear();
|
||||
end()->next()=end_;
|
||||
end_->next()=end();
|
||||
}
|
||||
|
||||
std::size_t size()const
|
||||
{
|
||||
return super::sizes[size_index_];
|
||||
return size_;
|
||||
}
|
||||
|
||||
std::size_t position(std::size_t hash)const
|
||||
{
|
||||
return super::position(hash,size_index_);
|
||||
return hash%size_;
|
||||
}
|
||||
|
||||
base_pointer begin()const{return buckets();}
|
||||
base_pointer end()const{return buckets()+size();}
|
||||
base_pointer at(std::size_t n)const{return buckets()+n;}
|
||||
hashed_index_node_impl* begin()const{return &buckets()[0];}
|
||||
hashed_index_node_impl* end()const{return &buckets()[size_];}
|
||||
hashed_index_node_impl* at(std::size_t n)const{return &buckets()[n];}
|
||||
|
||||
void clear(pointer end_)
|
||||
std::size_t first_nonempty(std::size_t n)const
|
||||
{
|
||||
for(base_pointer x=begin(),y=end();x!=y;++x)x->prior()=pointer(0);
|
||||
end()->prior()=end_->prior()=end_;
|
||||
end_->next()=end();
|
||||
}
|
||||
for(;;++n){
|
||||
hashed_index_node_impl* x=at(n);
|
||||
if(x->next()!=x)return n;
|
||||
}
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
for(hashed_index_node_impl* x=begin(),*y=end();x!=y;++x)x->next()=x;
|
||||
}
|
||||
|
||||
void swap(bucket_array& x)
|
||||
{
|
||||
std::swap(size_index_,x.size_index_);
|
||||
std::swap(size_,x.size_);
|
||||
spc.swap(x.spc);
|
||||
}
|
||||
|
||||
template<typename BoolConstant>
|
||||
void swap(bucket_array& x,BoolConstant swap_allocators)
|
||||
{
|
||||
std::swap(size_index_,x.size_index_);
|
||||
spc.swap(x.spc,swap_allocators);
|
||||
}
|
||||
|
||||
private:
|
||||
typedef auto_space<base_node_impl_type,Allocator> auto_space_type;
|
||||
typedef typename auto_space_type::size_type auto_space_size_type;
|
||||
std::size_t size_;
|
||||
auto_space<hashed_index_node_impl,Allocator> spc;
|
||||
|
||||
std::size_t size_index_;
|
||||
auto_space_type spc;
|
||||
|
||||
base_pointer buckets()const
|
||||
hashed_index_node_impl* buckets()const
|
||||
{
|
||||
return spc.data();
|
||||
}
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
/* Copyright 2003-2014 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_CONS_STDTUPLE_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_CONS_STDTUPLE_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <tuple>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
/* std::tuple wrapper providing the cons-based interface of boost::tuple for
|
||||
* composite_key interoperability.
|
||||
*/
|
||||
|
||||
template<typename StdTuple,std::size_t N>
|
||||
struct cons_stdtuple;
|
||||
|
||||
struct cons_stdtuple_ctor_terminal
|
||||
{
|
||||
typedef boost::tuples::null_type result_type;
|
||||
|
||||
template<typename StdTuple>
|
||||
static result_type create(const StdTuple&)
|
||||
{
|
||||
return boost::tuples::null_type();
|
||||
}
|
||||
};
|
||||
|
||||
template<typename StdTuple,std::size_t N>
|
||||
struct cons_stdtuple_ctor_normal
|
||||
{
|
||||
typedef cons_stdtuple<StdTuple,N> result_type;
|
||||
|
||||
static result_type create(const StdTuple& t)
|
||||
{
|
||||
return result_type(t);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename StdTuple,std::size_t N=0>
|
||||
struct cons_stdtuple_ctor:
|
||||
boost::mpl::if_c<
|
||||
N<std::tuple_size<StdTuple>::value,
|
||||
cons_stdtuple_ctor_normal<StdTuple,N>,
|
||||
cons_stdtuple_ctor_terminal
|
||||
>::type
|
||||
{};
|
||||
|
||||
template<typename StdTuple,std::size_t N>
|
||||
struct cons_stdtuple
|
||||
{
|
||||
typedef typename std::tuple_element<N,StdTuple>::type head_type;
|
||||
typedef cons_stdtuple_ctor<StdTuple,N+1> tail_ctor;
|
||||
typedef typename tail_ctor::result_type tail_type;
|
||||
|
||||
cons_stdtuple(const StdTuple& t_):t(t_){}
|
||||
|
||||
const head_type& get_head()const{return std::get<N>(t);}
|
||||
tail_type get_tail()const{return tail_ctor::create(t);}
|
||||
|
||||
const StdTuple& t;
|
||||
};
|
||||
|
||||
template<typename StdTuple>
|
||||
typename cons_stdtuple_ctor<StdTuple>::result_type
|
||||
make_cons_stdtuple(const StdTuple& t)
|
||||
{
|
||||
return cons_stdtuple_ctor<StdTuple>::create(t);
|
||||
}
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_CONVERTER_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_CONVERTER_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -31,15 +31,13 @@ struct converter
|
||||
static Index& index(MultiIndexContainer& x){return x;}
|
||||
|
||||
static typename Index::const_iterator const_iterator(
|
||||
const MultiIndexContainer& x,
|
||||
typename MultiIndexContainer::final_node_type* node)
|
||||
const MultiIndexContainer& x,typename MultiIndexContainer::node_type* node)
|
||||
{
|
||||
return x.Index::make_iterator(node);
|
||||
}
|
||||
|
||||
static typename Index::iterator iterator(
|
||||
MultiIndexContainer& x,
|
||||
typename MultiIndexContainer::final_node_type* node)
|
||||
MultiIndexContainer& x,typename MultiIndexContainer::node_type* node)
|
||||
{
|
||||
return x.Index::make_iterator(node);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,20 +9,16 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_COPY_MAP_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_COPY_MAP_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <algorithm>
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/move/core.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/multi_index/detail/allocator_traits.hpp>
|
||||
#include <boost/detail/no_exceptions_support.hpp>
|
||||
#include <boost/multi_index/detail/auto_space.hpp>
|
||||
#include <boost/multi_index/detail/raw_ptr.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
|
||||
namespace boost{
|
||||
@@ -57,33 +53,14 @@ struct copy_map_entry
|
||||
}
|
||||
};
|
||||
|
||||
struct copy_map_value_copier
|
||||
{
|
||||
template<typename Value>
|
||||
const Value& operator()(Value& x)const{return x;}
|
||||
};
|
||||
|
||||
struct copy_map_value_mover
|
||||
{
|
||||
template<typename Value>
|
||||
BOOST_RV_REF(Value) operator()(Value& x)const{return boost::move(x);}
|
||||
};
|
||||
|
||||
template <typename Node,typename Allocator>
|
||||
class copy_map:private noncopyable
|
||||
{
|
||||
typedef typename rebind_alloc_for<
|
||||
Allocator,Node
|
||||
>::type allocator_type;
|
||||
typedef allocator_traits<allocator_type> alloc_traits;
|
||||
typedef typename alloc_traits::pointer pointer;
|
||||
|
||||
public:
|
||||
typedef const copy_map_entry<Node>* const_iterator;
|
||||
typedef typename alloc_traits::size_type size_type;
|
||||
typedef const copy_map_entry<Node>* const_iterator;
|
||||
|
||||
copy_map(
|
||||
const Allocator& al,size_type size,Node* header_org,Node* header_cpy):
|
||||
const Allocator& al,std::size_t size,Node* header_org,Node* header_cpy):
|
||||
al_(al),size_(size),spc(al_,size_),n(0),
|
||||
header_org_(header_org),header_cpy_(header_cpy),released(false)
|
||||
{}
|
||||
@@ -91,19 +68,33 @@ public:
|
||||
~copy_map()
|
||||
{
|
||||
if(!released){
|
||||
for(size_type i=0;i<n;++i){
|
||||
alloc_traits::destroy(
|
||||
al_,boost::addressof((spc.data()+i)->second->value()));
|
||||
deallocate((spc.data()+i)->second);
|
||||
for(std::size_t i=0;i<n;++i){
|
||||
boost::detail::allocator::destroy(&spc.data()[i].second->value());
|
||||
deallocate(spc.data()[i].second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const_iterator begin()const{return raw_ptr<const_iterator>(spc.data());}
|
||||
const_iterator end()const{return raw_ptr<const_iterator>(spc.data()+n);}
|
||||
const_iterator begin()const{return spc.data();}
|
||||
const_iterator end()const{return spc.data()+n;}
|
||||
|
||||
void copy_clone(Node* node){clone(node,copy_map_value_copier());}
|
||||
void move_clone(Node* node){clone(node,copy_map_value_mover());}
|
||||
void clone(Node* node)
|
||||
{
|
||||
spc.data()[n].first=node;
|
||||
spc.data()[n].second=al_.allocate(1);
|
||||
BOOST_TRY{
|
||||
boost::detail::allocator::construct(
|
||||
&spc.data()[n].second->value(),node->value());
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
deallocate(spc.data()[n].second);
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
++n;
|
||||
|
||||
if(n==size_)std::sort(spc.data(),spc.data()+size_);
|
||||
}
|
||||
|
||||
Node* find(Node* node)const
|
||||
{
|
||||
@@ -118,46 +109,18 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
allocator_type al_;
|
||||
size_type size_;
|
||||
auto_space<copy_map_entry<Node>,Allocator> spc;
|
||||
size_type n;
|
||||
Node* header_org_;
|
||||
Node* header_cpy_;
|
||||
bool released;
|
||||
|
||||
pointer allocate()
|
||||
{
|
||||
return alloc_traits::allocate(al_,1);
|
||||
}
|
||||
typename boost::detail::allocator::rebind_to<
|
||||
Allocator,Node>::type al_;
|
||||
std::size_t size_;
|
||||
auto_space<copy_map_entry<Node>,Allocator> spc;
|
||||
std::size_t n;
|
||||
Node* header_org_;
|
||||
Node* header_cpy_;
|
||||
bool released;
|
||||
|
||||
void deallocate(Node* node)
|
||||
{
|
||||
alloc_traits::deallocate(al_,static_cast<pointer>(node),1);
|
||||
}
|
||||
|
||||
template<typename ValueAccess>
|
||||
void clone(Node* node,ValueAccess access)
|
||||
{
|
||||
(spc.data()+n)->first=node;
|
||||
(spc.data()+n)->second=raw_ptr<Node*>(allocate());
|
||||
BOOST_TRY{
|
||||
alloc_traits::construct(
|
||||
al_,boost::addressof((spc.data()+n)->second->value()),
|
||||
access(node->value()));
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
deallocate((spc.data()+n)->second);
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
++n;
|
||||
|
||||
if(n==size_){
|
||||
std::sort(
|
||||
raw_ptr<copy_map_entry<Node>*>(spc.data()),
|
||||
raw_ptr<copy_map_entry<Node>*>(spc.data())+size_);
|
||||
}
|
||||
al_.deallocate(node,1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_DEF_CTOR_TUPLE_CONS_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_DEF_CTOR_TUPLE_CONS_HPP
|
||||
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
/* In MSVC, tuples::cons is not default constructible. We provide a
|
||||
* tiny wrapper around tuple::cons filling that hole.
|
||||
*/
|
||||
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
template<typename Cons>
|
||||
struct default_constructible_tuple_cons:Cons
|
||||
{
|
||||
default_constructible_tuple_cons():
|
||||
Cons(
|
||||
Cons::head_type(),
|
||||
static_cast<const Cons::tail_type&>(
|
||||
default_constructible_tuple_cons<Cons::tail_type>()))
|
||||
{}
|
||||
|
||||
default_constructible_tuple_cons(const Cons& cons):Cons(cons){}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct default_constructible_tuple_cons<tuples::null_type>:tuples::null_type
|
||||
{
|
||||
default_constructible_tuple_cons(){}
|
||||
default_constructible_tuple_cons(const tuples::null_type&){}
|
||||
};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif /* BOOST_MSVC */
|
||||
|
||||
#endif
|
||||
@@ -1,32 +0,0 @@
|
||||
/* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if !defined(BOOST_MULTI_INDEX_DETAIL_UNDEF_IF_CONSTEXPR_MACRO)
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_IF_CONSTEXPR)
|
||||
#define BOOST_MULTI_INDEX_IF_CONSTEXPR if constexpr
|
||||
#else
|
||||
#define BOOST_MULTI_INDEX_IF_CONSTEXPR if
|
||||
#if defined(BOOST_MSVC)
|
||||
#define BOOST_MULTI_INDEX_DETAIL_C4127_DISABLED
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127) /* conditional expression is constant */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#undef BOOST_MULTI_INDEX_IF_CONSTEXPR
|
||||
#if defined(BOOST_MULTI_INDEX_DETAIL_C4127_DISABLED)
|
||||
#pragma warning(pop)
|
||||
#undef BOOST_MULTI_INDEX_DETAIL_C4127_DISABLED
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,34 +0,0 @@
|
||||
/* Copyright 2003-2013 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_DO_NOT_COPY_ELEMENTS_TAG_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_DO_NOT_COPY_ELEMENTS_TAG_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
/* Used to mark a special ctor variant that copies the internal objects of
|
||||
* a container but not its elements.
|
||||
*/
|
||||
|
||||
struct do_not_copy_elements_tag{};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2018 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,11 +9,12 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_DUPLICATES_ITERATOR_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_DUPLICATES_ITERATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
|
||||
namespace boost{
|
||||
@@ -31,7 +32,7 @@ class duplicates_iterator
|
||||
{
|
||||
public:
|
||||
typedef typename Node::value_type value_type;
|
||||
typedef typename Node::difference_type difference_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef const typename Node::value_type* pointer;
|
||||
typedef const typename Node::value_type& reference;
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2013 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_HAS_TAG_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_HAS_TAG_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2013 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,12 +9,12 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_ARGS_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_ARGS_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/functional/hash/hash.hpp>
|
||||
#include <boost/mpl/aux_/na.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
namespace boost{
|
||||
|
||||
template<class T> struct hash; /* fwd decl. */
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_ITERATOR_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_ITERATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/split_member.hpp>
|
||||
#include <boost/serialization/version.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
@@ -31,34 +30,35 @@ namespace detail{
|
||||
/* Iterator class for hashed indices.
|
||||
*/
|
||||
|
||||
struct hashed_index_global_iterator_tag{};
|
||||
struct hashed_index_local_iterator_tag{};
|
||||
|
||||
template<
|
||||
typename Node,typename BucketArray,
|
||||
typename IndexCategory,typename IteratorCategory
|
||||
>
|
||||
template<typename Node,typename BucketArray,typename Derived=mpl::na>
|
||||
class hashed_index_iterator:
|
||||
public forward_iterator_helper<
|
||||
hashed_index_iterator<Node,BucketArray,IndexCategory,IteratorCategory>,
|
||||
hashed_index_iterator<Node,BucketArray,Derived>,
|
||||
typename Node::value_type,
|
||||
typename Node::difference_type,
|
||||
std::ptrdiff_t,
|
||||
const typename Node::value_type*,
|
||||
const typename Node::value_type&>
|
||||
{
|
||||
public:
|
||||
/* coverity[uninit_ctor]: suppress warning */
|
||||
hashed_index_iterator(){}
|
||||
hashed_index_iterator(Node* node_):node(node_){}
|
||||
hashed_index_iterator(Node* node_,BucketArray* buckets_):
|
||||
node(node_),buckets(buckets_)
|
||||
{}
|
||||
|
||||
const typename Node::value_type& operator*()const
|
||||
{
|
||||
return node->value();
|
||||
}
|
||||
|
||||
friend bool operator==(
|
||||
const hashed_index_iterator& x,const hashed_index_iterator& y)
|
||||
{
|
||||
return x.node==y.node;
|
||||
}
|
||||
|
||||
hashed_index_iterator& operator++()
|
||||
{
|
||||
this->increment(IteratorCategory());
|
||||
Node::increment(node,buckets->begin(),buckets->end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -76,42 +76,16 @@ public:
|
||||
{
|
||||
node_base_type* bnode=node;
|
||||
ar<<serialization::make_nvp("pointer",bnode);
|
||||
ar<<serialization::make_nvp("pointer",buckets);
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
void load(Archive& ar,const unsigned int version)
|
||||
{
|
||||
load(ar,version,IteratorCategory());
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
void load(
|
||||
Archive& ar,const unsigned int version,hashed_index_global_iterator_tag)
|
||||
void load(Archive& ar,const unsigned int)
|
||||
{
|
||||
node_base_type* bnode;
|
||||
ar>>serialization::make_nvp("pointer",bnode);
|
||||
node=static_cast<Node*>(bnode);
|
||||
if(version<1){
|
||||
BucketArray* throw_away; /* consume unused ptr */
|
||||
ar>>serialization::make_nvp("pointer",throw_away);
|
||||
}
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
void load(
|
||||
Archive& ar,const unsigned int version,hashed_index_local_iterator_tag)
|
||||
{
|
||||
node_base_type* bnode;
|
||||
ar>>serialization::make_nvp("pointer",bnode);
|
||||
node=static_cast<Node*>(bnode);
|
||||
if(version<1){
|
||||
BucketArray* buckets;
|
||||
ar>>serialization::make_nvp("pointer",buckets);
|
||||
if(buckets&&node&&node->impl()==buckets->end()->prior()){
|
||||
/* end local_iterators used to point to end node, now they are null */
|
||||
node=0;
|
||||
}
|
||||
}
|
||||
ar>>serialization::make_nvp("pointer",buckets);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -122,58 +96,14 @@ public:
|
||||
Node* get_node()const{return node;}
|
||||
|
||||
private:
|
||||
|
||||
void increment(hashed_index_global_iterator_tag)
|
||||
{
|
||||
Node::template increment<IndexCategory>(node);
|
||||
}
|
||||
|
||||
void increment(hashed_index_local_iterator_tag)
|
||||
{
|
||||
Node::template increment_local<IndexCategory>(node);
|
||||
}
|
||||
|
||||
Node* node;
|
||||
Node* node;
|
||||
BucketArray* buckets;
|
||||
};
|
||||
|
||||
template<
|
||||
typename Node,typename BucketArray,
|
||||
typename IndexCategory,typename IteratorCategory
|
||||
>
|
||||
bool operator==(
|
||||
const hashed_index_iterator<
|
||||
Node,BucketArray,IndexCategory,IteratorCategory>& x,
|
||||
const hashed_index_iterator<
|
||||
Node,BucketArray,IndexCategory,IteratorCategory>& y)
|
||||
{
|
||||
return x.get_node()==y.get_node();
|
||||
}
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
|
||||
/* class version = 1 : hashed_index_iterator does no longer serialize a bucket
|
||||
* array pointer.
|
||||
*/
|
||||
|
||||
namespace serialization {
|
||||
template<
|
||||
typename Node,typename BucketArray,
|
||||
typename IndexCategory,typename IteratorCategory
|
||||
>
|
||||
struct version<
|
||||
boost::multi_index::detail::hashed_index_iterator<
|
||||
Node,BucketArray,IndexCategory,IteratorCategory
|
||||
>
|
||||
>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int,value=1);
|
||||
};
|
||||
} /* namespace serialization */
|
||||
#endif
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,14 +9,12 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_NODE_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_NODE_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/multi_index/detail/allocator_traits.hpp>
|
||||
#include <boost/multi_index/detail/raw_ptr.hpp>
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
|
||||
namespace boost{
|
||||
|
||||
@@ -24,748 +22,90 @@ namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
/* Certain C++ requirements on unordered associative containers (see LWG issue
|
||||
* #579) imply a data structure where nodes are linked in a single list, which
|
||||
* in its turn forces implementors to add additional overhed per node to
|
||||
* associate each with its corresponding bucket. Others resort to storing hash
|
||||
* values, we use an alternative structure providing unconditional O(1)
|
||||
* manipulation, even in situations of unfair hash distribution, plus some
|
||||
* lookup speedups. For unique indices we maintain a doubly linked list of
|
||||
* nodes except that if N is the first node of a bucket its associated
|
||||
* bucket node is embedded between N and the preceding node in the following
|
||||
* manner:
|
||||
*
|
||||
* +---+ +---+ +---+ +---+
|
||||
* <--+ |<--+ | <--+ |<--+ |
|
||||
* ... | B0| | B1| ... | B1| | B2| ...
|
||||
* | |-+ | +--> | |-+ | +-->
|
||||
* +-+-+ | +---+ +-+-+ | +---+
|
||||
* | ^ | ^
|
||||
* | | | |
|
||||
* | +-+ | +-+
|
||||
* | | | |
|
||||
* v | v |
|
||||
* --+---+---+---+-- --+---+---+---+--
|
||||
* ... | | B1| | ... | | B2| | ...
|
||||
* --+---+---+---+-- --+---+---+---+--
|
||||
*
|
||||
*
|
||||
* The fist and last nodes of buckets can be checked with
|
||||
*
|
||||
* first node of a bucket: Npn != N
|
||||
* last node of a bucket: Nnp != N
|
||||
*
|
||||
* (n and p short for ->next(), ->prior(), bucket nodes have prior pointers
|
||||
* only). Pure insert and erase (without lookup) can be unconditionally done
|
||||
* in O(1).
|
||||
* For non-unique indices we add the following additional complexity: when
|
||||
* there is a group of 3 or more equivalent elements, they are linked as
|
||||
* follows:
|
||||
*
|
||||
* +-----------------------+
|
||||
* | v
|
||||
* +---+ | +---+ +---+ +---+
|
||||
* | | +-+ | | |<--+ |
|
||||
* | F | | S | ... | P | | L |
|
||||
* | +-->| | | +-+ | |
|
||||
* +---+ +---+ +---+ | +---+
|
||||
* ^ |
|
||||
* +-----------------------+
|
||||
*
|
||||
* F, S, P and L are the first, second, penultimate and last node in the
|
||||
* group, respectively (S and P can coincide if the group has size 3.) This
|
||||
* arrangement is used to skip equivalent elements in O(1) when doing lookup,
|
||||
* while preserving O(1) insert/erase. The following invariants identify
|
||||
* special positions (some of the operations have to be carefully implemented
|
||||
* as Xnn is not valid if Xn points to a bucket):
|
||||
*
|
||||
* first node of a bucket: Npnp == N
|
||||
* last node of a bucket: Nnpp == N
|
||||
* first node of a group: Nnp != N && Nnppn == N
|
||||
* second node of a group: Npn != N && Nppnn == N
|
||||
* n-1 node of a group: Nnp != N && Nnnpp == N
|
||||
* last node of a group: Npn != N && Npnnp == N
|
||||
*
|
||||
* The memory overhead is one pointer per bucket plus two pointers per node,
|
||||
* probably unbeatable. The resulting structure is bidirectonally traversable,
|
||||
* though currently we are just providing forward iteration.
|
||||
*/
|
||||
/* singly-linked node for use by hashed_index */
|
||||
|
||||
template<typename Allocator>
|
||||
struct hashed_index_node_impl;
|
||||
|
||||
/* half-header (only prior() pointer) to use for the bucket array */
|
||||
|
||||
template<typename Allocator>
|
||||
struct hashed_index_base_node_impl
|
||||
struct hashed_index_node_impl
|
||||
{
|
||||
typedef typename rebind_alloc_for<
|
||||
Allocator,hashed_index_base_node_impl
|
||||
>::type base_allocator;
|
||||
typedef typename rebind_alloc_for<
|
||||
Allocator,hashed_index_node_impl<Allocator>
|
||||
>::type node_allocator;
|
||||
typedef allocator_traits<base_allocator> base_alloc_traits;
|
||||
typedef allocator_traits<node_allocator> node_alloc_traits;
|
||||
typedef typename base_alloc_traits::pointer base_pointer;
|
||||
typedef typename base_alloc_traits::const_pointer const_base_pointer;
|
||||
typedef typename node_alloc_traits::pointer pointer;
|
||||
typedef typename node_alloc_traits::const_pointer const_pointer;
|
||||
typedef typename node_alloc_traits::difference_type difference_type;
|
||||
hashed_index_node_impl*& next(){return next_;}
|
||||
hashed_index_node_impl* next()const{return next_;}
|
||||
|
||||
pointer& prior(){return prior_;}
|
||||
pointer prior()const{return prior_;}
|
||||
/* algorithmic stuff */
|
||||
|
||||
private:
|
||||
pointer prior_;
|
||||
};
|
||||
|
||||
/* full header (prior() and next()) for the nodes */
|
||||
|
||||
template<typename Allocator>
|
||||
struct hashed_index_node_impl:hashed_index_base_node_impl<Allocator>
|
||||
{
|
||||
private:
|
||||
typedef hashed_index_base_node_impl<Allocator> super;
|
||||
|
||||
public:
|
||||
typedef typename super::base_pointer base_pointer;
|
||||
typedef typename super::const_base_pointer const_base_pointer;
|
||||
typedef typename super::pointer pointer;
|
||||
typedef typename super::const_pointer const_pointer;
|
||||
|
||||
base_pointer& next(){return next_;}
|
||||
base_pointer next()const{return next_;}
|
||||
|
||||
static pointer pointer_from(base_pointer x)
|
||||
static void increment(
|
||||
hashed_index_node_impl*& x,
|
||||
hashed_index_node_impl* bbegin,hashed_index_node_impl* bbend)
|
||||
{
|
||||
return static_cast<pointer>(
|
||||
static_cast<hashed_index_node_impl*>(
|
||||
raw_ptr<super*>(x)));
|
||||
}
|
||||
std::less_equal<hashed_index_node_impl*> leq;
|
||||
|
||||
static base_pointer base_pointer_from(pointer x)
|
||||
{
|
||||
return static_cast<base_pointer>(
|
||||
raw_ptr<hashed_index_node_impl*>(x));
|
||||
}
|
||||
|
||||
private:
|
||||
base_pointer next_;
|
||||
};
|
||||
|
||||
/* Boost.MultiIndex requires machinery to reverse unlink operations. A simple
|
||||
* way to make a pointer-manipulation function undoable is to templatize
|
||||
* its internal pointer assignments with a functor that, besides doing the
|
||||
* assignment, keeps track of the original pointer values and can later undo
|
||||
* the operations in reverse order.
|
||||
*/
|
||||
|
||||
struct default_assigner
|
||||
{
|
||||
template<typename T> void operator()(T& x,const T& val){x=val;}
|
||||
};
|
||||
|
||||
template<typename Node>
|
||||
struct unlink_undo_assigner
|
||||
{
|
||||
typedef typename Node::base_pointer base_pointer;
|
||||
typedef typename Node::pointer pointer;
|
||||
|
||||
unlink_undo_assigner():pointer_track_count(0),base_pointer_track_count(0){}
|
||||
|
||||
void operator()(pointer& x,pointer val)
|
||||
{
|
||||
pointer_tracks[pointer_track_count].x=&x;
|
||||
pointer_tracks[pointer_track_count++].val=x;
|
||||
x=val;
|
||||
}
|
||||
|
||||
void operator()(base_pointer& x,base_pointer val)
|
||||
{
|
||||
base_pointer_tracks[base_pointer_track_count].x=&x;
|
||||
base_pointer_tracks[base_pointer_track_count++].val=x;
|
||||
x=val;
|
||||
}
|
||||
|
||||
void operator()() /* undo op */
|
||||
{
|
||||
/* in the absence of aliasing, restitution order is immaterial */
|
||||
|
||||
while(pointer_track_count--){
|
||||
*(pointer_tracks[pointer_track_count].x)=
|
||||
pointer_tracks[pointer_track_count].val;
|
||||
}
|
||||
while(base_pointer_track_count--){
|
||||
*(base_pointer_tracks[base_pointer_track_count].x)=
|
||||
base_pointer_tracks[base_pointer_track_count].val;
|
||||
x=x->next();
|
||||
if(leq(bbegin,x)&&leq(x,bbend)){ /* bucket node */
|
||||
do{
|
||||
++x;
|
||||
}while(x->next()==x);
|
||||
x=x->next();
|
||||
}
|
||||
}
|
||||
|
||||
struct pointer_track {pointer* x; pointer val;};
|
||||
struct base_pointer_track{base_pointer* x; base_pointer val;};
|
||||
|
||||
/* We know the maximum number of pointer and base pointer assignments that
|
||||
* the two unlink versions do, so we can statically reserve the needed
|
||||
* storage.
|
||||
*/
|
||||
|
||||
pointer_track pointer_tracks[3];
|
||||
int pointer_track_count;
|
||||
base_pointer_track base_pointer_tracks[2];
|
||||
int base_pointer_track_count;
|
||||
};
|
||||
|
||||
/* algorithmic stuff for unique and non-unique variants */
|
||||
|
||||
struct hashed_unique_tag{};
|
||||
struct hashed_non_unique_tag{};
|
||||
|
||||
template<typename Node,typename Category>
|
||||
struct hashed_index_node_alg;
|
||||
|
||||
template<typename Node>
|
||||
struct hashed_index_node_alg<Node,hashed_unique_tag>
|
||||
{
|
||||
typedef typename Node::base_pointer base_pointer;
|
||||
typedef typename Node::const_base_pointer const_base_pointer;
|
||||
typedef typename Node::pointer pointer;
|
||||
typedef typename Node::const_pointer const_pointer;
|
||||
|
||||
static bool is_first_of_bucket(pointer x)
|
||||
static void link(
|
||||
hashed_index_node_impl* x,hashed_index_node_impl* pos)
|
||||
{
|
||||
return x->prior()->next()!=base_pointer_from(x);
|
||||
}
|
||||
|
||||
static pointer after(pointer x)
|
||||
{
|
||||
return is_last_of_bucket(x)?x->next()->prior():pointer_from(x->next());
|
||||
}
|
||||
|
||||
static pointer after_local(pointer x)
|
||||
{
|
||||
return is_last_of_bucket(x)?pointer(0):pointer_from(x->next());
|
||||
}
|
||||
|
||||
static pointer next_to_inspect(pointer x)
|
||||
{
|
||||
return is_last_of_bucket(x)?pointer(0):pointer_from(x->next());
|
||||
}
|
||||
|
||||
static void link(pointer x,base_pointer buc,pointer end)
|
||||
{
|
||||
if(buc->prior()==pointer(0)){ /* empty bucket */
|
||||
x->prior()=end->prior();
|
||||
x->next()=end->prior()->next();
|
||||
x->prior()->next()=buc;
|
||||
buc->prior()=x;
|
||||
end->prior()=x;
|
||||
}
|
||||
else{
|
||||
x->prior()=buc->prior()->prior();
|
||||
x->next()=base_pointer_from(buc->prior());
|
||||
buc->prior()=x;
|
||||
x->next()->prior()=x;
|
||||
}
|
||||
}
|
||||
|
||||
static void unlink(pointer x)
|
||||
{
|
||||
default_assigner assign;
|
||||
unlink(x,assign);
|
||||
}
|
||||
|
||||
typedef unlink_undo_assigner<Node> unlink_undo;
|
||||
|
||||
template<typename Assigner>
|
||||
static void unlink(pointer x,Assigner& assign)
|
||||
{
|
||||
if(is_first_of_bucket(x)){
|
||||
if(is_last_of_bucket(x)){
|
||||
assign(x->prior()->next()->prior(),pointer(0));
|
||||
assign(x->prior()->next(),x->next());
|
||||
assign(x->next()->prior()->prior(),x->prior());
|
||||
}
|
||||
else{
|
||||
assign(x->prior()->next()->prior(),pointer_from(x->next()));
|
||||
assign(x->next()->prior(),x->prior());
|
||||
}
|
||||
}
|
||||
else if(is_last_of_bucket(x)){
|
||||
assign(x->prior()->next(),x->next());
|
||||
assign(x->next()->prior()->prior(),x->prior());
|
||||
}
|
||||
else{
|
||||
assign(x->prior()->next(),x->next());
|
||||
assign(x->next()->prior(),x->prior());
|
||||
}
|
||||
}
|
||||
|
||||
/* used only at rehashing */
|
||||
|
||||
static void append(pointer x,pointer end)
|
||||
{
|
||||
x->prior()=end->prior();
|
||||
x->next()=end->prior()->next();
|
||||
x->prior()->next()=base_pointer_from(x);
|
||||
end->prior()=x;
|
||||
}
|
||||
|
||||
static bool unlink_last(pointer end)
|
||||
{
|
||||
/* returns true iff bucket is emptied */
|
||||
|
||||
pointer x=end->prior();
|
||||
if(x->prior()->next()==base_pointer_from(x)){
|
||||
x->prior()->next()=x->next();
|
||||
end->prior()=x->prior();
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
x->prior()->next()->prior()=pointer(0);
|
||||
x->prior()->next()=x->next();
|
||||
end->prior()=x->prior();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static pointer pointer_from(base_pointer x)
|
||||
{
|
||||
return Node::pointer_from(x);
|
||||
}
|
||||
|
||||
static base_pointer base_pointer_from(pointer x)
|
||||
{
|
||||
return Node::base_pointer_from(x);
|
||||
}
|
||||
|
||||
static bool is_last_of_bucket(pointer x)
|
||||
{
|
||||
return x->next()->prior()!=x;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Node>
|
||||
struct hashed_index_node_alg<Node,hashed_non_unique_tag>
|
||||
{
|
||||
typedef typename Node::base_pointer base_pointer;
|
||||
typedef typename Node::const_base_pointer const_base_pointer;
|
||||
typedef typename Node::pointer pointer;
|
||||
typedef typename Node::const_pointer const_pointer;
|
||||
|
||||
static bool is_first_of_bucket(pointer x)
|
||||
{
|
||||
return x->prior()->next()->prior()==x;
|
||||
}
|
||||
|
||||
static bool is_first_of_group(pointer x)
|
||||
{
|
||||
return
|
||||
x->next()->prior()!=x&&
|
||||
x->next()->prior()->prior()->next()==base_pointer_from(x);
|
||||
}
|
||||
|
||||
static pointer after(pointer x)
|
||||
{
|
||||
if(x->next()->prior()==x)return pointer_from(x->next());
|
||||
if(x->next()->prior()->prior()==x)return x->next()->prior();
|
||||
if(x->next()->prior()->prior()->next()==base_pointer_from(x))
|
||||
return pointer_from(x->next());
|
||||
return pointer_from(x->next())->next()->prior();
|
||||
}
|
||||
|
||||
static pointer after_local(pointer x)
|
||||
{
|
||||
if(x->next()->prior()==x)return pointer_from(x->next());
|
||||
if(x->next()->prior()->prior()==x)return pointer(0);
|
||||
if(x->next()->prior()->prior()->next()==base_pointer_from(x))
|
||||
return pointer_from(x->next());
|
||||
return pointer_from(x->next())->next()->prior();
|
||||
}
|
||||
|
||||
static pointer next_to_inspect(pointer x)
|
||||
{
|
||||
if(x->next()->prior()==x)return pointer_from(x->next());
|
||||
if(x->next()->prior()->prior()==x)return pointer(0);
|
||||
if(x->next()->prior()->next()->prior()!=x->next()->prior())
|
||||
return pointer(0);
|
||||
return pointer_from(x->next()->prior()->next());
|
||||
}
|
||||
|
||||
static void link(pointer x,base_pointer buc,pointer end)
|
||||
{
|
||||
if(buc->prior()==pointer(0)){ /* empty bucket */
|
||||
x->prior()=end->prior();
|
||||
x->next()=end->prior()->next();
|
||||
x->prior()->next()=buc;
|
||||
buc->prior()=x;
|
||||
end->prior()=x;
|
||||
}
|
||||
else{
|
||||
x->prior()=buc->prior()->prior();
|
||||
x->next()=base_pointer_from(buc->prior());
|
||||
buc->prior()=x;
|
||||
x->next()->prior()=x;
|
||||
}
|
||||
}
|
||||
|
||||
static void link(pointer x,pointer first,pointer last)
|
||||
{
|
||||
x->prior()=first->prior();
|
||||
x->next()=base_pointer_from(first);
|
||||
if(is_first_of_bucket(first)){
|
||||
x->prior()->next()->prior()=x;
|
||||
}
|
||||
else{
|
||||
x->prior()->next()=base_pointer_from(x);
|
||||
}
|
||||
|
||||
if(first==last){
|
||||
last->prior()=x;
|
||||
}
|
||||
else if(first->next()==base_pointer_from(last)){
|
||||
first->prior()=last;
|
||||
first->next()=base_pointer_from(x);
|
||||
}
|
||||
else{
|
||||
pointer second=pointer_from(first->next()),
|
||||
lastbutone=last->prior();
|
||||
second->prior()=first;
|
||||
first->prior()=last;
|
||||
lastbutone->next()=base_pointer_from(x);
|
||||
}
|
||||
}
|
||||
|
||||
static void unlink(pointer x)
|
||||
{
|
||||
default_assigner assign;
|
||||
unlink(x,assign);
|
||||
}
|
||||
|
||||
typedef unlink_undo_assigner<Node> unlink_undo;
|
||||
|
||||
template<typename Assigner>
|
||||
static void unlink(pointer x,Assigner& assign)
|
||||
{
|
||||
if(x->prior()->next()==base_pointer_from(x)){
|
||||
if(x->next()->prior()==x){
|
||||
left_unlink(x,assign);
|
||||
right_unlink(x,assign);
|
||||
}
|
||||
else if(x->next()->prior()->prior()==x){ /* last of bucket */
|
||||
left_unlink(x,assign);
|
||||
right_unlink_last_of_bucket(x,assign);
|
||||
}
|
||||
else if(x->next()->prior()->prior()->next()==
|
||||
base_pointer_from(x)){ /* first of group size */
|
||||
left_unlink(x,assign);
|
||||
right_unlink_first_of_group(x,assign);
|
||||
}
|
||||
else{ /* n-1 of group */
|
||||
unlink_last_but_one_of_group(x,assign);
|
||||
}
|
||||
}
|
||||
else if(x->prior()->next()->prior()==x){ /* first of bucket */
|
||||
if(x->next()->prior()==x){
|
||||
left_unlink_first_of_bucket(x,assign);
|
||||
right_unlink(x,assign);
|
||||
}
|
||||
else if(x->next()->prior()->prior()==x){ /* last of bucket */
|
||||
assign(x->prior()->next()->prior(),pointer(0));
|
||||
assign(x->prior()->next(),x->next());
|
||||
assign(x->next()->prior()->prior(),x->prior());
|
||||
}
|
||||
else{ /* first of group */
|
||||
left_unlink_first_of_bucket(x,assign);
|
||||
right_unlink_first_of_group(x,assign);
|
||||
}
|
||||
}
|
||||
else if(x->next()->prior()->prior()==x){ /* last of group and bucket */
|
||||
left_unlink_last_of_group(x,assign);
|
||||
right_unlink_last_of_bucket(x,assign);
|
||||
}
|
||||
else if(pointer_from(x->prior()->prior()->next())
|
||||
->next()==base_pointer_from(x)){ /* second of group */
|
||||
unlink_second_of_group(x,assign);
|
||||
}
|
||||
else{ /* last of group, ~(last of bucket) */
|
||||
left_unlink_last_of_group(x,assign);
|
||||
right_unlink(x,assign);
|
||||
}
|
||||
}
|
||||
|
||||
/* used only at rehashing */
|
||||
|
||||
static void link_range(
|
||||
pointer first,pointer last,base_pointer buc,pointer cend)
|
||||
{
|
||||
if(buc->prior()==pointer(0)){ /* empty bucket */
|
||||
first->prior()=cend->prior();
|
||||
last->next()=cend->prior()->next();
|
||||
first->prior()->next()=buc;
|
||||
buc->prior()=first;
|
||||
cend->prior()=last;
|
||||
}
|
||||
else{
|
||||
first->prior()=buc->prior()->prior();
|
||||
last->next()=base_pointer_from(buc->prior());
|
||||
buc->prior()=first;
|
||||
last->next()->prior()=last;
|
||||
}
|
||||
}
|
||||
|
||||
static void append_range(pointer first,pointer last,pointer cend)
|
||||
{
|
||||
first->prior()=cend->prior();
|
||||
last->next()=cend->prior()->next();
|
||||
first->prior()->next()=base_pointer_from(first);
|
||||
cend->prior()=last;
|
||||
}
|
||||
|
||||
static std::pair<pointer,bool> unlink_last_group(pointer end)
|
||||
{
|
||||
/* returns first of group true iff bucket is emptied */
|
||||
|
||||
pointer x=end->prior();
|
||||
if(x->prior()->next()==base_pointer_from(x)){
|
||||
x->prior()->next()=x->next();
|
||||
end->prior()=x->prior();
|
||||
return std::make_pair(x,false);
|
||||
}
|
||||
else if(x->prior()->next()->prior()==x){
|
||||
x->prior()->next()->prior()=pointer(0);
|
||||
x->prior()->next()=x->next();
|
||||
end->prior()=x->prior();
|
||||
return std::make_pair(x,true);
|
||||
}
|
||||
else{
|
||||
pointer y=pointer_from(x->prior()->next());
|
||||
|
||||
if(y->prior()->next()==base_pointer_from(y)){
|
||||
y->prior()->next()=x->next();
|
||||
end->prior()=y->prior();
|
||||
return std::make_pair(y,false);
|
||||
}
|
||||
else{
|
||||
y->prior()->next()->prior()=pointer(0);
|
||||
y->prior()->next()=x->next();
|
||||
end->prior()=y->prior();
|
||||
return std::make_pair(y,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void unlink_range(pointer first,pointer last)
|
||||
{
|
||||
if(is_first_of_bucket(first)){
|
||||
if(is_last_of_bucket(last)){
|
||||
first->prior()->next()->prior()=pointer(0);
|
||||
first->prior()->next()=last->next();
|
||||
last->next()->prior()->prior()=first->prior();
|
||||
}
|
||||
else{
|
||||
first->prior()->next()->prior()=pointer_from(last->next());
|
||||
last->next()->prior()=first->prior();
|
||||
}
|
||||
}
|
||||
else if(is_last_of_bucket(last)){
|
||||
first->prior()->next()=last->next();
|
||||
last->next()->prior()->prior()=first->prior();
|
||||
}
|
||||
else{
|
||||
first->prior()->next()=last->next();
|
||||
last->next()->prior()=first->prior();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static pointer pointer_from(base_pointer x)
|
||||
{
|
||||
return Node::pointer_from(x);
|
||||
}
|
||||
|
||||
static base_pointer base_pointer_from(pointer x)
|
||||
{
|
||||
return Node::base_pointer_from(x);
|
||||
}
|
||||
|
||||
static bool is_last_of_bucket(pointer x)
|
||||
{
|
||||
return x->next()->prior()->prior()==x;
|
||||
}
|
||||
|
||||
template<typename Assigner>
|
||||
static void left_unlink(pointer x,Assigner& assign)
|
||||
{
|
||||
assign(x->prior()->next(),x->next());
|
||||
}
|
||||
|
||||
template<typename Assigner>
|
||||
static void right_unlink(pointer x,Assigner& assign)
|
||||
{
|
||||
assign(x->next()->prior(),x->prior());
|
||||
}
|
||||
|
||||
template<typename Assigner>
|
||||
static void left_unlink_first_of_bucket(pointer x,Assigner& assign)
|
||||
{
|
||||
assign(x->prior()->next()->prior(),pointer_from(x->next()));
|
||||
}
|
||||
|
||||
template<typename Assigner>
|
||||
static void right_unlink_last_of_bucket(pointer x,Assigner& assign)
|
||||
{
|
||||
assign(x->next()->prior()->prior(),x->prior());
|
||||
}
|
||||
|
||||
template<typename Assigner>
|
||||
static void right_unlink_first_of_group(pointer x,Assigner& assign)
|
||||
{
|
||||
pointer second=pointer_from(x->next()),
|
||||
last=second->prior(),
|
||||
lastbutone=last->prior();
|
||||
if(second==lastbutone){
|
||||
assign(second->next(),base_pointer_from(last));
|
||||
assign(second->prior(),x->prior());
|
||||
}
|
||||
else{
|
||||
assign(lastbutone->next(),base_pointer_from(second));
|
||||
assign(second->next()->prior(),last);
|
||||
assign(second->prior(),x->prior());
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Assigner>
|
||||
static void left_unlink_last_of_group(pointer x,Assigner& assign)
|
||||
{
|
||||
pointer lastbutone=x->prior(),
|
||||
first=pointer_from(lastbutone->next()),
|
||||
second=pointer_from(first->next());
|
||||
if(lastbutone==second){
|
||||
assign(lastbutone->prior(),first);
|
||||
assign(lastbutone->next(),x->next());
|
||||
}
|
||||
else{
|
||||
assign(second->prior(),lastbutone);
|
||||
assign(lastbutone->prior()->next(),base_pointer_from(first));
|
||||
assign(lastbutone->next(),x->next());
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Assigner>
|
||||
static void unlink_last_but_one_of_group(pointer x,Assigner& assign)
|
||||
{
|
||||
pointer first=pointer_from(x->next()),
|
||||
second=pointer_from(first->next()),
|
||||
last=second->prior();
|
||||
if(second==x){
|
||||
assign(last->prior(),first);
|
||||
assign(first->next(),base_pointer_from(last));
|
||||
}
|
||||
else{
|
||||
assign(last->prior(),x->prior());
|
||||
assign(x->prior()->next(),base_pointer_from(first));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Assigner>
|
||||
static void unlink_second_of_group(pointer x,Assigner& assign)
|
||||
{
|
||||
pointer last=x->prior(),
|
||||
lastbutone=last->prior(),
|
||||
first=pointer_from(lastbutone->next());
|
||||
if(lastbutone==x){
|
||||
assign(first->next(),base_pointer_from(last));
|
||||
assign(last->prior(),first);
|
||||
}
|
||||
else{
|
||||
assign(first->next(),x->next());
|
||||
assign(x->next()->prior(),last);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Super>
|
||||
struct hashed_index_node_trampoline:
|
||||
hashed_index_node_impl<
|
||||
typename rebind_alloc_for<
|
||||
typename Super::allocator_type,char
|
||||
>::type
|
||||
>
|
||||
{
|
||||
typedef typename rebind_alloc_for<
|
||||
typename Super::allocator_type,char
|
||||
>::type impl_allocator_type;
|
||||
typedef hashed_index_node_impl<impl_allocator_type> impl_type;
|
||||
};
|
||||
|
||||
template<typename Super>
|
||||
struct hashed_index_node:
|
||||
Super,hashed_index_node_trampoline<Super>
|
||||
{
|
||||
private:
|
||||
typedef hashed_index_node_trampoline<Super> trampoline;
|
||||
|
||||
public:
|
||||
typedef typename trampoline::impl_type impl_type;
|
||||
typedef typename trampoline::base_pointer impl_base_pointer;
|
||||
typedef typename trampoline::const_base_pointer const_impl_base_pointer;
|
||||
typedef typename trampoline::pointer impl_pointer;
|
||||
typedef typename trampoline::const_pointer const_impl_pointer;
|
||||
typedef typename trampoline::difference_type difference_type;
|
||||
|
||||
template<typename Category>
|
||||
struct node_alg{
|
||||
typedef hashed_index_node_alg<impl_type,Category> type;
|
||||
x->next()=pos->next();
|
||||
pos->next()=x;
|
||||
};
|
||||
|
||||
impl_pointer& prior(){return trampoline::prior();}
|
||||
impl_pointer prior()const{return trampoline::prior();}
|
||||
impl_base_pointer& next(){return trampoline::next();}
|
||||
impl_base_pointer next()const{return trampoline::next();}
|
||||
|
||||
impl_pointer impl()
|
||||
static void unlink(hashed_index_node_impl* x)
|
||||
{
|
||||
return static_cast<impl_pointer>(
|
||||
static_cast<impl_type*>(static_cast<trampoline*>(this)));
|
||||
hashed_index_node_impl* y=x->next();
|
||||
while(y->next()!=x){y=y->next();}
|
||||
y->next()=x->next();
|
||||
}
|
||||
|
||||
const_impl_pointer impl()const
|
||||
static hashed_index_node_impl* prev(hashed_index_node_impl* x)
|
||||
{
|
||||
return static_cast<const_impl_pointer>(
|
||||
static_cast<const impl_type*>(static_cast<const trampoline*>(this)));
|
||||
hashed_index_node_impl* y=x->next();
|
||||
while(y->next()!=x){y=y->next();}
|
||||
return y;
|
||||
}
|
||||
|
||||
static hashed_index_node* from_impl(impl_pointer x)
|
||||
static void unlink_next(hashed_index_node_impl* x)
|
||||
{
|
||||
return
|
||||
static_cast<hashed_index_node*>(
|
||||
static_cast<trampoline*>(
|
||||
raw_ptr<impl_type*>(x)));
|
||||
x->next()=x->next()->next();
|
||||
}
|
||||
|
||||
static const hashed_index_node* from_impl(const_impl_pointer x)
|
||||
private:
|
||||
hashed_index_node_impl* next_;
|
||||
};
|
||||
|
||||
template<typename Super>
|
||||
struct hashed_index_node_trampoline:hashed_index_node_impl{};
|
||||
|
||||
template<typename Super>
|
||||
struct hashed_index_node:Super,hashed_index_node_trampoline<Super>
|
||||
{
|
||||
hashed_index_node_impl* impl()
|
||||
{return static_cast<impl_type*>(this);}
|
||||
const hashed_index_node_impl* impl()const
|
||||
{return static_cast<const impl_type*>(this);}
|
||||
|
||||
static hashed_index_node* from_impl(hashed_index_node_impl *x)
|
||||
{return static_cast<hashed_index_node*>(static_cast<impl_type*>(x));}
|
||||
static const hashed_index_node* from_impl(const hashed_index_node_impl* x)
|
||||
{
|
||||
return
|
||||
static_cast<const hashed_index_node*>(
|
||||
static_cast<const trampoline*>(
|
||||
raw_ptr<const impl_type*>(x)));
|
||||
return static_cast<const hashed_index_node*>(
|
||||
static_cast<const impl_type*>(x));
|
||||
}
|
||||
|
||||
/* interoperability with hashed_index_iterator */
|
||||
|
||||
template<typename Category>
|
||||
static void increment(hashed_index_node*& x)
|
||||
static void increment(
|
||||
hashed_index_node*& x,
|
||||
hashed_index_node_impl* bbegin,hashed_index_node_impl* bend)
|
||||
{
|
||||
x=from_impl(node_alg<Category>::type::after(x->impl()));
|
||||
hashed_index_node_impl* xi=x->impl();
|
||||
impl_type::increment(xi,bbegin,bend);
|
||||
x=from_impl(xi);
|
||||
}
|
||||
|
||||
template<typename Category>
|
||||
static void increment_local(hashed_index_node*& x)
|
||||
{
|
||||
x=from_impl(node_alg<Category>::type::after_local(x->impl()));
|
||||
}
|
||||
private:
|
||||
typedef hashed_index_node_trampoline<Super> impl_type;
|
||||
};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2008 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_HEADER_HOLDER_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_HEADER_HOLDER_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -29,13 +29,13 @@ namespace detail{
|
||||
* to the base from member trick.
|
||||
*/
|
||||
|
||||
template<typename NodeTypePtr,typename Final>
|
||||
template<typename NodeType,typename Final>
|
||||
struct header_holder:private noncopyable
|
||||
{
|
||||
header_holder():member(final().allocate_node()){}
|
||||
~header_holder(){final().deallocate_node(&*member);}
|
||||
~header_holder(){final().deallocate_node(member);}
|
||||
|
||||
NodeTypePtr member;
|
||||
NodeType* member;
|
||||
|
||||
private:
|
||||
Final& final(){return *static_cast<Final*>(this);}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
/* Copyright 2003-2016 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_GCC)&&(BOOST_GCC>=4*10000+6*100)
|
||||
#if !defined(BOOST_MULTI_INDEX_DETAIL_RESTORE_WSTRICT_ALIASING)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#else
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,22 +9,16 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_INDEX_BASE_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_INDEX_BASE_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/call_traits.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/multi_index/detail/allocator_traits.hpp>
|
||||
#include <boost/multi_index/detail/copy_map.hpp>
|
||||
#include <boost/multi_index/detail/do_not_copy_elements_tag.hpp>
|
||||
#include <boost/multi_index/detail/node_handle.hpp>
|
||||
#include <boost/multi_index/detail/node_type.hpp>
|
||||
#include <boost/multi_index/detail/vartempl_support.hpp>
|
||||
#include <boost/multi_index_container_fwd.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <utility>
|
||||
@@ -48,25 +42,20 @@ namespace detail{
|
||||
* cannot be called directly from the index classes.)
|
||||
*/
|
||||
|
||||
struct lvalue_tag{};
|
||||
struct rvalue_tag{};
|
||||
struct emplaced_tag{};
|
||||
|
||||
template<typename Value,typename IndexSpecifierList,typename Allocator>
|
||||
class index_base
|
||||
{
|
||||
protected:
|
||||
typedef index_node_base<Value,Allocator> index_node_type;
|
||||
typedef index_node_base<Value> node_type;
|
||||
typedef typename multi_index_node_type<
|
||||
Value,IndexSpecifierList,Allocator>::type final_node_type;
|
||||
typedef multi_index_container<
|
||||
Value,IndexSpecifierList,Allocator> final_type;
|
||||
typedef tuples::null_type ctor_args_list;
|
||||
typedef typename rebind_alloc_for<
|
||||
Allocator,typename Allocator::value_type
|
||||
>::type final_allocator_type;
|
||||
typedef node_handle<
|
||||
final_node_type,final_allocator_type> final_node_handle_type;
|
||||
typedef typename
|
||||
boost::detail::allocator::rebind_to<
|
||||
Allocator,
|
||||
typename Allocator::value_type>::type final_allocator_type;
|
||||
typedef mpl::vector0<> index_type_list;
|
||||
typedef mpl::vector0<> iterator_type_list;
|
||||
typedef mpl::vector0<> const_iterator_type_list;
|
||||
@@ -76,111 +65,57 @@ protected:
|
||||
|
||||
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
|
||||
typedef index_saver<
|
||||
index_node_type,
|
||||
node_type,
|
||||
final_allocator_type> index_saver_type;
|
||||
typedef index_loader<
|
||||
index_node_type,
|
||||
node_type,
|
||||
final_node_type,
|
||||
final_allocator_type> index_loader_type;
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef Value value_type;
|
||||
typedef allocator_traits<Allocator> alloc_traits;
|
||||
typedef typename alloc_traits::size_type size_type;
|
||||
typedef typename call_traits<Value>::param_type value_param_type;
|
||||
|
||||
protected:
|
||||
explicit index_base(const ctor_args_list&,const Allocator&){}
|
||||
|
||||
index_base(
|
||||
const index_base<Value,IndexSpecifierList,Allocator>&,
|
||||
do_not_copy_elements_tag)
|
||||
{}
|
||||
|
||||
void copy_(
|
||||
const index_base<Value,IndexSpecifierList,Allocator>&,const copy_map_type&)
|
||||
{}
|
||||
|
||||
final_node_type* insert_(const value_type& v,final_node_type*& x,lvalue_tag)
|
||||
node_type* insert_(value_param_type v,node_type* x)
|
||||
{
|
||||
x=final().allocate_node();
|
||||
BOOST_TRY{
|
||||
final().construct_value(x,v);
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
final().deallocate_node(x);
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
boost::detail::allocator::construct(&x->value(),v);
|
||||
return x;
|
||||
}
|
||||
|
||||
final_node_type* insert_(const value_type& v,final_node_type*& x,rvalue_tag)
|
||||
node_type* insert_(value_param_type v,node_type*,node_type* x)
|
||||
{
|
||||
x=final().allocate_node();
|
||||
BOOST_TRY{
|
||||
final().construct_value(x,boost::move(const_cast<value_type&>(v)));
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
final().deallocate_node(x);
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
boost::detail::allocator::construct(&x->value(),v);
|
||||
return x;
|
||||
}
|
||||
|
||||
final_node_type* insert_(const value_type&,final_node_type*& x,emplaced_tag)
|
||||
void erase_(node_type* x)
|
||||
{
|
||||
return x;
|
||||
boost::detail::allocator::destroy(&x->value());
|
||||
}
|
||||
|
||||
final_node_type* insert_(
|
||||
const value_type& v,index_node_type*,final_node_type*& x,lvalue_tag)
|
||||
void delete_node_(node_type* x)
|
||||
{
|
||||
return insert_(v,x,lvalue_tag());
|
||||
boost::detail::allocator::destroy(&x->value());
|
||||
}
|
||||
|
||||
final_node_type* insert_(
|
||||
const value_type& v,index_node_type*,final_node_type*& x,rvalue_tag)
|
||||
{
|
||||
return insert_(v,x,rvalue_tag());
|
||||
}
|
||||
|
||||
final_node_type* insert_(
|
||||
const value_type&,index_node_type*,final_node_type*& x,emplaced_tag)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
void extract_(index_node_type*){}
|
||||
|
||||
void clear_(){}
|
||||
|
||||
template<typename BoolConstant>
|
||||
void swap_(
|
||||
index_base<Value,IndexSpecifierList,Allocator>&,
|
||||
BoolConstant /* swap_allocators */)
|
||||
{}
|
||||
void swap_(index_base<Value,IndexSpecifierList,Allocator>&){}
|
||||
|
||||
void swap_elements_(index_base<Value,IndexSpecifierList,Allocator>&){}
|
||||
|
||||
bool replace_(const value_type& v,index_node_type* x,lvalue_tag)
|
||||
bool replace_(value_param_type v,node_type* x)
|
||||
{
|
||||
x->value()=v;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool replace_(const value_type& v,index_node_type* x,rvalue_tag)
|
||||
{
|
||||
x->value()=boost::move(const_cast<value_type&>(v));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool modify_(index_node_type*){return true;}
|
||||
|
||||
bool modify_rollback_(index_node_type*){return true;}
|
||||
|
||||
bool check_rollback_(index_node_type*)const{return true;}
|
||||
bool modify_(node_type*){return true;}
|
||||
|
||||
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
|
||||
/* serialization */
|
||||
@@ -205,60 +140,15 @@ protected:
|
||||
|
||||
final_node_type* final_header()const{return final().header();}
|
||||
|
||||
bool final_empty_()const{return final().empty_();}
|
||||
size_type final_size_()const{return final().size_();}
|
||||
size_type final_max_size_()const{return final().max_size_();}
|
||||
bool final_empty_()const{return final().empty_();}
|
||||
std::size_t final_size_()const{return final().size_();}
|
||||
std::size_t final_max_size_()const{return final().max_size_();}
|
||||
|
||||
std::pair<final_node_type*,bool> final_insert_(const value_type& x)
|
||||
std::pair<final_node_type*,bool> final_insert_(value_param_type x)
|
||||
{return final().insert_(x);}
|
||||
std::pair<final_node_type*,bool> final_insert_rv_(const value_type& x)
|
||||
{return final().insert_rv_(x);}
|
||||
template<typename T>
|
||||
std::pair<final_node_type*,bool> final_insert_ref_(const T& t)
|
||||
{return final().insert_ref_(t);}
|
||||
template<typename T>
|
||||
std::pair<final_node_type*,bool> final_insert_ref_(T& t)
|
||||
{return final().insert_ref_(t);}
|
||||
std::pair<final_node_type*,bool> final_insert_nh_(final_node_handle_type& nh)
|
||||
{return final().insert_nh_(nh);}
|
||||
|
||||
template<BOOST_MULTI_INDEX_TEMPLATE_PARAM_PACK>
|
||||
std::pair<final_node_type*,bool> final_emplace_(
|
||||
BOOST_MULTI_INDEX_FUNCTION_PARAM_PACK)
|
||||
{
|
||||
return final().emplace_(BOOST_MULTI_INDEX_FORWARD_PARAM_PACK);
|
||||
}
|
||||
|
||||
std::pair<final_node_type*,bool> final_insert_(
|
||||
const value_type& x,final_node_type* position)
|
||||
value_param_type x,final_node_type* position)
|
||||
{return final().insert_(x,position);}
|
||||
std::pair<final_node_type*,bool> final_insert_rv_(
|
||||
const value_type& x,final_node_type* position)
|
||||
{return final().insert_rv_(x,position);}
|
||||
template<typename T>
|
||||
std::pair<final_node_type*,bool> final_insert_ref_(
|
||||
const T& t,final_node_type* position)
|
||||
{return final().insert_ref_(t,position);}
|
||||
template<typename T>
|
||||
std::pair<final_node_type*,bool> final_insert_ref_(
|
||||
T& t,final_node_type* position)
|
||||
{return final().insert_ref_(t,position);}
|
||||
std::pair<final_node_type*,bool> final_insert_nh_(
|
||||
final_node_handle_type& nh,final_node_type* position)
|
||||
{return final().insert_nh_(nh,position);}
|
||||
|
||||
template<BOOST_MULTI_INDEX_TEMPLATE_PARAM_PACK>
|
||||
std::pair<final_node_type*,bool> final_emplace_hint_(
|
||||
final_node_type* position,BOOST_MULTI_INDEX_FUNCTION_PARAM_PACK)
|
||||
{
|
||||
return final().emplace_hint_(
|
||||
position,BOOST_MULTI_INDEX_FORWARD_PARAM_PACK);
|
||||
}
|
||||
|
||||
final_node_handle_type final_extract_(final_node_type* x)
|
||||
{
|
||||
return final().extract_(x);
|
||||
}
|
||||
|
||||
void final_erase_(final_node_type* x){final().erase_(x);}
|
||||
|
||||
@@ -267,22 +157,14 @@ protected:
|
||||
void final_clear_(){final().clear_();}
|
||||
|
||||
void final_swap_(final_type& x){final().swap_(x);}
|
||||
|
||||
bool final_replace_(
|
||||
const value_type& k,final_node_type* x)
|
||||
value_param_type k,final_node_type* x)
|
||||
{return final().replace_(k,x);}
|
||||
bool final_replace_rv_(
|
||||
const value_type& k,final_node_type* x)
|
||||
{return final().replace_rv_(k,x);}
|
||||
|
||||
template<typename Modifier>
|
||||
bool final_modify_(Modifier& mod,final_node_type* x)
|
||||
bool final_modify_(Modifier mod,final_node_type* x)
|
||||
{return final().modify_(mod,x);}
|
||||
|
||||
template<typename Modifier,typename Rollback>
|
||||
bool final_modify_(Modifier& mod,Rollback& back,final_node_type* x)
|
||||
{return final().modify_(mod,back,x);}
|
||||
|
||||
#if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)
|
||||
void final_check_invariant_()const{final().check_invariant_();}
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2015 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_INDEX_LOADER_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_INDEX_LOADER_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/multi_index/detail/auto_space.hpp>
|
||||
#include <boost/multi_index/detail/raw_ptr.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <cstddef>
|
||||
@@ -92,7 +91,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
Node** entries()const{return raw_ptr<Node**>(spc.data());}
|
||||
Node** entries()const{return spc.data();}
|
||||
|
||||
/* We try to delay sorting as much as possible just in case it
|
||||
* is not necessary, hence this version of load_node.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2015 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_INDEX_MATCHER_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_INDEX_MATCHER_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <algorithm>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/multi_index/detail/auto_space.hpp>
|
||||
#include <boost/multi_index/detail/raw_ptr.hpp>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
|
||||
@@ -107,14 +106,14 @@ class algorithm_base:private noncopyable
|
||||
{
|
||||
protected:
|
||||
algorithm_base(const Allocator& al,std::size_t size):
|
||||
spc(al,size),size_(size),n_(0),sorted(false)
|
||||
spc(al,size),size_(size),n(0),sorted(false)
|
||||
{
|
||||
}
|
||||
|
||||
void add(void* node)
|
||||
{
|
||||
entries()[n_]=entry(node,n_);
|
||||
++n_;
|
||||
entries()[n]=entry(node,n);
|
||||
++n;
|
||||
}
|
||||
|
||||
void begin_algorithm()const
|
||||
@@ -180,11 +179,11 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
entry* entries()const{return raw_ptr<entry*>(spc.data());}
|
||||
entry* entries()const{return spc.data();}
|
||||
|
||||
auto_space<entry,Allocator> spc;
|
||||
std::size_t size_;
|
||||
std::size_t n_;
|
||||
std::size_t n;
|
||||
mutable bool sorted;
|
||||
mutable std::size_t num_piles;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2016 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_INDEX_NODE_BASE_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_INDEX_NODE_BASE_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -42,27 +42,24 @@ struct pod_value_holder
|
||||
>::type space;
|
||||
};
|
||||
|
||||
template<typename Value,typename Allocator>
|
||||
template<typename Value>
|
||||
struct index_node_base:private pod_value_holder<Value>
|
||||
{
|
||||
typedef index_node_base base_type; /* used for serialization purposes */
|
||||
typedef Value value_type;
|
||||
typedef Allocator allocator_type;
|
||||
|
||||
#include <boost/multi_index/detail/ignore_wstrict_aliasing.hpp>
|
||||
|
||||
value_type& value()
|
||||
{
|
||||
return *reinterpret_cast<value_type*>(&this->space);
|
||||
return *static_cast<value_type*>(
|
||||
static_cast<void*>(&this->space));
|
||||
}
|
||||
|
||||
const value_type& value()const
|
||||
{
|
||||
return *reinterpret_cast<const value_type*>(&this->space);
|
||||
return *static_cast<const value_type*>(
|
||||
static_cast<const void*>(&this->space));
|
||||
}
|
||||
|
||||
#include <boost/multi_index/detail/restore_wstrict_aliasing.hpp>
|
||||
|
||||
static index_node_base* from_value(const value_type* p)
|
||||
{
|
||||
return static_cast<index_node_base *>(
|
||||
@@ -87,11 +84,11 @@ private:
|
||||
};
|
||||
|
||||
template<typename Node,typename Value>
|
||||
Node* node_from_value(const Value* p)
|
||||
Node* node_from_value(
|
||||
const Value* p
|
||||
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Node))
|
||||
{
|
||||
typedef typename Node::allocator_type allocator_type;
|
||||
return static_cast<Node*>(
|
||||
index_node_base<Value,allocator_type>::from_value(p));
|
||||
return static_cast<Node*>(index_node_base<Value>::from_value(p));
|
||||
}
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
@@ -112,9 +109,9 @@ namespace multi_index{
|
||||
namespace detail{
|
||||
#endif
|
||||
|
||||
template<class Archive,typename Value,typename Allocator>
|
||||
template<class Archive,typename Value>
|
||||
inline void load_construct_data(
|
||||
Archive&,boost::multi_index::detail::index_node_base<Value,Allocator>*,
|
||||
Archive&,boost::multi_index::detail::index_node_base<Value>*,
|
||||
const unsigned int)
|
||||
{
|
||||
throw_exception(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2013 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_INDEX_SAVER_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_INDEX_SAVER_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2013 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_INVARIANT_ASSERT_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_INVARIANT_ASSERT_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/* Copyright 2003-2019 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_IS_FUNCTION_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_IS_FUNCTION_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)||\
|
||||
BOOST_WORKAROUND(_LIBCPP_VERSION,<30700)||\
|
||||
BOOST_WORKAROUND(BOOST_LIBSTDCXX_VERSION,<40802)
|
||||
/* libc++: std::is_function<void() const> fails,
|
||||
* https://bugs.llvm.org/show_bug.cgi?id=20084
|
||||
*
|
||||
* libstdc++-v3: std::is_function does not support ref-qualified function types,
|
||||
* https://github.com/gcc-mirror/gcc/commit/
|
||||
* 2fa630fb50ba29d8e891c52a75aaec261b07874e#
|
||||
* diff-6547f965a8d66bf35a6388fcf404aaa3
|
||||
*/
|
||||
|
||||
#include <boost/type_traits/is_function.hpp>
|
||||
|
||||
namespace boost{namespace multi_index{namespace detail{
|
||||
|
||||
template<typename T>
|
||||
struct is_function:boost::is_function<T>{};
|
||||
|
||||
}}} /* namespace boost::multi_index::detail */
|
||||
|
||||
#else
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost{namespace multi_index{namespace detail{
|
||||
|
||||
template<typename T>
|
||||
struct is_function:std::is_function<T>{};
|
||||
|
||||
}}} /* namespace boost::multi_index::detail */
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2013 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_IS_INDEX_LIST_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_IS_INDEX_LIST_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
/* Copyright 2003-2014 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_IS_TRANSPARENT_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_IS_TRANSPARENT_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/type_traits/intrinsics.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
/* Metafunction that checks if f(arg,arg2) executes without argument type
|
||||
* conversion. By default (i.e. when it cannot be determined) it evaluates to
|
||||
* true.
|
||||
*/
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2,typename=void>
|
||||
struct is_transparent:mpl::true_{};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#if !defined(BOOST_NO_SFINAE)&&!defined(BOOST_NO_SFINAE_EXPR)&& \
|
||||
!defined(BOOST_NO_CXX11_DECLTYPE)&& \
|
||||
(defined(BOOST_NO_CXX11_FINAL)||defined(BOOST_IS_FINAL))
|
||||
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/type_traits/function_traits.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/is_final.hpp>
|
||||
#include <boost/type_traits/is_function.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/remove_pointer.hpp>
|
||||
#include <boost/utility/declval.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
struct not_is_transparent_result_type{};
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2>
|
||||
struct is_transparent_class_helper:F
|
||||
{
|
||||
using F::operator();
|
||||
template<typename T,typename Q>
|
||||
not_is_transparent_result_type operator()(const T&,const Q&)const;
|
||||
};
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2,typename=void>
|
||||
struct is_transparent_class:mpl::true_{};
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2>
|
||||
struct is_transparent_class<
|
||||
F,Arg1,Arg2,
|
||||
typename enable_if<
|
||||
is_same<
|
||||
decltype(
|
||||
declval<const is_transparent_class_helper<F,Arg1,Arg2> >()(
|
||||
declval<const Arg1&>(),declval<const Arg2&>())
|
||||
),
|
||||
not_is_transparent_result_type
|
||||
>
|
||||
>::type
|
||||
>:mpl::false_{};
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2>
|
||||
struct is_transparent<
|
||||
F,Arg1,Arg2,
|
||||
typename enable_if<
|
||||
mpl::and_<
|
||||
is_class<F>,
|
||||
mpl::not_<is_final<F> > /* is_transparent_class_helper derives from F */
|
||||
>
|
||||
>::type
|
||||
>:is_transparent_class<F,Arg1,Arg2>{};
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2,typename=void>
|
||||
struct is_transparent_function:mpl::true_{};
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2>
|
||||
struct is_transparent_function<
|
||||
F,Arg1,Arg2,
|
||||
typename enable_if<
|
||||
mpl::or_<
|
||||
mpl::not_<mpl::or_<
|
||||
is_same<typename function_traits<F>::arg1_type,const Arg1&>,
|
||||
is_same<typename function_traits<F>::arg1_type,Arg1>
|
||||
> >,
|
||||
mpl::not_<mpl::or_<
|
||||
is_same<typename function_traits<F>::arg2_type,const Arg2&>,
|
||||
is_same<typename function_traits<F>::arg2_type,Arg2>
|
||||
> >
|
||||
>
|
||||
>::type
|
||||
>:mpl::false_{};
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2>
|
||||
struct is_transparent<
|
||||
F,Arg1,Arg2,
|
||||
typename enable_if<
|
||||
is_function<typename remove_pointer<F>::type>
|
||||
>::type
|
||||
>:is_transparent_function<typename remove_pointer<F>::type,Arg1,Arg2>{};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2013 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muńoz.
|
||||
* 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)
|
||||
@@ -9,12 +9,13 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_ITER_ADAPTOR_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_ITER_ADAPTOR_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/multi_index/detail/prevent_eti.hpp>
|
||||
#include <boost/operators.hpp>
|
||||
|
||||
namespace boost{
|
||||
@@ -29,12 +30,6 @@ namespace detail{
|
||||
* for internal consumption.
|
||||
*/
|
||||
|
||||
/* NB. The purpose of the (non-inclass) global operators ==, < and - defined
|
||||
* above is to partially alleviate a problem of MSVC++ 6.0 by * which
|
||||
* friend-injected operators on T are not visible if T is instantiated only
|
||||
* in template code where T is a dependent type.
|
||||
*/
|
||||
|
||||
class iter_adaptor_access
|
||||
{
|
||||
public:
|
||||
@@ -112,15 +107,6 @@ private:
|
||||
const Derived& final()const{return *static_cast<const Derived*>(this);}
|
||||
};
|
||||
|
||||
template<class Derived,class Base>
|
||||
bool operator==(
|
||||
const forward_iter_adaptor_base<Derived,Base>& x,
|
||||
const forward_iter_adaptor_base<Derived,Base>& y)
|
||||
{
|
||||
return iter_adaptor_access::equal(
|
||||
static_cast<const Derived&>(x),static_cast<const Derived&>(y));
|
||||
}
|
||||
|
||||
template<>
|
||||
struct iter_adaptor_selector<std::forward_iterator_tag>
|
||||
{
|
||||
@@ -170,15 +156,6 @@ private:
|
||||
const Derived& final()const{return *static_cast<const Derived*>(this);}
|
||||
};
|
||||
|
||||
template<class Derived,class Base>
|
||||
bool operator==(
|
||||
const bidirectional_iter_adaptor_base<Derived,Base>& x,
|
||||
const bidirectional_iter_adaptor_base<Derived,Base>& y)
|
||||
{
|
||||
return iter_adaptor_access::equal(
|
||||
static_cast<const Derived&>(x),static_cast<const Derived&>(y));
|
||||
}
|
||||
|
||||
template<>
|
||||
struct iter_adaptor_selector<std::bidirectional_iterator_tag>
|
||||
{
|
||||
@@ -251,34 +228,6 @@ private:
|
||||
const Derived& final()const{return *static_cast<const Derived*>(this);}
|
||||
};
|
||||
|
||||
template<class Derived,class Base>
|
||||
bool operator==(
|
||||
const random_access_iter_adaptor_base<Derived,Base>& x,
|
||||
const random_access_iter_adaptor_base<Derived,Base>& y)
|
||||
{
|
||||
return iter_adaptor_access::equal(
|
||||
static_cast<const Derived&>(x),static_cast<const Derived&>(y));
|
||||
}
|
||||
|
||||
template<class Derived,class Base>
|
||||
bool operator<(
|
||||
const random_access_iter_adaptor_base<Derived,Base>& x,
|
||||
const random_access_iter_adaptor_base<Derived,Base>& y)
|
||||
{
|
||||
return iter_adaptor_access::distance_to(
|
||||
static_cast<const Derived&>(x),static_cast<const Derived&>(y))>0;
|
||||
}
|
||||
|
||||
template<class Derived,class Base>
|
||||
typename random_access_iter_adaptor_base<Derived,Base>::difference_type
|
||||
operator-(
|
||||
const random_access_iter_adaptor_base<Derived,Base>& x,
|
||||
const random_access_iter_adaptor_base<Derived,Base>& y)
|
||||
{
|
||||
return iter_adaptor_access::distance_to(
|
||||
static_cast<const Derived&>(y),static_cast<const Derived&>(x));
|
||||
}
|
||||
|
||||
template<>
|
||||
struct iter_adaptor_selector<std::random_access_iterator_tag>
|
||||
{
|
||||
@@ -293,9 +242,12 @@ template<class Derived,class Base>
|
||||
struct iter_adaptor_base
|
||||
{
|
||||
typedef iter_adaptor_selector<
|
||||
typename Base::iterator_category> selector;
|
||||
typedef typename mpl::apply2<
|
||||
selector,Derived,Base>::type type;
|
||||
typename Base::iterator_category> selector;
|
||||
typedef typename prevent_eti<
|
||||
selector,
|
||||
typename mpl::apply2<
|
||||
selector,Derived,Base>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<class Derived,class Base>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2013 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_MODIFY_KEY_ADAPTOR_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_MODIFY_KEY_ADAPTOR_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -24,19 +24,19 @@ namespace detail{
|
||||
* with references to references, dealing with function pointers, etc.
|
||||
*/
|
||||
|
||||
template<typename Fun,typename Value,typename KeyFromValue>
|
||||
template<typename Modifier,typename Value,typename KeyFromValue>
|
||||
struct modify_key_adaptor
|
||||
{
|
||||
|
||||
modify_key_adaptor(Fun f_,KeyFromValue kfv_):f(f_),kfv(kfv_){}
|
||||
modify_key_adaptor(Modifier mod_,KeyFromValue kfv_):mod(mod_),kfv(kfv_){}
|
||||
|
||||
void operator()(Value& x)
|
||||
{
|
||||
f(kfv(x));
|
||||
mod(kfv(x));
|
||||
}
|
||||
|
||||
private:
|
||||
Fun f;
|
||||
Modifier mod;
|
||||
KeyFromValue kfv;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_MSVC_INDEX_SPECIFIER_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_MSVC_INDEX_SPECIFIER_HPP
|
||||
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC,<1310)
|
||||
/* Workaround for a problem in MSVC with dependent template typedefs
|
||||
* when accesing index specifiers.
|
||||
* Modeled after <boost/mpl/aux_/msvc_dtw.hpp> (thanks, Aleksey!)
|
||||
*/
|
||||
|
||||
#include <boost/mpl/aux_/msvc_never_true.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
template<typename IndexSpecifier>
|
||||
struct msvc_index_specifier
|
||||
{
|
||||
template<bool> struct fake_index_type:IndexSpecifier{};
|
||||
template<> struct fake_index_type<true>
|
||||
{
|
||||
template<typename Super>
|
||||
struct node_class{};
|
||||
|
||||
template<typename Super>
|
||||
struct index_class{};
|
||||
};
|
||||
|
||||
template<typename Super>
|
||||
struct result_node_class:
|
||||
fake_index_type<mpl::aux::msvc_never_true<IndexSpecifier>::value>::
|
||||
template node_class<Super>
|
||||
{
|
||||
};
|
||||
|
||||
template<typename Super>
|
||||
struct result_index_class:
|
||||
fake_index_type<mpl::aux::msvc_never_true<IndexSpecifier>::value>::
|
||||
template index_class<Super>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif /* workaround */
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2013 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_NO_DUPLICATE_TAGS_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_NO_DUPLICATE_TAGS_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,244 +0,0 @@
|
||||
/* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_NODE_HANDLE_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_NODE_HANDLE_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <algorithm>
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/move/core.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/multi_index_container_fwd.hpp>
|
||||
#include <boost/multi_index/detail/allocator_traits.hpp>
|
||||
#include <boost/type_traits/aligned_storage.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
#include <new>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
/* Node handle template class following [container.node] specs.
|
||||
*/
|
||||
|
||||
#include <boost/multi_index/detail/define_if_constexpr_macro.hpp>
|
||||
|
||||
template<typename Node,typename Allocator>
|
||||
class node_handle
|
||||
{
|
||||
public:
|
||||
typedef typename Node::value_type value_type;
|
||||
typedef Allocator allocator_type;
|
||||
|
||||
private:
|
||||
typedef allocator_traits<allocator_type> alloc_traits;
|
||||
|
||||
public:
|
||||
node_handle()BOOST_NOEXCEPT:node(0){}
|
||||
|
||||
node_handle(BOOST_RV_REF(node_handle) x)BOOST_NOEXCEPT:node(x.node)
|
||||
{
|
||||
if(!x.empty()){
|
||||
move_construct_allocator(boost::move(x));
|
||||
x.destroy_allocator();
|
||||
x.node=0;
|
||||
}
|
||||
}
|
||||
|
||||
~node_handle()
|
||||
{
|
||||
if(!empty()){
|
||||
delete_node();
|
||||
destroy_allocator();
|
||||
}
|
||||
}
|
||||
|
||||
node_handle& operator=(BOOST_RV_REF(node_handle) x)
|
||||
{
|
||||
if(this!=&x){
|
||||
if(!empty()){
|
||||
delete_node();
|
||||
if(!x.empty()){
|
||||
BOOST_MULTI_INDEX_IF_CONSTEXPR(
|
||||
alloc_traits::propagate_on_container_move_assignment::value){
|
||||
move_assign_allocator(boost::move(x));
|
||||
}
|
||||
x.destroy_allocator();
|
||||
}
|
||||
else{
|
||||
destroy_allocator();
|
||||
}
|
||||
}
|
||||
else if(!x.empty()){
|
||||
move_construct_allocator(boost::move(x));
|
||||
x.destroy_allocator();
|
||||
}
|
||||
node=x.node;
|
||||
x.node=0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
value_type& value()const{return node->value();}
|
||||
allocator_type get_allocator()const{return *allocator_ptr();}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||
explicit
|
||||
#endif
|
||||
operator bool()const BOOST_NOEXCEPT{return (node!=0);}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_GCC_VERSION,>=70000)&&__cplusplus<201103L
|
||||
/* https://github.com/boostorg/config/issues/336 */
|
||||
#else
|
||||
BOOST_ATTRIBUTE_NODISCARD
|
||||
#endif
|
||||
bool empty()const BOOST_NOEXCEPT{return (node==0);}
|
||||
|
||||
void swap(node_handle& x)
|
||||
BOOST_NOEXCEPT_IF(
|
||||
alloc_traits::propagate_on_container_swap::value||
|
||||
alloc_traits::is_always_equal::value)
|
||||
{
|
||||
if(!empty()){
|
||||
if(!x.empty()){
|
||||
BOOST_MULTI_INDEX_IF_CONSTEXPR(
|
||||
alloc_traits::propagate_on_container_swap::value){
|
||||
using std::swap;
|
||||
swap(*allocator_ptr(),*x.allocator_ptr());
|
||||
}
|
||||
}
|
||||
else{
|
||||
x.move_construct_allocator(boost::move(*this));
|
||||
destroy_allocator();
|
||||
}
|
||||
}
|
||||
else if(!x.empty()){
|
||||
move_construct_allocator(boost::move(x));
|
||||
x.destroy_allocator();
|
||||
}
|
||||
std::swap(node,x.node);
|
||||
}
|
||||
|
||||
friend void swap(node_handle& x,node_handle& y)
|
||||
BOOST_NOEXCEPT_IF(noexcept(x.swap(y)))
|
||||
{
|
||||
x.swap(y);
|
||||
}
|
||||
|
||||
private:
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(node_handle)
|
||||
|
||||
template <typename,typename,typename>
|
||||
friend class boost::multi_index::multi_index_container;
|
||||
|
||||
node_handle(Node* node_,const allocator_type& al):node(node_)
|
||||
{
|
||||
::new (static_cast<void*>(allocator_ptr())) allocator_type(al);
|
||||
}
|
||||
|
||||
void release_node()
|
||||
{
|
||||
if(!empty()){
|
||||
node=0;
|
||||
destroy_allocator();
|
||||
}
|
||||
}
|
||||
|
||||
#include <boost/multi_index/detail/ignore_wstrict_aliasing.hpp>
|
||||
|
||||
const allocator_type* allocator_ptr()const
|
||||
{
|
||||
return reinterpret_cast<const allocator_type*>(&space);
|
||||
}
|
||||
|
||||
allocator_type* allocator_ptr()
|
||||
{
|
||||
return reinterpret_cast<allocator_type*>(&space);
|
||||
}
|
||||
|
||||
#include <boost/multi_index/detail/restore_wstrict_aliasing.hpp>
|
||||
|
||||
void move_construct_allocator(BOOST_RV_REF(node_handle) x)
|
||||
{
|
||||
::new (static_cast<void*>(allocator_ptr()))
|
||||
allocator_type(boost::move(*x.allocator_ptr()));
|
||||
}
|
||||
|
||||
void move_assign_allocator(BOOST_RV_REF(node_handle) x)
|
||||
{
|
||||
*allocator_ptr()=boost::move(*x.allocator_ptr());
|
||||
}
|
||||
|
||||
void destroy_allocator(){allocator_ptr()->~allocator_type();}
|
||||
|
||||
void delete_node()
|
||||
{
|
||||
typedef typename rebind_alloc_for<
|
||||
allocator_type,Node
|
||||
>::type node_allocator;
|
||||
typedef detail::allocator_traits<node_allocator> node_alloc_traits;
|
||||
typedef typename node_alloc_traits::pointer node_pointer;
|
||||
|
||||
alloc_traits::destroy(*allocator_ptr(),boost::addressof(node->value()));
|
||||
node_allocator nal(*allocator_ptr());
|
||||
node_alloc_traits::deallocate(nal,static_cast<node_pointer>(node),1);
|
||||
}
|
||||
|
||||
Node* node;
|
||||
typename aligned_storage<
|
||||
sizeof(allocator_type),
|
||||
alignment_of<allocator_type>::value
|
||||
>::type space;
|
||||
};
|
||||
|
||||
#include <boost/multi_index/detail/undef_if_constexpr_macro.hpp>
|
||||
|
||||
/* node handle insert return type template class following
|
||||
* [container.insert.return] specs.
|
||||
*/
|
||||
|
||||
template<typename Iterator,typename NodeHandle>
|
||||
struct insert_return_type
|
||||
{
|
||||
insert_return_type(
|
||||
Iterator position_,bool inserted_,BOOST_RV_REF(NodeHandle) node_):
|
||||
position(position_),inserted(inserted_),node(boost::move(node_)){}
|
||||
insert_return_type(BOOST_RV_REF(insert_return_type) x):
|
||||
position(x.position),inserted(x.inserted),node(boost::move(x.node)){}
|
||||
|
||||
insert_return_type& operator=(BOOST_RV_REF(insert_return_type) x)
|
||||
{
|
||||
position=x.position;
|
||||
inserted=x.inserted;
|
||||
node=boost::move(x.node);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Iterator position;
|
||||
bool inserted;
|
||||
NodeHandle node;
|
||||
|
||||
private:
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(insert_return_type)
|
||||
};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2013 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_NODE_TYPE_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_NODE_TYPE_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <boost/multi_index/detail/header_holder.hpp>
|
||||
#include <boost/multi_index/detail/index_node_base.hpp>
|
||||
#include <boost/multi_index/detail/is_index_list.hpp>
|
||||
#include <boost/multi_index/detail/msvc_index_specifier.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace boost{
|
||||
@@ -34,6 +35,17 @@ namespace detail{
|
||||
* index list.
|
||||
*/
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC,<1310)
|
||||
struct index_node_applier
|
||||
{
|
||||
template<typename IndexSpecifierIterator,typename Super>
|
||||
struct apply:
|
||||
msvc_index_specifier< mpl::deref<IndexSpecifierIterator>::type >::
|
||||
template result_node_class<Super>
|
||||
{
|
||||
};
|
||||
};
|
||||
#else
|
||||
struct index_node_applier
|
||||
{
|
||||
template<typename IndexSpecifierIterator,typename Super>
|
||||
@@ -44,6 +56,7 @@ struct index_node_applier
|
||||
BOOST_NESTED_TEMPLATE node_class<Super>::type type;
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
||||
template<typename Value,typename IndexSpecifierList,typename Allocator>
|
||||
struct multi_index_node_type
|
||||
@@ -52,7 +65,7 @@ struct multi_index_node_type
|
||||
|
||||
typedef typename mpl::reverse_iter_fold<
|
||||
IndexSpecifierList,
|
||||
index_node_base<Value,Allocator>,
|
||||
index_node_base<Value>,
|
||||
mpl::bind2<index_node_applier,mpl::_2,mpl::_1>
|
||||
>::type type;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2013 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_ARGS_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_ARGS_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,128 +0,0 @@
|
||||
/* Copyright 2003-2015 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_IMPL_FWD_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_IMPL_FWD_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
template<
|
||||
typename KeyFromValue,typename Compare,
|
||||
typename SuperMeta,typename TagList,typename Category,typename AugmentPolicy
|
||||
>
|
||||
class ordered_index;
|
||||
|
||||
template<
|
||||
typename KeyFromValue1,typename Compare1,
|
||||
typename SuperMeta1,typename TagList1,typename Category1,
|
||||
typename AugmentPolicy1,
|
||||
typename KeyFromValue2,typename Compare2,
|
||||
typename SuperMeta2,typename TagList2,typename Category2,
|
||||
typename AugmentPolicy2
|
||||
>
|
||||
bool operator==(
|
||||
const ordered_index<
|
||||
KeyFromValue1,Compare1,SuperMeta1,TagList1,Category1,AugmentPolicy1>& x,
|
||||
const ordered_index<
|
||||
KeyFromValue2,Compare2,SuperMeta2,TagList2,Category2,AugmentPolicy2>& y);
|
||||
|
||||
template<
|
||||
typename KeyFromValue1,typename Compare1,
|
||||
typename SuperMeta1,typename TagList1,typename Category1,
|
||||
typename AugmentPolicy1,
|
||||
typename KeyFromValue2,typename Compare2,
|
||||
typename SuperMeta2,typename TagList2,typename Category2,
|
||||
typename AugmentPolicy2
|
||||
>
|
||||
bool operator<(
|
||||
const ordered_index<
|
||||
KeyFromValue1,Compare1,SuperMeta1,TagList1,Category1,AugmentPolicy1>& x,
|
||||
const ordered_index<
|
||||
KeyFromValue2,Compare2,SuperMeta2,TagList2,Category2,AugmentPolicy2>& y);
|
||||
|
||||
template<
|
||||
typename KeyFromValue1,typename Compare1,
|
||||
typename SuperMeta1,typename TagList1,typename Category1,
|
||||
typename AugmentPolicy1,
|
||||
typename KeyFromValue2,typename Compare2,
|
||||
typename SuperMeta2,typename TagList2,typename Category2,
|
||||
typename AugmentPolicy2
|
||||
>
|
||||
bool operator!=(
|
||||
const ordered_index<
|
||||
KeyFromValue1,Compare1,SuperMeta1,TagList1,Category1,AugmentPolicy1>& x,
|
||||
const ordered_index<
|
||||
KeyFromValue2,Compare2,SuperMeta2,TagList2,Category2,AugmentPolicy2>& y);
|
||||
|
||||
template<
|
||||
typename KeyFromValue1,typename Compare1,
|
||||
typename SuperMeta1,typename TagList1,typename Category1,
|
||||
typename AugmentPolicy1,
|
||||
typename KeyFromValue2,typename Compare2,
|
||||
typename SuperMeta2,typename TagList2,typename Category2,
|
||||
typename AugmentPolicy2
|
||||
>
|
||||
bool operator>(
|
||||
const ordered_index<
|
||||
KeyFromValue1,Compare1,SuperMeta1,TagList1,Category1,AugmentPolicy1>& x,
|
||||
const ordered_index<
|
||||
KeyFromValue2,Compare2,SuperMeta2,TagList2,Category2,AugmentPolicy2>& y);
|
||||
|
||||
template<
|
||||
typename KeyFromValue1,typename Compare1,
|
||||
typename SuperMeta1,typename TagList1,typename Category1,
|
||||
typename AugmentPolicy1,
|
||||
typename KeyFromValue2,typename Compare2,
|
||||
typename SuperMeta2,typename TagList2,typename Category2,
|
||||
typename AugmentPolicy2
|
||||
>
|
||||
bool operator>=(
|
||||
const ordered_index<
|
||||
KeyFromValue1,Compare1,SuperMeta1,TagList1,Category1,AugmentPolicy1>& x,
|
||||
const ordered_index<
|
||||
KeyFromValue2,Compare2,SuperMeta2,TagList2,Category2,AugmentPolicy2>& y);
|
||||
|
||||
template<
|
||||
typename KeyFromValue1,typename Compare1,
|
||||
typename SuperMeta1,typename TagList1,typename Category1,
|
||||
typename AugmentPolicy1,
|
||||
typename KeyFromValue2,typename Compare2,
|
||||
typename SuperMeta2,typename TagList2,typename Category2,
|
||||
typename AugmentPolicy2
|
||||
>
|
||||
bool operator<=(
|
||||
const ordered_index<
|
||||
KeyFromValue1,Compare1,SuperMeta1,TagList1,Category1,AugmentPolicy1>& x,
|
||||
const ordered_index<
|
||||
KeyFromValue2,Compare2,SuperMeta2,TagList2,Category2,AugmentPolicy2>& y);
|
||||
|
||||
template<
|
||||
typename KeyFromValue,typename Compare,
|
||||
typename SuperMeta,typename TagList,typename Category,typename AugmentPolicy
|
||||
>
|
||||
void swap(
|
||||
ordered_index<
|
||||
KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy>& x,
|
||||
ordered_index<
|
||||
KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy>& y);
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2007 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -36,21 +36,18 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_NODE_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_NODE_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <cstddef>
|
||||
#include <boost/multi_index/detail/allocator_traits.hpp>
|
||||
#include <boost/multi_index/detail/raw_ptr.hpp>
|
||||
|
||||
#if !defined(BOOST_MULTI_INDEX_DISABLE_COMPRESSED_ORDERED_INDEX_NODES)
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/multi_index/detail/uintptr_type.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
@@ -64,50 +61,27 @@ namespace detail{
|
||||
enum ordered_index_color{red=false,black=true};
|
||||
enum ordered_index_side{to_left=false,to_right=true};
|
||||
|
||||
template<typename AugmentPolicy,typename Allocator>
|
||||
struct ordered_index_node_impl; /* fwd decl. */
|
||||
|
||||
template<typename AugmentPolicy,typename Allocator>
|
||||
struct ordered_index_node_traits
|
||||
{
|
||||
typedef typename rebind_alloc_for<
|
||||
Allocator,
|
||||
ordered_index_node_impl<AugmentPolicy,Allocator>
|
||||
>::type allocator;
|
||||
typedef allocator_traits<allocator> alloc_traits;
|
||||
typedef typename alloc_traits::pointer pointer;
|
||||
typedef typename alloc_traits::const_pointer const_pointer;
|
||||
typedef typename alloc_traits::difference_type difference_type;
|
||||
typedef typename alloc_traits::size_type size_type;
|
||||
};
|
||||
|
||||
template<typename AugmentPolicy,typename Allocator>
|
||||
struct ordered_index_node_std_base
|
||||
{
|
||||
typedef ordered_index_node_traits<
|
||||
AugmentPolicy,Allocator> node_traits;
|
||||
typedef typename node_traits::allocator node_allocator;
|
||||
typedef typename node_traits::pointer pointer;
|
||||
typedef typename node_traits::const_pointer const_pointer;
|
||||
typedef typename node_traits::difference_type difference_type;
|
||||
typedef typename node_traits::size_type size_type;
|
||||
typedef ordered_index_color& color_ref;
|
||||
typedef pointer& parent_ref;
|
||||
typedef ordered_index_color& color_ref;
|
||||
typedef ordered_index_node_impl*& parent_ref;
|
||||
|
||||
ordered_index_color& color(){return color_;}
|
||||
ordered_index_color color()const{return color_;}
|
||||
pointer& parent(){return parent_;}
|
||||
pointer parent()const{return parent_;}
|
||||
pointer& left(){return left_;}
|
||||
pointer left()const{return left_;}
|
||||
pointer& right(){return right_;}
|
||||
pointer right()const{return right_;}
|
||||
ordered_index_color& color(){return color_;}
|
||||
ordered_index_color color()const{return color_;}
|
||||
ordered_index_node_impl*& parent(){return parent_;}
|
||||
ordered_index_node_impl* parent()const{return parent_;}
|
||||
ordered_index_node_impl*& left(){return left_;}
|
||||
ordered_index_node_impl* left()const{return left_;}
|
||||
ordered_index_node_impl*& right(){return right_;}
|
||||
ordered_index_node_impl* right()const{return right_;}
|
||||
|
||||
private:
|
||||
ordered_index_color color_;
|
||||
pointer parent_;
|
||||
pointer left_;
|
||||
pointer right_;
|
||||
ordered_index_color color_;
|
||||
ordered_index_node_impl* parent_;
|
||||
ordered_index_node_impl* left_;
|
||||
ordered_index_node_impl* right_;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_MULTI_INDEX_DISABLE_COMPRESSED_ORDERED_INDEX_NODES)
|
||||
@@ -128,22 +102,11 @@ private:
|
||||
#pragma warning(disable:4312 4311)
|
||||
#endif
|
||||
|
||||
template<typename AugmentPolicy,typename Allocator>
|
||||
struct ordered_index_node_compressed_base
|
||||
{
|
||||
typedef ordered_index_node_traits<
|
||||
AugmentPolicy,Allocator> node_traits;
|
||||
typedef ordered_index_node_impl<
|
||||
AugmentPolicy,Allocator>* pointer;
|
||||
typedef const ordered_index_node_impl<
|
||||
AugmentPolicy,Allocator>* const_pointer;
|
||||
typedef typename node_traits::difference_type difference_type;
|
||||
typedef typename node_traits::size_type size_type;
|
||||
|
||||
struct color_ref
|
||||
{
|
||||
color_ref(uintptr_type* r_):r(r_){}
|
||||
color_ref(const color_ref& x):r(x.r){}
|
||||
|
||||
operator ordered_index_color()const
|
||||
{
|
||||
@@ -169,14 +132,13 @@ struct ordered_index_node_compressed_base
|
||||
struct parent_ref
|
||||
{
|
||||
parent_ref(uintptr_type* r_):r(r_){}
|
||||
parent_ref(const parent_ref& x):r(x.r){}
|
||||
|
||||
operator pointer()const
|
||||
operator ordered_index_node_impl*()const
|
||||
{
|
||||
return (pointer)(void*)(*r&~uintptr_type(1));
|
||||
return (ordered_index_node_impl*)(void*)(*r&~uintptr_type(1));
|
||||
}
|
||||
|
||||
parent_ref& operator=(pointer p)
|
||||
parent_ref& operator=(ordered_index_node_impl* p)
|
||||
{
|
||||
*r=((uintptr_type)(void*)p)|(*r&uintptr_type(1));
|
||||
return *this;
|
||||
@@ -184,93 +146,69 @@ struct ordered_index_node_compressed_base
|
||||
|
||||
parent_ref& operator=(const parent_ref& x)
|
||||
{
|
||||
return operator=(x.operator pointer());
|
||||
return operator=(x.operator ordered_index_node_impl*());
|
||||
}
|
||||
|
||||
pointer operator->()const
|
||||
ordered_index_node_impl* operator->()const
|
||||
{
|
||||
return operator pointer();
|
||||
return operator ordered_index_node_impl*();
|
||||
}
|
||||
|
||||
private:
|
||||
uintptr_type* r;
|
||||
};
|
||||
|
||||
color_ref color(){return color_ref(&parentcolor_);}
|
||||
ordered_index_color color()const
|
||||
color_ref color(){return color_ref(&parentcolor_);}
|
||||
ordered_index_color color()const
|
||||
{
|
||||
return ordered_index_color(parentcolor_&uintptr_type(1));
|
||||
return ordered_index_color(parentcolor_&std::size_t(1ul));
|
||||
}
|
||||
|
||||
parent_ref parent(){return parent_ref(&parentcolor_);}
|
||||
pointer parent()const
|
||||
parent_ref parent(){return parent_ref(&parentcolor_);}
|
||||
ordered_index_node_impl* parent()const
|
||||
{
|
||||
return (pointer)(void*)(parentcolor_&~uintptr_type(1));
|
||||
return (ordered_index_node_impl*)(void*)(parentcolor_&~uintptr_type(1));
|
||||
}
|
||||
|
||||
pointer& left(){return left_;}
|
||||
pointer left()const{return left_;}
|
||||
pointer& right(){return right_;}
|
||||
pointer right()const{return right_;}
|
||||
ordered_index_node_impl*& left(){return left_;}
|
||||
ordered_index_node_impl* left()const{return left_;}
|
||||
ordered_index_node_impl*& right(){return right_;}
|
||||
ordered_index_node_impl* right()const{return right_;}
|
||||
|
||||
private:
|
||||
uintptr_type parentcolor_;
|
||||
pointer left_;
|
||||
pointer right_;
|
||||
uintptr_type parentcolor_;
|
||||
ordered_index_node_impl* left_;
|
||||
ordered_index_node_impl* right_;
|
||||
};
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template<typename AugmentPolicy,typename Allocator>
|
||||
struct ordered_index_node_impl_base:
|
||||
struct ordered_index_node_impl:
|
||||
|
||||
#if !defined(BOOST_MULTI_INDEX_DISABLE_COMPRESSED_ORDERED_INDEX_NODES)
|
||||
AugmentPolicy::template augmented_node<
|
||||
typename mpl::if_c<
|
||||
!(has_uintptr_type::value)||
|
||||
(alignment_of<
|
||||
ordered_index_node_compressed_base<AugmentPolicy,Allocator>
|
||||
>::value%2)||
|
||||
!(is_same<
|
||||
typename ordered_index_node_traits<AugmentPolicy,Allocator>::pointer,
|
||||
ordered_index_node_impl<AugmentPolicy,Allocator>*>::value),
|
||||
ordered_index_node_std_base<AugmentPolicy,Allocator>,
|
||||
ordered_index_node_compressed_base<AugmentPolicy,Allocator>
|
||||
>::type
|
||||
mpl::if_c<
|
||||
!(has_uintptr_type::value)||
|
||||
(alignment_of<ordered_index_node_compressed_base>::value%2),
|
||||
ordered_index_node_std_base,
|
||||
ordered_index_node_compressed_base
|
||||
>::type
|
||||
#else
|
||||
AugmentPolicy::template augmented_node<
|
||||
ordered_index_node_std_base<AugmentPolicy,Allocator>
|
||||
>::type
|
||||
ordered_index_node_std_base
|
||||
#endif
|
||||
|
||||
{};
|
||||
|
||||
template<typename AugmentPolicy,typename Allocator>
|
||||
struct ordered_index_node_impl:
|
||||
ordered_index_node_impl_base<AugmentPolicy,Allocator>
|
||||
{
|
||||
private:
|
||||
typedef ordered_index_node_impl_base<AugmentPolicy,Allocator> super;
|
||||
|
||||
public:
|
||||
typedef typename super::color_ref color_ref;
|
||||
typedef typename super::parent_ref parent_ref;
|
||||
typedef typename super::pointer pointer;
|
||||
typedef typename super::const_pointer const_pointer;
|
||||
|
||||
/* interoperability with bidir_node_iterator */
|
||||
|
||||
static void increment(pointer& x)
|
||||
static void increment(ordered_index_node_impl*& x)
|
||||
{
|
||||
if(x->right()!=pointer(0)){
|
||||
if(x->right()){
|
||||
x=x->right();
|
||||
while(x->left()!=pointer(0))x=x->left();
|
||||
while(x->left())x=x->left();
|
||||
}
|
||||
else{
|
||||
pointer y=x->parent();
|
||||
ordered_index_node_impl* y=x->parent();
|
||||
while(x==y->right()){
|
||||
x=y;
|
||||
y=y->parent();
|
||||
@@ -279,17 +217,17 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static void decrement(pointer& x)
|
||||
static void decrement(ordered_index_node_impl*& x)
|
||||
{
|
||||
if(x->color()==red&&x->parent()->parent()==x){
|
||||
x=x->right();
|
||||
}
|
||||
else if(x->left()!=pointer(0)){
|
||||
pointer y=x->left();
|
||||
while(y->right()!=pointer(0))y=y->right();
|
||||
else if(x->left()){
|
||||
ordered_index_node_impl* y=x->left();
|
||||
while(y->right())y=y->right();
|
||||
x=y;
|
||||
}else{
|
||||
pointer y=x->parent();
|
||||
ordered_index_node_impl* y=x->parent();
|
||||
while(x==y->left()){
|
||||
x=y;
|
||||
y=y->parent();
|
||||
@@ -300,11 +238,12 @@ public:
|
||||
|
||||
/* algorithmic stuff */
|
||||
|
||||
static void rotate_left(pointer x,parent_ref root)
|
||||
static void rotate_left(
|
||||
ordered_index_node_impl* x,parent_ref root)
|
||||
{
|
||||
pointer y=x->right();
|
||||
ordered_index_node_impl* y=x->right();
|
||||
x->right()=y->left();
|
||||
if(y->left()!=pointer(0))y->left()->parent()=x;
|
||||
if(y->left())y->left()->parent()=x;
|
||||
y->parent()=x->parent();
|
||||
|
||||
if(x==root) root=y;
|
||||
@@ -312,26 +251,26 @@ public:
|
||||
else x->parent()->right()=y;
|
||||
y->left()=x;
|
||||
x->parent()=y;
|
||||
AugmentPolicy::rotate_left(x,y);
|
||||
}
|
||||
|
||||
static pointer minimum(pointer x)
|
||||
static ordered_index_node_impl* minimum(ordered_index_node_impl* x)
|
||||
{
|
||||
while(x->left()!=pointer(0))x=x->left();
|
||||
while(x->left())x=x->left();
|
||||
return x;
|
||||
}
|
||||
|
||||
static pointer maximum(pointer x)
|
||||
static ordered_index_node_impl* maximum(ordered_index_node_impl* x)
|
||||
{
|
||||
while(x->right()!=pointer(0))x=x->right();
|
||||
while(x->right())x=x->right();
|
||||
return x;
|
||||
}
|
||||
|
||||
static void rotate_right(pointer x,parent_ref root)
|
||||
static void rotate_right(
|
||||
ordered_index_node_impl* x,parent_ref root)
|
||||
{
|
||||
pointer y=x->left();
|
||||
ordered_index_node_impl* y=x->left();
|
||||
x->left()=y->right();
|
||||
if(y->right()!=pointer(0))y->right()->parent()=x;
|
||||
if(y->right())y->right()->parent()=x;
|
||||
y->parent()=x->parent();
|
||||
|
||||
if(x==root) root=y;
|
||||
@@ -339,16 +278,16 @@ public:
|
||||
else x->parent()->left()=y;
|
||||
y->right()=x;
|
||||
x->parent()=y;
|
||||
AugmentPolicy::rotate_right(x,y);
|
||||
}
|
||||
|
||||
static void rebalance(pointer x,parent_ref root)
|
||||
static void rebalance(
|
||||
ordered_index_node_impl* x,parent_ref root)
|
||||
{
|
||||
x->color()=red;
|
||||
while(x!=root&&x->parent()->color()==red){
|
||||
if(x->parent()==x->parent()->parent()->left()){
|
||||
pointer y=x->parent()->parent()->right();
|
||||
if(y!=pointer(0)&&y->color()==red){
|
||||
ordered_index_node_impl* y=x->parent()->parent()->right();
|
||||
if(y&&y->color()==red){
|
||||
x->parent()->color()=black;
|
||||
y->color()=black;
|
||||
x->parent()->parent()->color()=red;
|
||||
@@ -365,8 +304,8 @@ public:
|
||||
}
|
||||
}
|
||||
else{
|
||||
pointer y=x->parent()->parent()->left();
|
||||
if(y!=pointer(0)&&y->color()==red){
|
||||
ordered_index_node_impl* y=x->parent()->parent()->left();
|
||||
if(y&&y->color()==red){
|
||||
x->parent()->color()=black;
|
||||
y->color()=black;
|
||||
x->parent()->parent()->color()=red;
|
||||
@@ -387,7 +326,9 @@ public:
|
||||
}
|
||||
|
||||
static void link(
|
||||
pointer x,ordered_index_side side,pointer position,pointer header)
|
||||
ordered_index_node_impl* x,
|
||||
ordered_index_side side,ordered_index_node_impl* position,
|
||||
ordered_index_node_impl* header)
|
||||
{
|
||||
if(side==to_left){
|
||||
position->left()=x; /* also makes leftmost=x when parent==header */
|
||||
@@ -406,39 +347,37 @@ public:
|
||||
}
|
||||
}
|
||||
x->parent()=position;
|
||||
x->left()=pointer(0);
|
||||
x->right()=pointer(0);
|
||||
AugmentPolicy::add(x,pointer(header->parent()));
|
||||
x->left()=0;
|
||||
x->right()=0;
|
||||
ordered_index_node_impl::rebalance(x,header->parent());
|
||||
}
|
||||
|
||||
static pointer rebalance_for_extract(
|
||||
pointer z,parent_ref root,pointer& leftmost,pointer& rightmost)
|
||||
static ordered_index_node_impl* rebalance_for_erase(
|
||||
ordered_index_node_impl* z,parent_ref root,
|
||||
ordered_index_node_impl*& leftmost,ordered_index_node_impl*& rightmost)
|
||||
{
|
||||
pointer y=z;
|
||||
pointer x=pointer(0);
|
||||
pointer x_parent=pointer(0);
|
||||
if(y->left()==pointer(0)){ /* z has at most one non-null child. y==z. */
|
||||
x=y->right(); /* x might be null */
|
||||
ordered_index_node_impl* y=z;
|
||||
ordered_index_node_impl* x=0;
|
||||
ordered_index_node_impl* x_parent=0;
|
||||
if(y->left()==0){ /* z has at most one non-null child. y==z. */
|
||||
x=y->right(); /* x might be null */
|
||||
}
|
||||
else{
|
||||
if(y->right()==pointer(0)){ /* z has exactly one non-null child. y==z. */
|
||||
x=y->left(); /* x is not null */
|
||||
if(y->right()==0) { /* z has exactly one non-null child. y==z. */
|
||||
x=y->left(); /* x is not null */
|
||||
}
|
||||
else{ /* z has two non-null children. Set y to */
|
||||
y=y->right(); /* z's successor. x might be null. */
|
||||
while(y->left()!=pointer(0))y=y->left();
|
||||
else{ /* z has two non-null children. Set y to */
|
||||
y=y->right(); /* z's successor. x might be null. */
|
||||
while(y->left())y=y->left();
|
||||
x=y->right();
|
||||
}
|
||||
}
|
||||
AugmentPolicy::remove(y,pointer(root));
|
||||
if(y!=z){
|
||||
AugmentPolicy::copy(z,y);
|
||||
z->left()->parent()=y; /* relink y in place of z. y is z's successor */
|
||||
y->left()=z->left();
|
||||
if(y!=z->right()){
|
||||
x_parent=y->parent();
|
||||
if(x!=pointer(0))x->parent()=y->parent();
|
||||
if(x) x->parent()=y->parent();
|
||||
y->parent()->left()=x; /* y must be a child of left */
|
||||
y->right()=z->right();
|
||||
z->right()->parent()=y;
|
||||
@@ -458,7 +397,7 @@ public:
|
||||
}
|
||||
else{ /* y==z */
|
||||
x_parent=y->parent();
|
||||
if(x!=pointer(0))x->parent()=y->parent();
|
||||
if(x)x->parent()=y->parent();
|
||||
if(root==z){
|
||||
root=x;
|
||||
}
|
||||
@@ -467,15 +406,15 @@ public:
|
||||
else z->parent()->right()=x;
|
||||
}
|
||||
if(leftmost==z){
|
||||
if(z->right()==pointer(0)){ /* z->left() must be null also */
|
||||
if(z->right()==0){ /* z->left() must be null also */
|
||||
leftmost=z->parent();
|
||||
}
|
||||
else{
|
||||
leftmost=minimum(x); /* makes leftmost==header if z==root */
|
||||
leftmost=minimum(x); /* makes leftmost==header if z==root */
|
||||
}
|
||||
}
|
||||
if(rightmost==z){
|
||||
if(z->left()==pointer(0)){ /* z->right() must be null also */
|
||||
if(z->left()==0){ /* z->right() must be null also */
|
||||
rightmost=z->parent();
|
||||
}
|
||||
else{ /* x==z->left() */
|
||||
@@ -484,73 +423,75 @@ public:
|
||||
}
|
||||
}
|
||||
if(y->color()!=red){
|
||||
while(x!=root&&(x==pointer(0)|| x->color()==black)){
|
||||
while(x!=root&&(x==0 || x->color()==black)){
|
||||
if(x==x_parent->left()){
|
||||
pointer w=x_parent->right();
|
||||
ordered_index_node_impl* w=x_parent->right();
|
||||
if(w->color()==red){
|
||||
w->color()=black;
|
||||
x_parent->color()=red;
|
||||
rotate_left(x_parent,root);
|
||||
w=x_parent->right();
|
||||
}
|
||||
if((w->left()==pointer(0)||w->left()->color()==black) &&
|
||||
(w->right()==pointer(0)||w->right()->color()==black)){
|
||||
if((w->left()==0||w->left()->color()==black) &&
|
||||
(w->right()==0||w->right()->color()==black)){
|
||||
w->color()=red;
|
||||
x=x_parent;
|
||||
x_parent=x_parent->parent();
|
||||
}
|
||||
else{
|
||||
if(w->right()==pointer(0 )
|
||||
if(w->right()==0
|
||||
|| w->right()->color()==black){
|
||||
if(w->left()!=pointer(0)) w->left()->color()=black;
|
||||
if(w->left()) w->left()->color()=black;
|
||||
w->color()=red;
|
||||
rotate_right(w,root);
|
||||
w=x_parent->right();
|
||||
}
|
||||
w->color()=x_parent->color();
|
||||
x_parent->color()=black;
|
||||
if(w->right()!=pointer(0))w->right()->color()=black;
|
||||
if(w->right())w->right()->color()=black;
|
||||
rotate_left(x_parent,root);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else{ /* same as above,with right <-> left */
|
||||
pointer w=x_parent->left();
|
||||
ordered_index_node_impl* w=x_parent->left();
|
||||
if(w->color()==red){
|
||||
w->color()=black;
|
||||
x_parent->color()=red;
|
||||
rotate_right(x_parent,root);
|
||||
w=x_parent->left();
|
||||
}
|
||||
if((w->right()==pointer(0)||w->right()->color()==black) &&
|
||||
(w->left()==pointer(0)||w->left()->color()==black)){
|
||||
if((w->right()==0||w->right()->color()==black) &&
|
||||
(w->left()==0||w->left()->color()==black)){
|
||||
w->color()=red;
|
||||
x=x_parent;
|
||||
x_parent=x_parent->parent();
|
||||
}
|
||||
else{
|
||||
if(w->left()==pointer(0)||w->left()->color()==black){
|
||||
if(w->right()!=pointer(0))w->right()->color()=black;
|
||||
if(w->left()==0||w->left()->color()==black){
|
||||
if(w->right())w->right()->color()=black;
|
||||
w->color()=red;
|
||||
rotate_left(w,root);
|
||||
w=x_parent->left();
|
||||
}
|
||||
w->color()=x_parent->color();
|
||||
x_parent->color()=black;
|
||||
if(w->left()!=pointer(0))w->left()->color()=black;
|
||||
if(w->left())w->left()->color()=black;
|
||||
rotate_right(x_parent,root);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(x!=pointer(0))x->color()=black;
|
||||
if(x)x->color()=black;
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
static void restore(pointer x,pointer position,pointer header)
|
||||
static void restore(
|
||||
ordered_index_node_impl* x,ordered_index_node_impl* position,
|
||||
ordered_index_node_impl* header)
|
||||
{
|
||||
if(position->left()==pointer(0)||position->left()==header){
|
||||
if(position->left()==0||position->left()==header){
|
||||
link(x,to_left,position,header);
|
||||
}
|
||||
else{
|
||||
@@ -562,9 +503,10 @@ public:
|
||||
#if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)
|
||||
/* invariant stuff */
|
||||
|
||||
static std::size_t black_count(pointer node,pointer root)
|
||||
static std::size_t black_count(
|
||||
ordered_index_node_impl* node,ordered_index_node_impl* root)
|
||||
{
|
||||
if(node==pointer(0))return 0;
|
||||
if(!node)return 0;
|
||||
std::size_t sum=0;
|
||||
for(;;){
|
||||
if(node->color()==black)++sum;
|
||||
@@ -576,91 +518,55 @@ public:
|
||||
#endif
|
||||
};
|
||||
|
||||
template<typename AugmentPolicy,typename Super>
|
||||
struct ordered_index_node_trampoline:
|
||||
ordered_index_node_impl<
|
||||
AugmentPolicy,
|
||||
typename rebind_alloc_for<
|
||||
typename Super::allocator_type,
|
||||
char
|
||||
>::type
|
||||
>
|
||||
{
|
||||
typedef ordered_index_node_impl<
|
||||
AugmentPolicy,
|
||||
typename rebind_alloc_for<
|
||||
typename Super::allocator_type,
|
||||
char
|
||||
>::type
|
||||
> impl_type;
|
||||
};
|
||||
template<typename Super>
|
||||
struct ordered_index_node_trampoline:ordered_index_node_impl{};
|
||||
|
||||
template<typename AugmentPolicy,typename Super>
|
||||
struct ordered_index_node:
|
||||
Super,ordered_index_node_trampoline<AugmentPolicy,Super>
|
||||
template<typename Super>
|
||||
struct ordered_index_node:Super,ordered_index_node_trampoline<Super>
|
||||
{
|
||||
private:
|
||||
typedef ordered_index_node_trampoline<AugmentPolicy,Super> trampoline;
|
||||
typedef ordered_index_node_trampoline<Super> impl_type;
|
||||
typedef typename impl_type::color_ref color_ref;
|
||||
typedef typename impl_type::parent_ref parent_ref;
|
||||
|
||||
public:
|
||||
typedef typename trampoline::impl_type impl_type;
|
||||
typedef typename trampoline::color_ref impl_color_ref;
|
||||
typedef typename trampoline::parent_ref impl_parent_ref;
|
||||
typedef typename trampoline::pointer impl_pointer;
|
||||
typedef typename trampoline::const_pointer const_impl_pointer;
|
||||
typedef typename trampoline::difference_type difference_type;
|
||||
typedef typename trampoline::size_type size_type;
|
||||
color_ref color(){return impl_type::color();}
|
||||
ordered_index_color color()const{return impl_type::color();}
|
||||
parent_ref parent(){return impl_type::parent();}
|
||||
ordered_index_node_impl* parent()const{return impl_type::parent();}
|
||||
ordered_index_node_impl*& left(){return impl_type::left();}
|
||||
ordered_index_node_impl* left()const{return impl_type::left();}
|
||||
ordered_index_node_impl*& right(){return impl_type::right();}
|
||||
ordered_index_node_impl* right()const{return impl_type::right();}
|
||||
|
||||
impl_color_ref color(){return trampoline::color();}
|
||||
ordered_index_color color()const{return trampoline::color();}
|
||||
impl_parent_ref parent(){return trampoline::parent();}
|
||||
impl_pointer parent()const{return trampoline::parent();}
|
||||
impl_pointer& left(){return trampoline::left();}
|
||||
impl_pointer left()const{return trampoline::left();}
|
||||
impl_pointer& right(){return trampoline::right();}
|
||||
impl_pointer right()const{return trampoline::right();}
|
||||
ordered_index_node_impl* impl(){return static_cast<impl_type*>(this);}
|
||||
const ordered_index_node_impl* impl()const
|
||||
{return static_cast<const impl_type*>(this);}
|
||||
|
||||
impl_pointer impl()
|
||||
static ordered_index_node* from_impl(ordered_index_node_impl *x)
|
||||
{
|
||||
return static_cast<impl_pointer>(
|
||||
static_cast<impl_type*>(static_cast<trampoline*>(this)));
|
||||
return static_cast<ordered_index_node*>(static_cast<impl_type*>(x));
|
||||
}
|
||||
|
||||
const_impl_pointer impl()const
|
||||
|
||||
static const ordered_index_node* from_impl(const ordered_index_node_impl* x)
|
||||
{
|
||||
return static_cast<const_impl_pointer>(
|
||||
static_cast<const impl_type*>(static_cast<const trampoline*>(this)));
|
||||
}
|
||||
|
||||
static ordered_index_node* from_impl(impl_pointer x)
|
||||
{
|
||||
return
|
||||
static_cast<ordered_index_node*>(
|
||||
static_cast<trampoline*>(
|
||||
raw_ptr<impl_type*>(x)));
|
||||
}
|
||||
|
||||
static const ordered_index_node* from_impl(const_impl_pointer x)
|
||||
{
|
||||
return
|
||||
static_cast<const ordered_index_node*>(
|
||||
static_cast<const trampoline*>(
|
||||
raw_ptr<const impl_type*>(x)));
|
||||
return static_cast<const ordered_index_node*>(
|
||||
static_cast<const impl_type*>(x));
|
||||
}
|
||||
|
||||
/* interoperability with bidir_node_iterator */
|
||||
|
||||
static void increment(ordered_index_node*& x)
|
||||
{
|
||||
impl_pointer xi=x->impl();
|
||||
trampoline::increment(xi);
|
||||
ordered_index_node_impl* xi=x->impl();
|
||||
impl_type::increment(xi);
|
||||
x=from_impl(xi);
|
||||
}
|
||||
|
||||
static void decrement(ordered_index_node*& x)
|
||||
{
|
||||
impl_pointer xi=x->impl();
|
||||
trampoline::decrement(xi);
|
||||
ordered_index_node_impl* xi=x->impl();
|
||||
impl_type::decrement(xi);
|
||||
x=from_impl(xi);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2014 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -36,15 +36,10 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_OPS_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_OPS_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/multi_index/detail/promotes_arg.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
@@ -53,9 +48,6 @@ namespace detail{
|
||||
|
||||
/* Common code for index memfuns having templatized and
|
||||
* non-templatized versions.
|
||||
* Implementation note: When CompatibleKey is consistently promoted to
|
||||
* KeyFromValue::result_type for comparison, the promotion is made once in
|
||||
* advance to increase efficiency.
|
||||
*/
|
||||
|
||||
template<
|
||||
@@ -63,49 +55,21 @@ template<
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline Node* ordered_index_find(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
Node* header,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp)
|
||||
{
|
||||
typedef typename KeyFromValue::result_type key_type;
|
||||
|
||||
return ordered_index_find(
|
||||
top,y,key,x,comp,
|
||||
mpl::and_<
|
||||
promotes_1st_arg<CompatibleCompare,CompatibleKey,key_type>,
|
||||
promotes_2nd_arg<CompatibleCompare,key_type,CompatibleKey> >());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleCompare
|
||||
>
|
||||
inline Node* ordered_index_find(
|
||||
Node* top,Node* y,const KeyFromValue& key,
|
||||
const BOOST_DEDUCED_TYPENAME KeyFromValue::result_type& x,
|
||||
const CompatibleCompare& comp,mpl::true_)
|
||||
{
|
||||
return ordered_index_find(top,y,key,x,comp,mpl::false_());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline Node* ordered_index_find(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp,mpl::false_)
|
||||
{
|
||||
Node* y0=y;
|
||||
|
||||
while (top){
|
||||
if(!comp(key(top->value()),x)){
|
||||
y=top;
|
||||
top=Node::from_impl(top->left());
|
||||
Node* y=header;
|
||||
Node* z=Node::from_impl(header->parent());
|
||||
|
||||
while (z){
|
||||
if(!comp(key(z->value()),x)){
|
||||
y=z;
|
||||
z=Node::from_impl(z->left());
|
||||
}
|
||||
else top=Node::from_impl(top->right());
|
||||
else z=Node::from_impl(z->right());
|
||||
}
|
||||
|
||||
return (y==y0||comp(x,key(y->value())))?y0:y;
|
||||
return (y==header||comp(x,key(y->value())))?header:y;
|
||||
}
|
||||
|
||||
template<
|
||||
@@ -113,42 +77,18 @@ template<
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline Node* ordered_index_lower_bound(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
Node* header,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp)
|
||||
{
|
||||
typedef typename KeyFromValue::result_type key_type;
|
||||
Node* y=header;
|
||||
Node* z=Node::from_impl(header->parent());
|
||||
|
||||
return ordered_index_lower_bound(
|
||||
top,y,key,x,comp,
|
||||
promotes_2nd_arg<CompatibleCompare,key_type,CompatibleKey>());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleCompare
|
||||
>
|
||||
inline Node* ordered_index_lower_bound(
|
||||
Node* top,Node* y,const KeyFromValue& key,
|
||||
const BOOST_DEDUCED_TYPENAME KeyFromValue::result_type& x,
|
||||
const CompatibleCompare& comp,mpl::true_)
|
||||
{
|
||||
return ordered_index_lower_bound(top,y,key,x,comp,mpl::false_());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline Node* ordered_index_lower_bound(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp,mpl::false_)
|
||||
{
|
||||
while(top){
|
||||
if(!comp(key(top->value()),x)){
|
||||
y=top;
|
||||
top=Node::from_impl(top->left());
|
||||
while(z){
|
||||
if(!comp(key(z->value()),x)){
|
||||
y=z;
|
||||
z=Node::from_impl(z->left());
|
||||
}
|
||||
else top=Node::from_impl(top->right());
|
||||
else z=Node::from_impl(z->right());
|
||||
}
|
||||
|
||||
return y;
|
||||
@@ -159,104 +99,23 @@ template<
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline Node* ordered_index_upper_bound(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
Node* header,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp)
|
||||
{
|
||||
typedef typename KeyFromValue::result_type key_type;
|
||||
Node* y=header;
|
||||
Node* z=Node::from_impl(header->parent());
|
||||
|
||||
return ordered_index_upper_bound(
|
||||
top,y,key,x,comp,
|
||||
promotes_1st_arg<CompatibleCompare,CompatibleKey,key_type>());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleCompare
|
||||
>
|
||||
inline Node* ordered_index_upper_bound(
|
||||
Node* top,Node* y,const KeyFromValue& key,
|
||||
const BOOST_DEDUCED_TYPENAME KeyFromValue::result_type& x,
|
||||
const CompatibleCompare& comp,mpl::true_)
|
||||
{
|
||||
return ordered_index_upper_bound(top,y,key,x,comp,mpl::false_());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline Node* ordered_index_upper_bound(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp,mpl::false_)
|
||||
{
|
||||
while(top){
|
||||
if(comp(x,key(top->value()))){
|
||||
y=top;
|
||||
top=Node::from_impl(top->left());
|
||||
while(z){
|
||||
if(comp(x,key(z->value()))){
|
||||
y=z;
|
||||
z=Node::from_impl(z->left());
|
||||
}
|
||||
else top=Node::from_impl(top->right());
|
||||
else z=Node::from_impl(z->right());
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline std::pair<Node*,Node*> ordered_index_equal_range(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp)
|
||||
{
|
||||
typedef typename KeyFromValue::result_type key_type;
|
||||
|
||||
return ordered_index_equal_range(
|
||||
top,y,key,x,comp,
|
||||
mpl::and_<
|
||||
promotes_1st_arg<CompatibleCompare,CompatibleKey,key_type>,
|
||||
promotes_2nd_arg<CompatibleCompare,key_type,CompatibleKey> >());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleCompare
|
||||
>
|
||||
inline std::pair<Node*,Node*> ordered_index_equal_range(
|
||||
Node* top,Node* y,const KeyFromValue& key,
|
||||
const BOOST_DEDUCED_TYPENAME KeyFromValue::result_type& x,
|
||||
const CompatibleCompare& comp,mpl::true_)
|
||||
{
|
||||
return ordered_index_equal_range(top,y,key,x,comp,mpl::false_());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline std::pair<Node*,Node*> ordered_index_equal_range(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp,mpl::false_)
|
||||
{
|
||||
while(top){
|
||||
if(comp(key(top->value()),x)){
|
||||
top=Node::from_impl(top->right());
|
||||
}
|
||||
else if(comp(x,key(top->value()))){
|
||||
y=top;
|
||||
top=Node::from_impl(top->left());
|
||||
}
|
||||
else{
|
||||
return std::pair<Node*,Node*>(
|
||||
ordered_index_lower_bound(
|
||||
Node::from_impl(top->left()),top,key,x,comp,mpl::false_()),
|
||||
ordered_index_upper_bound(
|
||||
Node::from_impl(top->right()),y,key,x,comp,mpl::false_()));
|
||||
}
|
||||
}
|
||||
|
||||
return std::pair<Node*,Node*>(y,y);
|
||||
}
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_PREVENT_ETI_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_PREVENT_ETI_HPP
|
||||
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/integral_c.hpp>
|
||||
#include <boost/mpl/aux_/msvc_never_true.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
|
||||
/* See
|
||||
* http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Effective_MPL
|
||||
* Item 5.6, Beware of the 'early template instantiation' trap.
|
||||
*/
|
||||
|
||||
template<typename Type,typename Construct>
|
||||
struct prevent_eti
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
mpl::aux::msvc_never_true<Type>,
|
||||
mpl::integral_c<int,0>,
|
||||
Construct
|
||||
>::type type;
|
||||
};
|
||||
#else
|
||||
template<typename Type,typename Construct>
|
||||
struct prevent_eti
|
||||
{
|
||||
typedef Construct type;
|
||||
};
|
||||
#endif
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif
|
||||
@@ -1,83 +0,0 @@
|
||||
/* Copyright 2003-2017 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_PROMOTES_ARG_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_PROMOTES_ARG_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
/* Metafunctions to check if f(arg1,arg2) promotes either arg1 to the type of
|
||||
* arg2 or viceversa. By default, (i.e. if it cannot be determined), no
|
||||
* promotion is assumed.
|
||||
*/
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC,<1400)
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2>
|
||||
struct promotes_1st_arg:mpl::false_{};
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2>
|
||||
struct promotes_2nd_arg:mpl::false_{};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/multi_index/detail/is_transparent.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2>
|
||||
struct promotes_1st_arg:
|
||||
mpl::and_<
|
||||
mpl::not_<is_transparent<F,Arg1,Arg2> >,
|
||||
is_convertible<const Arg1,Arg2>,
|
||||
is_transparent<F,Arg2,Arg2>
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2>
|
||||
struct promotes_2nd_arg:
|
||||
mpl::and_<
|
||||
mpl::not_<is_transparent<F,Arg1,Arg2> >,
|
||||
is_convertible<const Arg2,Arg1>,
|
||||
is_transparent<F,Arg1,Arg1>
|
||||
>
|
||||
{};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,52 +0,0 @@
|
||||
/* Copyright 2003-2015 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_RAW_PTR_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_RAW_PTR_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
/* gets the underlying pointer of a pointer-like value */
|
||||
|
||||
template<typename RawPointer>
|
||||
inline RawPointer raw_ptr(RawPointer const& p,mpl::true_)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
template<typename RawPointer,typename Pointer>
|
||||
inline RawPointer raw_ptr(Pointer const& p,mpl::false_)
|
||||
{
|
||||
return p==Pointer(0)?0:&*p;
|
||||
}
|
||||
|
||||
template<typename RawPointer,typename Pointer>
|
||||
inline RawPointer raw_ptr(Pointer const& p)
|
||||
{
|
||||
return raw_ptr<RawPointer>(p,is_same<RawPointer,Pointer>());
|
||||
}
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
/* Copyright 2003-2016 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#define BOOST_MULTI_INDEX_DETAIL_RESTORE_WSTRICT_ALIASING
|
||||
#include <boost/multi_index/detail/ignore_wstrict_aliasing.hpp>
|
||||
#undef BOOST_MULTI_INDEX_DETAIL_RESTORE_WSTRICT_ALIASING
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2018 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,16 +9,16 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_RND_INDEX_LOADER_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_RND_INDEX_LOADER_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <algorithm>
|
||||
#include <boost/multi_index/detail/allocator_traits.hpp>
|
||||
#include <boost/multi_index/detail/auto_space.hpp>
|
||||
#include <boost/multi_index/detail/rnd_index_ptr_array.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost{
|
||||
|
||||
@@ -43,16 +43,10 @@ template<typename Allocator>
|
||||
class random_access_index_loader_base:private noncopyable
|
||||
{
|
||||
protected:
|
||||
typedef random_access_index_node_impl<
|
||||
typename rebind_alloc_for<
|
||||
Allocator,
|
||||
char
|
||||
>::type
|
||||
> node_impl_type;
|
||||
typedef typename node_impl_type::pointer node_impl_pointer;
|
||||
typedef random_access_index_ptr_array<Allocator> ptr_array;
|
||||
typedef random_access_index_node_impl node_type;
|
||||
typedef random_access_index_ptr_array<Allocator> ptr_array_type;
|
||||
|
||||
random_access_index_loader_base(const Allocator& al_,ptr_array& ptrs_):
|
||||
random_access_index_loader_base(const Allocator& al_,ptr_array_type& ptrs_):
|
||||
al(al_),
|
||||
ptrs(ptrs_),
|
||||
header(*ptrs.end()),
|
||||
@@ -64,14 +58,14 @@ protected:
|
||||
{
|
||||
if(preprocessed)
|
||||
{
|
||||
node_impl_pointer n=header;
|
||||
node_type* n=header;
|
||||
next(n)=n;
|
||||
|
||||
for(size_type i=ptrs.size();i--;){
|
||||
for(std::size_t i=ptrs.size();i--;){
|
||||
n=prev(n);
|
||||
size_type d=position(n);
|
||||
std::size_t d=position(n);
|
||||
if(d!=i){
|
||||
node_impl_pointer m=prev(next_at(i));
|
||||
node_type* m=prev(next_at(i));
|
||||
std::swap(m->up(),n->up());
|
||||
next_at(d)=next_at(i);
|
||||
std::swap(prev_at(d),prev_at(i));
|
||||
@@ -81,69 +75,65 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
void rearrange(node_impl_pointer position_,node_impl_pointer x)
|
||||
void rearrange(node_type* position,node_type *x)
|
||||
{
|
||||
preprocess(); /* only incur this penalty if rearrange() is ever called */
|
||||
if(position_==node_impl_pointer(0))position_=header;
|
||||
if(!position)position=header;
|
||||
next(prev(x))=next(x);
|
||||
prev(next(x))=prev(x);
|
||||
prev(x)=position_;
|
||||
next(x)=next(position_);
|
||||
prev(x)=position;
|
||||
next(x)=next(position);
|
||||
next(prev(x))=prev(next(x))=x;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef allocator_traits<Allocator> alloc_traits;
|
||||
typedef typename alloc_traits::size_type size_type;
|
||||
|
||||
void preprocess()
|
||||
{
|
||||
if(!preprocessed){
|
||||
/* get space for the auxiliary prev array */
|
||||
auto_space<node_impl_pointer,Allocator> tmp(al,ptrs.size()+1);
|
||||
auto_space<node_type*,Allocator> tmp(al,ptrs.size()+1);
|
||||
prev_spc.swap(tmp);
|
||||
|
||||
/* prev_spc elements point to the prev nodes */
|
||||
std::rotate_copy(
|
||||
&*ptrs.begin(),&*ptrs.end(),&*ptrs.end()+1,&*prev_spc.data());
|
||||
std::rotate_copy(ptrs.begin(),ptrs.end(),ptrs.end()+1,prev_spc.data());
|
||||
|
||||
/* ptrs elements point to the next nodes */
|
||||
std::rotate(&*ptrs.begin(),&*ptrs.begin()+1,&*ptrs.end()+1);
|
||||
std::rotate(ptrs.begin(),ptrs.begin()+1,ptrs.end()+1);
|
||||
|
||||
preprocessed=true;
|
||||
}
|
||||
}
|
||||
|
||||
size_type position(node_impl_pointer x)const
|
||||
std::size_t position(node_type* x)const
|
||||
{
|
||||
return (size_type)(x->up()-ptrs.begin());
|
||||
return (std::size_t)(x->up()-ptrs.begin());
|
||||
}
|
||||
|
||||
node_impl_pointer& next_at(size_type n)const
|
||||
node_type*& next_at(std::size_t n)const
|
||||
{
|
||||
return *ptrs.at(n);
|
||||
}
|
||||
|
||||
node_impl_pointer& prev_at(size_type n)const
|
||||
node_type*& prev_at(std::size_t n)const
|
||||
{
|
||||
return *(prev_spc.data()+n);
|
||||
return prev_spc.data()[n];
|
||||
}
|
||||
|
||||
node_impl_pointer& next(node_impl_pointer x)const
|
||||
node_type*& next(node_type* x)const
|
||||
{
|
||||
return *(x->up());
|
||||
}
|
||||
|
||||
node_impl_pointer& prev(node_impl_pointer x)const
|
||||
node_type*& prev(node_type* x)const
|
||||
{
|
||||
return prev_at(position(x));
|
||||
}
|
||||
|
||||
Allocator al;
|
||||
ptr_array& ptrs;
|
||||
node_impl_pointer header;
|
||||
auto_space<node_impl_pointer,Allocator> prev_spc;
|
||||
bool preprocessed;
|
||||
Allocator al;
|
||||
ptr_array_type& ptrs;
|
||||
node_type* header;
|
||||
auto_space<node_type*,Allocator> prev_spc;
|
||||
bool preprocessed;
|
||||
};
|
||||
|
||||
template<typename Node,typename Allocator>
|
||||
@@ -151,18 +141,16 @@ class random_access_index_loader:
|
||||
private random_access_index_loader_base<Allocator>
|
||||
{
|
||||
typedef random_access_index_loader_base<Allocator> super;
|
||||
typedef typename super::node_impl_pointer node_impl_pointer;
|
||||
typedef typename super::ptr_array ptr_array;
|
||||
typedef typename super::ptr_array_type ptr_array_type;
|
||||
|
||||
public:
|
||||
random_access_index_loader(const Allocator& al_,ptr_array& ptrs_):
|
||||
random_access_index_loader(const Allocator& al_,ptr_array_type& ptrs_):
|
||||
super(al_,ptrs_)
|
||||
{}
|
||||
|
||||
void rearrange(Node* position_,Node *x)
|
||||
void rearrange(Node* position,Node *x)
|
||||
{
|
||||
super::rearrange(
|
||||
position_?position_->impl():node_impl_pointer(0),x->impl());
|
||||
super::rearrange(position?position->impl():0,x->impl());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2018 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,15 +9,13 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_RND_INDEX_NODE_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_RND_INDEX_NODE_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <algorithm>
|
||||
#include <boost/integer/common_factor_rt.hpp>
|
||||
#include <boost/multi_index/detail/allocator_traits.hpp>
|
||||
#include <boost/multi_index/detail/raw_ptr.hpp>
|
||||
#include <boost/math/common_factor_rt.hpp>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
|
||||
@@ -27,52 +25,42 @@ namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
template<typename Allocator>
|
||||
struct random_access_index_node_impl
|
||||
{
|
||||
typedef typename rebind_alloc_for<
|
||||
Allocator,random_access_index_node_impl
|
||||
>::type node_allocator;
|
||||
typedef allocator_traits<node_allocator> node_alloc_traits;
|
||||
typedef typename node_alloc_traits::pointer pointer;
|
||||
typedef typename node_alloc_traits::const_pointer const_pointer;
|
||||
typedef typename node_alloc_traits::difference_type difference_type;
|
||||
typedef typename rebind_alloc_for<
|
||||
Allocator,pointer
|
||||
>::type ptr_allocator;
|
||||
typedef allocator_traits<ptr_allocator> ptr_alloc_traits;
|
||||
typedef typename ptr_alloc_traits::pointer ptr_pointer;
|
||||
|
||||
ptr_pointer& up(){return up_;}
|
||||
ptr_pointer up()const{return up_;}
|
||||
random_access_index_node_impl**& up(){return up_;}
|
||||
random_access_index_node_impl** up()const{return up_;}
|
||||
|
||||
/* interoperability with rnd_node_iterator */
|
||||
|
||||
static void increment(pointer& x)
|
||||
static void increment(random_access_index_node_impl*& x)
|
||||
{
|
||||
x=*(x->up()+1);
|
||||
}
|
||||
|
||||
static void decrement(pointer& x)
|
||||
static void decrement(random_access_index_node_impl*& x)
|
||||
{
|
||||
x=*(x->up()-1);
|
||||
}
|
||||
|
||||
static void advance(pointer& x,difference_type n)
|
||||
static void advance(
|
||||
random_access_index_node_impl*& x,std::ptrdiff_t n)
|
||||
{
|
||||
x=*(x->up()+n);
|
||||
}
|
||||
|
||||
static difference_type distance(pointer x,pointer y)
|
||||
static std::ptrdiff_t distance(
|
||||
random_access_index_node_impl* x,random_access_index_node_impl* y)
|
||||
{
|
||||
return static_cast<difference_type>(y->up()-x->up());
|
||||
return y->up()-x->up();
|
||||
}
|
||||
|
||||
/* algorithmic stuff */
|
||||
|
||||
static void relocate(ptr_pointer pos,ptr_pointer x)
|
||||
static void relocate(
|
||||
random_access_index_node_impl** pos,
|
||||
random_access_index_node_impl** x)
|
||||
{
|
||||
pointer n=*x;
|
||||
random_access_index_node_impl* n=*x;
|
||||
if(x<pos){
|
||||
extract(x,pos);
|
||||
*(pos-1)=n;
|
||||
@@ -89,9 +77,12 @@ struct random_access_index_node_impl
|
||||
}
|
||||
};
|
||||
|
||||
static void relocate(ptr_pointer pos,ptr_pointer first,ptr_pointer last)
|
||||
static void relocate(
|
||||
random_access_index_node_impl** pos,
|
||||
random_access_index_node_impl** first,
|
||||
random_access_index_node_impl** last)
|
||||
{
|
||||
ptr_pointer begin,middle,end;
|
||||
random_access_index_node_impl** begin,**middle,**end;
|
||||
if(pos<first){
|
||||
begin=pos;
|
||||
middle=first;
|
||||
@@ -106,39 +97,41 @@ struct random_access_index_node_impl
|
||||
std::ptrdiff_t n=end-begin;
|
||||
std::ptrdiff_t m=middle-begin;
|
||||
std::ptrdiff_t n_m=n-m;
|
||||
std::ptrdiff_t p=integer::gcd(n,m);
|
||||
std::ptrdiff_t p=math::gcd(n,m);
|
||||
|
||||
for(std::ptrdiff_t i=0;i<p;++i){
|
||||
pointer tmp=begin[i];
|
||||
random_access_index_node_impl* tmp=begin[i];
|
||||
for(std::ptrdiff_t j=i,k;;){
|
||||
if(j<n_m)k=j+m;
|
||||
else k=j-n_m;
|
||||
if(k==i){
|
||||
*(begin+j)=tmp;
|
||||
(*(begin+j))->up()=begin+j;
|
||||
begin[j]=tmp;
|
||||
begin[j]->up()=&begin[j];
|
||||
break;
|
||||
}
|
||||
else{
|
||||
*(begin+j)=*(begin+k);
|
||||
(*(begin+j))->up()=begin+j;
|
||||
begin[j]=begin[k];
|
||||
begin[j]->up()=&begin[j];
|
||||
}
|
||||
|
||||
if(k<n_m)j=k+m;
|
||||
else j=k-n_m;
|
||||
if(j==i){
|
||||
*(begin+k)=tmp;
|
||||
(*(begin+k))->up()=begin+k;
|
||||
begin[k]=tmp;
|
||||
begin[k]->up()=&begin[k];
|
||||
break;
|
||||
}
|
||||
else{
|
||||
*(begin+k)=*(begin+j);
|
||||
(*(begin+k))->up()=begin+k;
|
||||
begin[k]=begin[j];
|
||||
begin[k]->up()=&begin[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static void extract(ptr_pointer x,ptr_pointer pend)
|
||||
static void extract(
|
||||
random_access_index_node_impl** x,
|
||||
random_access_index_node_impl** pend)
|
||||
{
|
||||
--pend;
|
||||
while(x!=pend){
|
||||
@@ -149,7 +142,9 @@ struct random_access_index_node_impl
|
||||
}
|
||||
|
||||
static void transfer(
|
||||
ptr_pointer pbegin0,ptr_pointer pend0,ptr_pointer pbegin1)
|
||||
random_access_index_node_impl** pbegin0,
|
||||
random_access_index_node_impl** pend0,
|
||||
random_access_index_node_impl** pbegin1)
|
||||
{
|
||||
while(pbegin0!=pend0){
|
||||
*pbegin1=*pbegin0++;
|
||||
@@ -158,7 +153,9 @@ struct random_access_index_node_impl
|
||||
}
|
||||
}
|
||||
|
||||
static void reverse(ptr_pointer pbegin,ptr_pointer pend)
|
||||
static void reverse(
|
||||
random_access_index_node_impl** pbegin,
|
||||
random_access_index_node_impl** pend)
|
||||
{
|
||||
std::ptrdiff_t d=(pend-pbegin)/2;
|
||||
for(std::ptrdiff_t i=0;i<d;++i){
|
||||
@@ -170,99 +167,68 @@ struct random_access_index_node_impl
|
||||
}
|
||||
|
||||
private:
|
||||
ptr_pointer up_;
|
||||
random_access_index_node_impl** up_;
|
||||
};
|
||||
|
||||
template<typename Super>
|
||||
struct random_access_index_node_trampoline:
|
||||
random_access_index_node_impl<
|
||||
typename rebind_alloc_for<
|
||||
typename Super::allocator_type,
|
||||
char
|
||||
>::type
|
||||
>
|
||||
{
|
||||
typedef random_access_index_node_impl<
|
||||
typename rebind_alloc_for<
|
||||
typename Super::allocator_type,
|
||||
char
|
||||
>::type
|
||||
> impl_type;
|
||||
};
|
||||
struct random_access_index_node_trampoline:random_access_index_node_impl{};
|
||||
|
||||
template<typename Super>
|
||||
struct random_access_index_node:
|
||||
Super,random_access_index_node_trampoline<Super>
|
||||
{
|
||||
private:
|
||||
typedef random_access_index_node_trampoline<Super> trampoline;
|
||||
random_access_index_node_impl**& up(){return impl_type::up();}
|
||||
random_access_index_node_impl** up()const{return impl_type::up();}
|
||||
|
||||
public:
|
||||
typedef typename trampoline::impl_type impl_type;
|
||||
typedef typename trampoline::pointer impl_pointer;
|
||||
typedef typename trampoline::const_pointer const_impl_pointer;
|
||||
typedef typename trampoline::difference_type difference_type;
|
||||
typedef typename trampoline::ptr_pointer impl_ptr_pointer;
|
||||
random_access_index_node_impl* impl()
|
||||
{return static_cast<impl_type*>(this);}
|
||||
const random_access_index_node_impl* impl()const
|
||||
{return static_cast<const impl_type*>(this);}
|
||||
|
||||
impl_ptr_pointer& up(){return trampoline::up();}
|
||||
impl_ptr_pointer up()const{return trampoline::up();}
|
||||
|
||||
impl_pointer impl()
|
||||
static random_access_index_node* from_impl(random_access_index_node_impl *x)
|
||||
{
|
||||
return static_cast<impl_pointer>(
|
||||
static_cast<impl_type*>(static_cast<trampoline*>(this)));
|
||||
return static_cast<random_access_index_node*>(
|
||||
static_cast<impl_type*>(x));
|
||||
}
|
||||
|
||||
const_impl_pointer impl()const
|
||||
static const random_access_index_node* from_impl(
|
||||
const random_access_index_node_impl* x)
|
||||
{
|
||||
return static_cast<const_impl_pointer>(
|
||||
static_cast<const impl_type*>(static_cast<const trampoline*>(this)));
|
||||
}
|
||||
|
||||
static random_access_index_node* from_impl(impl_pointer x)
|
||||
{
|
||||
return
|
||||
static_cast<random_access_index_node*>(
|
||||
static_cast<trampoline*>(
|
||||
raw_ptr<impl_type*>(x)));
|
||||
}
|
||||
|
||||
static const random_access_index_node* from_impl(const_impl_pointer x)
|
||||
{
|
||||
return
|
||||
static_cast<const random_access_index_node*>(
|
||||
static_cast<const trampoline*>(
|
||||
raw_ptr<const impl_type*>(x)));
|
||||
return static_cast<const random_access_index_node*>(
|
||||
static_cast<const impl_type*>(x));
|
||||
}
|
||||
|
||||
/* interoperability with rnd_node_iterator */
|
||||
|
||||
static void increment(random_access_index_node*& x)
|
||||
{
|
||||
impl_pointer xi=x->impl();
|
||||
trampoline::increment(xi);
|
||||
random_access_index_node_impl* xi=x->impl();
|
||||
impl_type::increment(xi);
|
||||
x=from_impl(xi);
|
||||
}
|
||||
|
||||
static void decrement(random_access_index_node*& x)
|
||||
{
|
||||
impl_pointer xi=x->impl();
|
||||
trampoline::decrement(xi);
|
||||
random_access_index_node_impl* xi=x->impl();
|
||||
impl_type::decrement(xi);
|
||||
x=from_impl(xi);
|
||||
}
|
||||
|
||||
static void advance(random_access_index_node*& x,difference_type n)
|
||||
static void advance(random_access_index_node*& x,std::ptrdiff_t n)
|
||||
{
|
||||
impl_pointer xi=x->impl();
|
||||
trampoline::advance(xi,n);
|
||||
random_access_index_node_impl* xi=x->impl();
|
||||
impl_type::advance(xi,n);
|
||||
x=from_impl(xi);
|
||||
}
|
||||
|
||||
static difference_type distance(
|
||||
static std::ptrdiff_t distance(
|
||||
random_access_index_node* x,random_access_index_node* y)
|
||||
{
|
||||
return trampoline::distance(x->impl(),y->impl());
|
||||
return impl_type::distance(x->impl(),y->impl());
|
||||
}
|
||||
|
||||
private:
|
||||
typedef random_access_index_node_trampoline<Super> impl_type;
|
||||
};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2015 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,13 +9,14 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_RND_INDEX_OPS_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_RND_INDEX_OPS_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <algorithm>
|
||||
#include <boost/multi_index/detail/rnd_index_ptr_array.hpp>
|
||||
#include <functional>
|
||||
|
||||
namespace boost{
|
||||
|
||||
@@ -29,14 +30,14 @@ namespace detail{
|
||||
|
||||
template<typename Node,typename Allocator,typename Predicate>
|
||||
Node* random_access_index_remove(
|
||||
random_access_index_ptr_array<Allocator>& ptrs,Predicate pred)
|
||||
random_access_index_ptr_array<Allocator>& ptrs,Predicate pred
|
||||
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Node))
|
||||
{
|
||||
typedef typename Node::value_type value_type;
|
||||
typedef typename Node::impl_ptr_pointer impl_ptr_pointer;
|
||||
|
||||
impl_ptr_pointer first=ptrs.begin(),
|
||||
res=first,
|
||||
last=ptrs.end();
|
||||
random_access_index_node_impl** first=ptrs.begin(),
|
||||
** res=first,
|
||||
** last=ptrs.end();
|
||||
for(;first!=last;++first){
|
||||
if(!pred(
|
||||
const_cast<const value_type&>(Node::from_impl(*first)->value()))){
|
||||
@@ -53,14 +54,14 @@ Node* random_access_index_remove(
|
||||
|
||||
template<typename Node,typename Allocator,class BinaryPredicate>
|
||||
Node* random_access_index_unique(
|
||||
random_access_index_ptr_array<Allocator>& ptrs,BinaryPredicate binary_pred)
|
||||
random_access_index_ptr_array<Allocator>& ptrs,BinaryPredicate binary_pred
|
||||
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Node))
|
||||
{
|
||||
typedef typename Node::value_type value_type;
|
||||
typedef typename Node::impl_ptr_pointer impl_ptr_pointer;
|
||||
typedef typename Node::value_type value_type;
|
||||
|
||||
impl_ptr_pointer first=ptrs.begin(),
|
||||
res=first,
|
||||
last=ptrs.end();
|
||||
random_access_index_node_impl** first=ptrs.begin(),
|
||||
** res=first,
|
||||
** last=ptrs.end();
|
||||
if(first!=last){
|
||||
for(;++first!=last;){
|
||||
if(!binary_pred(
|
||||
@@ -83,18 +84,17 @@ template<typename Node,typename Allocator,typename Compare>
|
||||
void random_access_index_inplace_merge(
|
||||
const Allocator& al,
|
||||
random_access_index_ptr_array<Allocator>& ptrs,
|
||||
BOOST_DEDUCED_TYPENAME Node::impl_ptr_pointer first1,Compare comp)
|
||||
random_access_index_node_impl** first1,Compare comp
|
||||
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Node))
|
||||
{
|
||||
typedef typename Node::value_type value_type;
|
||||
typedef typename Node::impl_pointer impl_pointer;
|
||||
typedef typename Node::impl_ptr_pointer impl_ptr_pointer;
|
||||
typedef typename Node::value_type value_type;
|
||||
|
||||
auto_space<impl_pointer,Allocator> spc(al,ptrs.size());
|
||||
auto_space<random_access_index_node_impl*,Allocator> spc(al,ptrs.size());
|
||||
|
||||
impl_ptr_pointer first0=ptrs.begin(),
|
||||
last0=first1,
|
||||
last1=ptrs.end(),
|
||||
out=spc.data();
|
||||
random_access_index_node_impl** first0=ptrs.begin(),
|
||||
** last0=first1,
|
||||
** last1=ptrs.end(),
|
||||
** out=spc.data();
|
||||
while(first0!=last0&&first1!=last1){
|
||||
if(comp(
|
||||
const_cast<const value_type&>(Node::from_impl(*first1)->value()),
|
||||
@@ -105,8 +105,8 @@ void random_access_index_inplace_merge(
|
||||
*out++=*first0++;
|
||||
}
|
||||
}
|
||||
std::copy(&*first0,&*last0,&*out);
|
||||
std::copy(&*first1,&*last1,&*out);
|
||||
std::copy(first0,last0,out);
|
||||
std::copy(first1,last1,out);
|
||||
|
||||
first1=ptrs.begin();
|
||||
out=spc.data();
|
||||
@@ -122,16 +122,15 @@ void random_access_index_inplace_merge(
|
||||
/* auxiliary stuff */
|
||||
|
||||
template<typename Node,typename Compare>
|
||||
struct random_access_index_sort_compare
|
||||
struct random_access_index_sort_compare:
|
||||
std::binary_function<
|
||||
const typename Node::value_type*,const typename Node::value_type*,bool>
|
||||
{
|
||||
typedef typename Node::impl_pointer first_argument_type;
|
||||
typedef typename Node::impl_pointer second_argument_type;
|
||||
typedef bool result_type;
|
||||
|
||||
random_access_index_sort_compare(Compare comp_=Compare()):comp(comp_){}
|
||||
|
||||
bool operator()(
|
||||
typename Node::impl_pointer x,typename Node::impl_pointer y)const
|
||||
random_access_index_node_impl* x,
|
||||
random_access_index_node_impl* y)const
|
||||
{
|
||||
typedef typename Node::value_type value_type;
|
||||
|
||||
@@ -148,7 +147,8 @@ template<typename Node,typename Allocator,class Compare>
|
||||
void random_access_index_sort(
|
||||
const Allocator& al,
|
||||
random_access_index_ptr_array<Allocator>& ptrs,
|
||||
Compare comp)
|
||||
Compare comp
|
||||
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Node))
|
||||
{
|
||||
/* The implementation is extremely simple: an auxiliary
|
||||
* array of pointers is sorted using stdlib facilities and
|
||||
@@ -170,22 +170,19 @@ void random_access_index_sort(
|
||||
* solution adopted.
|
||||
*/
|
||||
|
||||
if(ptrs.size()<=1)return;
|
||||
|
||||
typedef typename Node::impl_pointer impl_pointer;
|
||||
typedef typename Node::impl_ptr_pointer impl_ptr_pointer;
|
||||
typedef typename Node::value_type value_type;
|
||||
typedef random_access_index_sort_compare<
|
||||
Node,Compare> ptr_compare;
|
||||
|
||||
impl_ptr_pointer first=ptrs.begin();
|
||||
impl_ptr_pointer last=ptrs.end();
|
||||
random_access_index_node_impl** first=ptrs.begin();
|
||||
random_access_index_node_impl** last=ptrs.end();
|
||||
auto_space<
|
||||
impl_pointer,
|
||||
Allocator> spc(al,ptrs.size());
|
||||
impl_ptr_pointer buf=spc.data();
|
||||
random_access_index_node_impl*,
|
||||
Allocator> spc(al,ptrs.size());
|
||||
random_access_index_node_impl** buf=spc.data();
|
||||
|
||||
std::copy(&*first,&*last,&*buf);
|
||||
std::stable_sort(&*buf,&*buf+ptrs.size(),ptr_compare(comp));
|
||||
std::copy(first,last,buf);
|
||||
std::stable_sort(buf,buf+ptrs.size(),ptr_compare(comp));
|
||||
|
||||
while(first!=last){
|
||||
*first=*buf++;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,16 +9,16 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_RND_INDEX_PTR_ARRAY_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_RND_INDEX_PTR_ARRAY_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <algorithm>
|
||||
#include <boost/multi_index/detail/allocator_traits.hpp>
|
||||
#include <boost/multi_index/detail/auto_space.hpp>
|
||||
#include <boost/multi_index/detail/rnd_index_node.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost{
|
||||
|
||||
@@ -31,34 +31,21 @@ namespace detail{
|
||||
template<typename Allocator>
|
||||
class random_access_index_ptr_array:private noncopyable
|
||||
{
|
||||
typedef random_access_index_node_impl<
|
||||
typename rebind_alloc_for<
|
||||
Allocator,
|
||||
char
|
||||
>::type
|
||||
> node_impl_type;
|
||||
|
||||
public:
|
||||
typedef typename node_impl_type::pointer value_type;
|
||||
typedef typename rebind_alloc_for<
|
||||
Allocator,value_type
|
||||
>::type value_allocator;
|
||||
typedef allocator_traits<value_allocator> alloc_traits;
|
||||
typedef typename alloc_traits::pointer pointer;
|
||||
typedef typename alloc_traits::size_type size_type;
|
||||
typedef random_access_index_node_impl* value_type;
|
||||
|
||||
random_access_index_ptr_array(
|
||||
const Allocator& al,value_type end_,size_type sz):
|
||||
size_(sz),
|
||||
capacity_(sz),
|
||||
const Allocator& al,value_type end_,std::size_t size):
|
||||
size_(size),
|
||||
capacity_(size),
|
||||
spc(al,capacity_+1)
|
||||
{
|
||||
*end()=end_;
|
||||
end_->up()=end();
|
||||
}
|
||||
|
||||
size_type size()const{return size_;}
|
||||
size_type capacity()const{return capacity_;}
|
||||
std::size_t size()const{return size_;}
|
||||
std::size_t capacity()const{return capacity_;}
|
||||
|
||||
void room_for_one()
|
||||
{
|
||||
@@ -67,19 +54,19 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void reserve(size_type c)
|
||||
void reserve(std::size_t c)
|
||||
{
|
||||
if(c>capacity_)set_capacity(c);
|
||||
if(c>capacity_){
|
||||
auto_space<value_type,Allocator> spc1(spc.get_allocator(),c+1);
|
||||
random_access_index_node_impl::transfer(begin(),end()+1,spc1.data());
|
||||
spc.swap(spc1);
|
||||
capacity_=c;
|
||||
}
|
||||
}
|
||||
|
||||
void shrink_to_fit()
|
||||
{
|
||||
if(capacity_>size_)set_capacity(size_);
|
||||
}
|
||||
|
||||
pointer begin()const{return ptrs();}
|
||||
pointer end()const{return ptrs()+size_;}
|
||||
pointer at(size_type n)const{return ptrs()+n;}
|
||||
value_type* begin()const{return &ptrs()[0];}
|
||||
value_type* end()const{return &ptrs()[size_];}
|
||||
value_type* at(std::size_t n)const{return &ptrs()[n];}
|
||||
|
||||
void push_back(value_type x)
|
||||
{
|
||||
@@ -92,7 +79,7 @@ public:
|
||||
|
||||
void erase(value_type x)
|
||||
{
|
||||
node_impl_type::extract(x->up(),end()+1);
|
||||
random_access_index_node_impl::extract(x->up(),end()+1);
|
||||
--size_;
|
||||
}
|
||||
|
||||
@@ -110,31 +97,15 @@ public:
|
||||
spc.swap(x.spc);
|
||||
}
|
||||
|
||||
template<typename BoolConstant>
|
||||
void swap(random_access_index_ptr_array& x,BoolConstant swap_allocators)
|
||||
{
|
||||
std::swap(size_,x.size_);
|
||||
std::swap(capacity_,x.capacity_);
|
||||
spc.swap(x.spc,swap_allocators);
|
||||
}
|
||||
|
||||
private:
|
||||
size_type size_;
|
||||
size_type capacity_;
|
||||
std::size_t size_;
|
||||
std::size_t capacity_;
|
||||
auto_space<value_type,Allocator> spc;
|
||||
|
||||
pointer ptrs()const
|
||||
value_type* ptrs()const
|
||||
{
|
||||
return spc.data();
|
||||
}
|
||||
|
||||
void set_capacity(size_type c)
|
||||
{
|
||||
auto_space<value_type,Allocator> spc1(spc.get_allocator(),c+1);
|
||||
node_impl_type::transfer(begin(),end()+1,spc1.data());
|
||||
spc.swap(spc1);
|
||||
capacity_=c;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Allocator>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2018 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_RND_NODE_ITERATOR_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_RND_NODE_ITERATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -29,17 +29,16 @@ namespace detail{
|
||||
|
||||
/* Iterator class for node-based indices with random access iterators. */
|
||||
|
||||
template<typename Node>
|
||||
template<typename Node,typename Derived=mpl::na>
|
||||
class rnd_node_iterator:
|
||||
public random_access_iterator_helper<
|
||||
rnd_node_iterator<Node>,
|
||||
rnd_node_iterator<Node,Derived>,
|
||||
typename Node::value_type,
|
||||
typename Node::difference_type,
|
||||
std::ptrdiff_t,
|
||||
const typename Node::value_type*,
|
||||
const typename Node::value_type&>
|
||||
{
|
||||
public:
|
||||
/* coverity[uninit_ctor]: suppress warning */
|
||||
rnd_node_iterator(){}
|
||||
explicit rnd_node_iterator(Node* node_):node(node_){}
|
||||
|
||||
@@ -48,6 +47,18 @@ public:
|
||||
return node->value();
|
||||
}
|
||||
|
||||
friend bool operator==(
|
||||
const rnd_node_iterator& x,const rnd_node_iterator& y)
|
||||
{
|
||||
return x.node==y.node;
|
||||
}
|
||||
|
||||
friend bool operator<(
|
||||
const rnd_node_iterator& x,const rnd_node_iterator& y)
|
||||
{
|
||||
return Node::distance(x.node,y.node)>0;
|
||||
}
|
||||
|
||||
rnd_node_iterator& operator++()
|
||||
{
|
||||
Node::increment(node);
|
||||
@@ -60,18 +71,24 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
rnd_node_iterator& operator+=(typename Node::difference_type n)
|
||||
rnd_node_iterator& operator+=(std::ptrdiff_t n)
|
||||
{
|
||||
Node::advance(node,n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
rnd_node_iterator& operator-=(typename Node::difference_type n)
|
||||
rnd_node_iterator& operator-=(std::ptrdiff_t n)
|
||||
{
|
||||
Node::advance(node,-n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend std::ptrdiff_t operator-(
|
||||
const rnd_node_iterator& x,const rnd_node_iterator& y)
|
||||
{
|
||||
return Node::distance(y.node,x.node);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
|
||||
/* Serialization. As for why the following is public,
|
||||
* see explanation in safe_mode_iterator notes in safe_mode.hpp.
|
||||
@@ -107,30 +124,6 @@ private:
|
||||
Node* node;
|
||||
};
|
||||
|
||||
template<typename Node>
|
||||
bool operator==(
|
||||
const rnd_node_iterator<Node>& x,
|
||||
const rnd_node_iterator<Node>& y)
|
||||
{
|
||||
return x.get_node()==y.get_node();
|
||||
}
|
||||
|
||||
template<typename Node>
|
||||
bool operator<(
|
||||
const rnd_node_iterator<Node>& x,
|
||||
const rnd_node_iterator<Node>& y)
|
||||
{
|
||||
return Node::distance(x.get_node(),y.get_node())>0;
|
||||
}
|
||||
|
||||
template<typename Node>
|
||||
typename Node::difference_type operator-(
|
||||
const rnd_node_iterator<Node>& x,
|
||||
const rnd_node_iterator<Node>& y)
|
||||
{
|
||||
return Node::distance(y.get_node(),x.get_node());
|
||||
}
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
@@ -1,325 +0,0 @@
|
||||
/* Copyright 2003-2018 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_RNK_INDEX_OPS_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_RNK_INDEX_OPS_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/multi_index/detail/promotes_arg.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
/* Common code for ranked_index memfuns having templatized and
|
||||
* non-templatized versions.
|
||||
*/
|
||||
|
||||
template<typename Pointer>
|
||||
struct ranked_node_size_type
|
||||
{
|
||||
typedef typename boost::pointer_traits<Pointer>::
|
||||
element_type::size_type type;
|
||||
};
|
||||
|
||||
template<typename Pointer>
|
||||
inline typename ranked_node_size_type<Pointer>::type
|
||||
ranked_node_size(Pointer x)
|
||||
{
|
||||
return x!=Pointer(0)?x->size:0;
|
||||
}
|
||||
|
||||
template<typename Pointer>
|
||||
inline Pointer ranked_index_nth(
|
||||
BOOST_DEDUCED_TYPENAME ranked_node_size_type<Pointer>::type n,Pointer end_)
|
||||
{
|
||||
typedef typename ranked_node_size_type<Pointer>::type size_type;
|
||||
|
||||
Pointer top=end_->parent();
|
||||
if(top==Pointer(0)||n>=top->size)return end_;
|
||||
|
||||
for(;;){
|
||||
size_type s=ranked_node_size(top->left());
|
||||
if(n==s)return top;
|
||||
if(n<s)top=top->left();
|
||||
else{
|
||||
top=top->right();
|
||||
n-=s+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Pointer>
|
||||
inline typename ranked_node_size_type<Pointer>::type
|
||||
ranked_index_rank(Pointer x,Pointer end_)
|
||||
{
|
||||
typedef typename ranked_node_size_type<Pointer>::type size_type;
|
||||
|
||||
Pointer top=end_->parent();
|
||||
if(top==Pointer(0))return 0;
|
||||
if(x==end_)return top->size;
|
||||
|
||||
size_type s=ranked_node_size(x->left());
|
||||
while(x!=top){
|
||||
Pointer z=x->parent();
|
||||
if(x==z->right()){
|
||||
s+=ranked_node_size(z->left())+1;
|
||||
}
|
||||
x=z;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline typename Node::size_type ranked_index_find_rank(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp)
|
||||
{
|
||||
typedef typename KeyFromValue::result_type key_type;
|
||||
|
||||
return ranked_index_find_rank(
|
||||
top,y,key,x,comp,
|
||||
mpl::and_<
|
||||
promotes_1st_arg<CompatibleCompare,CompatibleKey,key_type>,
|
||||
promotes_2nd_arg<CompatibleCompare,key_type,CompatibleKey> >());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleCompare
|
||||
>
|
||||
inline typename Node::size_type ranked_index_find_rank(
|
||||
Node* top,Node* y,const KeyFromValue& key,
|
||||
const BOOST_DEDUCED_TYPENAME KeyFromValue::result_type& x,
|
||||
const CompatibleCompare& comp,mpl::true_)
|
||||
{
|
||||
return ranked_index_find_rank(top,y,key,x,comp,mpl::false_());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline typename Node::size_type ranked_index_find_rank(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp,mpl::false_)
|
||||
{
|
||||
typedef typename Node::size_type size_type;
|
||||
|
||||
if(!top)return 0;
|
||||
|
||||
size_type s=top->impl()->size,
|
||||
s0=s;
|
||||
Node* y0=y;
|
||||
|
||||
do{
|
||||
if(!comp(key(top->value()),x)){
|
||||
y=top;
|
||||
s-=ranked_node_size(y->right())+1;
|
||||
top=Node::from_impl(top->left());
|
||||
}
|
||||
else top=Node::from_impl(top->right());
|
||||
}while(top);
|
||||
|
||||
return (y==y0||comp(x,key(y->value())))?s0:s;
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline typename Node::size_type ranked_index_lower_bound_rank(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp)
|
||||
{
|
||||
typedef typename KeyFromValue::result_type key_type;
|
||||
|
||||
return ranked_index_lower_bound_rank(
|
||||
top,y,key,x,comp,
|
||||
promotes_2nd_arg<CompatibleCompare,key_type,CompatibleKey>());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleCompare
|
||||
>
|
||||
inline typename Node::size_type ranked_index_lower_bound_rank(
|
||||
Node* top,Node* y,const KeyFromValue& key,
|
||||
const BOOST_DEDUCED_TYPENAME KeyFromValue::result_type& x,
|
||||
const CompatibleCompare& comp,mpl::true_)
|
||||
{
|
||||
return ranked_index_lower_bound_rank(top,y,key,x,comp,mpl::false_());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline typename Node::size_type ranked_index_lower_bound_rank(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp,mpl::false_)
|
||||
{
|
||||
typedef typename Node::size_type size_type;
|
||||
|
||||
if(!top)return 0;
|
||||
|
||||
size_type s=top->impl()->size;
|
||||
|
||||
do{
|
||||
if(!comp(key(top->value()),x)){
|
||||
y=top;
|
||||
s-=ranked_node_size(y->right())+1;
|
||||
top=Node::from_impl(top->left());
|
||||
}
|
||||
else top=Node::from_impl(top->right());
|
||||
}while(top);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline typename Node::size_type ranked_index_upper_bound_rank(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp)
|
||||
{
|
||||
typedef typename KeyFromValue::result_type key_type;
|
||||
|
||||
return ranked_index_upper_bound_rank(
|
||||
top,y,key,x,comp,
|
||||
promotes_1st_arg<CompatibleCompare,CompatibleKey,key_type>());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleCompare
|
||||
>
|
||||
inline typename Node::size_type ranked_index_upper_bound_rank(
|
||||
Node* top,Node* y,const KeyFromValue& key,
|
||||
const BOOST_DEDUCED_TYPENAME KeyFromValue::result_type& x,
|
||||
const CompatibleCompare& comp,mpl::true_)
|
||||
{
|
||||
return ranked_index_upper_bound_rank(top,y,key,x,comp,mpl::false_());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline typename Node::size_type ranked_index_upper_bound_rank(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp,mpl::false_)
|
||||
{
|
||||
typedef typename Node::size_type size_type;
|
||||
|
||||
if(!top)return 0;
|
||||
|
||||
size_type s=top->impl()->size;
|
||||
|
||||
do{
|
||||
if(comp(x,key(top->value()))){
|
||||
y=top;
|
||||
s-=ranked_node_size(y->right())+1;
|
||||
top=Node::from_impl(top->left());
|
||||
}
|
||||
else top=Node::from_impl(top->right());
|
||||
}while(top);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline std::pair<typename Node::size_type,typename Node::size_type>
|
||||
ranked_index_equal_range_rank(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp)
|
||||
{
|
||||
typedef typename KeyFromValue::result_type key_type;
|
||||
|
||||
return ranked_index_equal_range_rank(
|
||||
top,y,key,x,comp,
|
||||
mpl::and_<
|
||||
promotes_1st_arg<CompatibleCompare,CompatibleKey,key_type>,
|
||||
promotes_2nd_arg<CompatibleCompare,key_type,CompatibleKey> >());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleCompare
|
||||
>
|
||||
inline std::pair<typename Node::size_type,typename Node::size_type>
|
||||
ranked_index_equal_range_rank(
|
||||
Node* top,Node* y,const KeyFromValue& key,
|
||||
const BOOST_DEDUCED_TYPENAME KeyFromValue::result_type& x,
|
||||
const CompatibleCompare& comp,mpl::true_)
|
||||
{
|
||||
return ranked_index_equal_range_rank(top,y,key,x,comp,mpl::false_());
|
||||
}
|
||||
|
||||
template<
|
||||
typename Node,typename KeyFromValue,
|
||||
typename CompatibleKey,typename CompatibleCompare
|
||||
>
|
||||
inline std::pair<typename Node::size_type,typename Node::size_type>
|
||||
ranked_index_equal_range_rank(
|
||||
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
|
||||
const CompatibleCompare& comp,mpl::false_)
|
||||
{
|
||||
typedef typename Node::size_type size_type;
|
||||
|
||||
if(!top)return std::pair<size_type,size_type>(0,0);
|
||||
|
||||
size_type s=top->impl()->size;
|
||||
|
||||
do{
|
||||
if(comp(key(top->value()),x)){
|
||||
top=Node::from_impl(top->right());
|
||||
}
|
||||
else if(comp(x,key(top->value()))){
|
||||
y=top;
|
||||
s-=ranked_node_size(y->right())+1;
|
||||
top=Node::from_impl(top->left());
|
||||
}
|
||||
else{
|
||||
return std::pair<size_type,size_type>(
|
||||
s-top->impl()->size+
|
||||
ranked_index_lower_bound_rank(
|
||||
Node::from_impl(top->left()),top,key,x,comp,mpl::false_()),
|
||||
s-ranked_node_size(top->right())+
|
||||
ranked_index_upper_bound_rank(
|
||||
Node::from_impl(top->right()),y,key,x,comp,mpl::false_()));
|
||||
}
|
||||
}while(top);
|
||||
|
||||
return std::pair<size_type,size_type>(s,s);
|
||||
}
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,105 @@
|
||||
/* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_SAFE_CTR_PROXY_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_SAFE_CTR_PROXY_HPP
|
||||
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
|
||||
#include <boost/multi_index/detail/safe_mode.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
/* A safe iterator is instantiated in the form
|
||||
* safe_iterator<Iterator,Container>: MSVC++ 6.0 has serious troubles with
|
||||
* the resulting symbols names, given that index names (which stand for
|
||||
* Container) are fairly long themselves. safe_ctr_proxy does not statically
|
||||
* depend on Container, and provides the necessary methods (begin and end) to
|
||||
* the safe mode framework via an abstract interface. With safe_ctr_proxy,
|
||||
* instead of deriving from safe_container<Container> the following base class
|
||||
* must be used:
|
||||
*
|
||||
* safe_ctr_proxy_impl<Iterator,Container>
|
||||
*
|
||||
* where Iterator is the type of the *unsafe* iterator being wrapped.
|
||||
* The corresponding safe iterator instantiation is then
|
||||
*
|
||||
* safe_iterator<Iterator,safe_ctr_proxy<Iterator> >,
|
||||
*
|
||||
* which does not include the name of Container.
|
||||
*/
|
||||
|
||||
template<typename Iterator>
|
||||
class safe_ctr_proxy:
|
||||
public safe_mode::safe_container<safe_ctr_proxy<Iterator> >
|
||||
{
|
||||
public:
|
||||
typedef safe_mode::safe_iterator<Iterator,safe_ctr_proxy> iterator;
|
||||
typedef iterator const_iterator;
|
||||
|
||||
iterator begin(){return begin_impl();}
|
||||
const_iterator begin()const{return begin_impl();}
|
||||
iterator end(){return end_impl();}
|
||||
const_iterator end()const{return end_impl();}
|
||||
|
||||
protected:
|
||||
virtual iterator begin_impl()=0;
|
||||
virtual const_iterator begin_impl()const=0;
|
||||
virtual iterator end_impl()=0;
|
||||
virtual const_iterator end_impl()const=0;
|
||||
};
|
||||
|
||||
template<typename Iterator,typename Container>
|
||||
class safe_ctr_proxy_impl:public safe_ctr_proxy<Iterator>
|
||||
{
|
||||
typedef safe_ctr_proxy<Iterator> super;
|
||||
typedef Container container_type;
|
||||
|
||||
public:
|
||||
typedef typename super::iterator iterator;
|
||||
typedef typename super::const_iterator const_iterator;
|
||||
|
||||
virtual iterator begin_impl(){return container().begin();}
|
||||
virtual const_iterator begin_impl()const{return container().begin();}
|
||||
virtual iterator end_impl(){return container().end();}
|
||||
virtual const_iterator end_impl()const{return container().end();}
|
||||
|
||||
private:
|
||||
container_type& container()
|
||||
{
|
||||
return *static_cast<container_type*>(this);
|
||||
}
|
||||
|
||||
const container_type& container()const
|
||||
{
|
||||
return *static_cast<const container_type*>(this);
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif /* workaround */
|
||||
|
||||
#endif /* BOOST_MULTI_INDEX_ENABLE_SAFE_MODE */
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_SAFE_MODE_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_SAFE_MODE_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -105,14 +105,10 @@
|
||||
safe_mode::check_different_container(cont0,cont1), \
|
||||
safe_mode::same_container);
|
||||
|
||||
#define BOOST_MULTI_INDEX_CHECK_EQUAL_ALLOCATORS(cont0,cont1) \
|
||||
BOOST_MULTI_INDEX_SAFE_MODE_ASSERT( \
|
||||
safe_mode::check_equal_allocators(cont0,cont1), \
|
||||
safe_mode::unequal_allocators);
|
||||
|
||||
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <algorithm>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/multi_index/detail/access_specifier.hpp>
|
||||
#include <boost/multi_index/detail/iter_adaptor.hpp>
|
||||
#include <boost/multi_index/safe_mode_errors.hpp>
|
||||
@@ -120,7 +116,6 @@
|
||||
|
||||
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
|
||||
#include <boost/serialization/split_member.hpp>
|
||||
#include <boost/serialization/version.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_THREADS)
|
||||
@@ -147,32 +142,32 @@ inline bool check_valid_iterator(const Iterator& it)
|
||||
template<typename Iterator>
|
||||
inline bool check_dereferenceable_iterator(const Iterator& it)
|
||||
{
|
||||
return (it.valid()&&it!=it.owner()->end())||it.unchecked();
|
||||
return it.valid()&&it!=it.owner()->end()||it.unchecked();
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
inline bool check_incrementable_iterator(const Iterator& it)
|
||||
{
|
||||
return (it.valid()&&it!=it.owner()->end())||it.unchecked();
|
||||
return it.valid()&&it!=it.owner()->end()||it.unchecked();
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
inline bool check_decrementable_iterator(const Iterator& it)
|
||||
{
|
||||
return (it.valid()&&it!=it.owner()->begin())||it.unchecked();
|
||||
return it.valid()&&it!=it.owner()->begin()||it.unchecked();
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
inline bool check_is_owner(
|
||||
const Iterator& it,const typename Iterator::container_type& cont)
|
||||
{
|
||||
return (it.valid()&&it.owner()==&cont)||it.unchecked();
|
||||
return it.valid()&&it.owner()==&cont||it.unchecked();
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
inline bool check_same_owner(const Iterator& it0,const Iterator& it1)
|
||||
{
|
||||
return (it0.valid()&&it1.valid()&&it0.owner()==it1.owner())||
|
||||
return it0.valid()&&it1.valid()&&it0.owner()==it1.owner()||
|
||||
it0.unchecked()||it1.unchecked();
|
||||
}
|
||||
|
||||
@@ -233,13 +228,6 @@ inline bool check_different_container(
|
||||
return &cont0!=&cont1;
|
||||
}
|
||||
|
||||
template<typename Container0,typename Container1>
|
||||
inline bool check_equal_allocators(
|
||||
const Container0& cont0,const Container1& cont1)
|
||||
{
|
||||
return cont0.get_allocator()==cont1.get_allocator();
|
||||
}
|
||||
|
||||
/* Invalidates all iterators equivalent to that given. Safe containers
|
||||
* must call this when deleting elements: the safe mode framework cannot
|
||||
* perform this operation automatically without outside help.
|
||||
@@ -249,21 +237,15 @@ template<typename Iterator>
|
||||
inline void detach_equivalent_iterators(Iterator& it)
|
||||
{
|
||||
if(it.valid()){
|
||||
{
|
||||
#if defined(BOOST_HAS_THREADS)
|
||||
boost::detail::lightweight_mutex::scoped_lock lock(it.cont->mutex);
|
||||
#endif
|
||||
|
||||
Iterator *prev_,*next_;
|
||||
for(
|
||||
prev_=static_cast<Iterator*>(&it.cont->header);
|
||||
(next_=static_cast<Iterator*>(prev_->next))!=0;){
|
||||
if(next_!=&it&&*next_==it){
|
||||
prev_->next=next_->next;
|
||||
next_->cont=0;
|
||||
}
|
||||
else prev_=next_;
|
||||
Iterator *prev_,*next_;
|
||||
for(
|
||||
prev_=static_cast<Iterator*>(&it.cont->header);
|
||||
(next_=static_cast<Iterator*>(prev_->next))!=0;){
|
||||
if(next_!=&it&&*next_==it){
|
||||
prev_->next=next_->next;
|
||||
next_->cont=0;
|
||||
}
|
||||
else prev_=next_;
|
||||
}
|
||||
it.detach();
|
||||
}
|
||||
@@ -441,7 +423,6 @@ public:
|
||||
safe_iterator(
|
||||
const T0& t0,const T1& t1,safe_container<container_type>* cont_):
|
||||
super(Iterator(t0,t1)),safe_super(cont_){}
|
||||
safe_iterator(const safe_iterator& x):super(x),safe_super(x){}
|
||||
|
||||
safe_iterator& operator=(const safe_iterator& x)
|
||||
{
|
||||
@@ -580,19 +561,6 @@ public:
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
|
||||
namespace serialization{
|
||||
template<typename Iterator,typename Container>
|
||||
struct version<
|
||||
boost::multi_index::safe_mode::safe_iterator<Iterator,Container>
|
||||
>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(
|
||||
int,value=boost::serialization::version<Iterator>::value);
|
||||
};
|
||||
} /* namespace serialization */
|
||||
#endif
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif /* BOOST_MULTI_INDEX_ENABLE_SAFE_MODE */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2020 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2005 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,13 +9,10 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_SCOPE_GUARD_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_SCOPE_GUARD_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
@@ -27,10 +24,12 @@ namespace detail{
|
||||
* ScopeGuard.h as defined in:
|
||||
* Alexandrescu, A., Marginean, P.:"Generic<Programming>: Change the Way You
|
||||
* Write Exception-Safe Code - Forever", C/C++ Users Jornal, Dec 2000,
|
||||
* http://www.drdobbs.com/184403758
|
||||
* http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/
|
||||
* with the following modifications:
|
||||
* - General pretty formatting (pretty to my taste at least.)
|
||||
* - Naming style changed to standard C++ library requirements.
|
||||
* - safe_execute does not feature a try-catch protection, so we can
|
||||
* use this even if BOOST_NO_EXCEPTIONS is defined.
|
||||
* - Added scope_guard_impl4 and obj_scope_guard_impl3, (Boost.MultiIndex
|
||||
* needs them). A better design would provide guards for many more
|
||||
* arguments through the Boost Preprocessor Library.
|
||||
@@ -43,18 +42,6 @@ namespace detail{
|
||||
*
|
||||
* NB: CodeWarrior Pro 8 seems to have problems looking up safe_execute
|
||||
* without an explicit qualification.
|
||||
*
|
||||
* We also define the following variants of the idiom:
|
||||
*
|
||||
* - make_guard_if_c<bool>( ... )
|
||||
* - make_guard_if<IntegralConstant>( ... )
|
||||
* - make_obj_guard_if_c<bool>( ... )
|
||||
* - make_obj_guard_if<IntegralConstant>( ... )
|
||||
* which may be used with a compile-time constant to yield
|
||||
* a "null_guard" if the boolean compile-time parameter is false,
|
||||
* or conversely, the guard is only constructed if the constant is true.
|
||||
* This is useful to avoid extra tagging, because the returned
|
||||
* null_guard can be optimzed comlpetely away by the compiler.
|
||||
*/
|
||||
|
||||
class scope_guard_impl_base
|
||||
@@ -78,13 +65,7 @@ protected:
|
||||
}
|
||||
|
||||
template<typename J>
|
||||
static void safe_execute(J& j){
|
||||
BOOST_TRY{
|
||||
if(!j.dismissed_)j.execute();
|
||||
}
|
||||
BOOST_CATCH(...){}
|
||||
BOOST_CATCH_END
|
||||
}
|
||||
static void safe_execute(J& j){if(!j.dismissed_)j.execute();}
|
||||
|
||||
mutable bool dismissed_;
|
||||
|
||||
@@ -94,35 +75,6 @@ private:
|
||||
|
||||
typedef const scope_guard_impl_base& scope_guard;
|
||||
|
||||
struct null_guard : public scope_guard_impl_base
|
||||
{
|
||||
template< class T1 >
|
||||
null_guard( const T1& )
|
||||
{ }
|
||||
|
||||
template< class T1, class T2 >
|
||||
null_guard( const T1&, const T2& )
|
||||
{ }
|
||||
|
||||
template< class T1, class T2, class T3 >
|
||||
null_guard( const T1&, const T2&, const T3& )
|
||||
{ }
|
||||
|
||||
template< class T1, class T2, class T3, class T4 >
|
||||
null_guard( const T1&, const T2&, const T3&, const T4& )
|
||||
{ }
|
||||
|
||||
template< class T1, class T2, class T3, class T4, class T5 >
|
||||
null_guard( const T1&, const T2&, const T3&, const T4&, const T5& )
|
||||
{ }
|
||||
};
|
||||
|
||||
template< bool cond, class T >
|
||||
struct null_guard_return
|
||||
{
|
||||
typedef typename boost::mpl::if_c<cond,T,null_guard>::type type;
|
||||
};
|
||||
|
||||
template<typename F>
|
||||
class scope_guard_impl0:public scope_guard_impl_base
|
||||
{
|
||||
@@ -142,20 +94,6 @@ inline scope_guard_impl0<F> make_guard(F fun)
|
||||
return scope_guard_impl0<F>(fun);
|
||||
}
|
||||
|
||||
template<bool cond, typename F>
|
||||
inline typename null_guard_return<cond,scope_guard_impl0<F> >::type
|
||||
make_guard_if_c(F fun)
|
||||
{
|
||||
return typename null_guard_return<cond,scope_guard_impl0<F> >::type(fun);
|
||||
}
|
||||
|
||||
template<typename C, typename F>
|
||||
inline typename null_guard_return<C::value,scope_guard_impl0<F> >::type
|
||||
make_guard_if(F fun)
|
||||
{
|
||||
return make_guard_if<C::value>(fun);
|
||||
}
|
||||
|
||||
template<typename F,typename P1>
|
||||
class scope_guard_impl1:public scope_guard_impl_base
|
||||
{
|
||||
@@ -175,20 +113,6 @@ inline scope_guard_impl1<F,P1> make_guard(F fun,P1 p1)
|
||||
return scope_guard_impl1<F,P1>(fun,p1);
|
||||
}
|
||||
|
||||
template<bool cond, typename F,typename P1>
|
||||
inline typename null_guard_return<cond,scope_guard_impl1<F,P1> >::type
|
||||
make_guard_if_c(F fun,P1 p1)
|
||||
{
|
||||
return typename null_guard_return<cond,scope_guard_impl1<F,P1> >::type(fun,p1);
|
||||
}
|
||||
|
||||
template<typename C, typename F,typename P1>
|
||||
inline typename null_guard_return<C::value,scope_guard_impl1<F,P1> >::type
|
||||
make_guard_if(F fun,P1 p1)
|
||||
{
|
||||
return make_guard_if_c<C::value>(fun,p1);
|
||||
}
|
||||
|
||||
template<typename F,typename P1,typename P2>
|
||||
class scope_guard_impl2:public scope_guard_impl_base
|
||||
{
|
||||
@@ -209,20 +133,6 @@ inline scope_guard_impl2<F,P1,P2> make_guard(F fun,P1 p1,P2 p2)
|
||||
return scope_guard_impl2<F,P1,P2>(fun,p1,p2);
|
||||
}
|
||||
|
||||
template<bool cond, typename F,typename P1,typename P2>
|
||||
inline typename null_guard_return<cond,scope_guard_impl2<F,P1,P2> >::type
|
||||
make_guard_if_c(F fun,P1 p1,P2 p2)
|
||||
{
|
||||
return typename null_guard_return<cond,scope_guard_impl2<F,P1,P2> >::type(fun,p1,p2);
|
||||
}
|
||||
|
||||
template<typename C, typename F,typename P1,typename P2>
|
||||
inline typename null_guard_return<C::value,scope_guard_impl2<F,P1,P2> >::type
|
||||
make_guard_if(F fun,P1 p1,P2 p2)
|
||||
{
|
||||
return make_guard_if_c<C::value>(fun,p1,p2);
|
||||
}
|
||||
|
||||
template<typename F,typename P1,typename P2,typename P3>
|
||||
class scope_guard_impl3:public scope_guard_impl_base
|
||||
{
|
||||
@@ -244,20 +154,6 @@ inline scope_guard_impl3<F,P1,P2,P3> make_guard(F fun,P1 p1,P2 p2,P3 p3)
|
||||
return scope_guard_impl3<F,P1,P2,P3>(fun,p1,p2,p3);
|
||||
}
|
||||
|
||||
template<bool cond,typename F,typename P1,typename P2,typename P3>
|
||||
inline typename null_guard_return<cond,scope_guard_impl3<F,P1,P2,P3> >::type
|
||||
make_guard_if_c(F fun,P1 p1,P2 p2,P3 p3)
|
||||
{
|
||||
return typename null_guard_return<cond,scope_guard_impl3<F,P1,P2,P3> >::type(fun,p1,p2,p3);
|
||||
}
|
||||
|
||||
template<typename C,typename F,typename P1,typename P2,typename P3>
|
||||
inline typename null_guard_return< C::value,scope_guard_impl3<F,P1,P2,P3> >::type
|
||||
make_guard_if(F fun,P1 p1,P2 p2,P3 p3)
|
||||
{
|
||||
return make_guard_if_c<C::value>(fun,p1,p2,p3);
|
||||
}
|
||||
|
||||
template<typename F,typename P1,typename P2,typename P3,typename P4>
|
||||
class scope_guard_impl4:public scope_guard_impl_base
|
||||
{
|
||||
@@ -282,22 +178,6 @@ inline scope_guard_impl4<F,P1,P2,P3,P4> make_guard(
|
||||
return scope_guard_impl4<F,P1,P2,P3,P4>(fun,p1,p2,p3,p4);
|
||||
}
|
||||
|
||||
template<bool cond, typename F,typename P1,typename P2,typename P3,typename P4>
|
||||
inline typename null_guard_return<cond,scope_guard_impl4<F,P1,P2,P3,P4> >::type
|
||||
make_guard_if_c(
|
||||
F fun,P1 p1,P2 p2,P3 p3,P4 p4)
|
||||
{
|
||||
return typename null_guard_return<cond,scope_guard_impl4<F,P1,P2,P3,P4> >::type(fun,p1,p2,p3,p4);
|
||||
}
|
||||
|
||||
template<typename C, typename F,typename P1,typename P2,typename P3,typename P4>
|
||||
inline typename null_guard_return<C::value,scope_guard_impl4<F,P1,P2,P3,P4> >::type
|
||||
make_guard_if(
|
||||
F fun,P1 p1,P2 p2,P3 p3,P4 p4)
|
||||
{
|
||||
return make_guard_if_c<C::value>(fun,p1,p2,p3,p4);
|
||||
}
|
||||
|
||||
template<class Obj,typename MemFun>
|
||||
class obj_scope_guard_impl0:public scope_guard_impl_base
|
||||
{
|
||||
@@ -317,20 +197,6 @@ inline obj_scope_guard_impl0<Obj,MemFun> make_obj_guard(Obj& obj,MemFun mem_fun)
|
||||
return obj_scope_guard_impl0<Obj,MemFun>(obj,mem_fun);
|
||||
}
|
||||
|
||||
template<bool cond, class Obj,typename MemFun>
|
||||
inline typename null_guard_return<cond,obj_scope_guard_impl0<Obj,MemFun> >::type
|
||||
make_obj_guard_if_c(Obj& obj,MemFun mem_fun)
|
||||
{
|
||||
return typename null_guard_return<cond,obj_scope_guard_impl0<Obj,MemFun> >::type(obj,mem_fun);
|
||||
}
|
||||
|
||||
template<typename C, class Obj,typename MemFun>
|
||||
inline typename null_guard_return<C::value,obj_scope_guard_impl0<Obj,MemFun> >::type
|
||||
make_obj_guard_if(Obj& obj,MemFun mem_fun)
|
||||
{
|
||||
return make_obj_guard_if_c<C::value>(obj,mem_fun);
|
||||
}
|
||||
|
||||
template<class Obj,typename MemFun,typename P1>
|
||||
class obj_scope_guard_impl1:public scope_guard_impl_base
|
||||
{
|
||||
@@ -353,20 +219,6 @@ inline obj_scope_guard_impl1<Obj,MemFun,P1> make_obj_guard(
|
||||
return obj_scope_guard_impl1<Obj,MemFun,P1>(obj,mem_fun,p1);
|
||||
}
|
||||
|
||||
template<bool cond, class Obj,typename MemFun,typename P1>
|
||||
inline typename null_guard_return<cond,obj_scope_guard_impl1<Obj,MemFun,P1> >::type
|
||||
make_obj_guard_if_c( Obj& obj,MemFun mem_fun,P1 p1)
|
||||
{
|
||||
return typename null_guard_return<cond,obj_scope_guard_impl1<Obj,MemFun,P1> >::type(obj,mem_fun,p1);
|
||||
}
|
||||
|
||||
template<typename C, class Obj,typename MemFun,typename P1>
|
||||
inline typename null_guard_return<C::value,obj_scope_guard_impl1<Obj,MemFun,P1> >::type
|
||||
make_obj_guard_if( Obj& obj,MemFun mem_fun,P1 p1)
|
||||
{
|
||||
return make_obj_guard_if_c<C::value>(obj,mem_fun,p1);
|
||||
}
|
||||
|
||||
template<class Obj,typename MemFun,typename P1,typename P2>
|
||||
class obj_scope_guard_impl2:public scope_guard_impl_base
|
||||
{
|
||||
@@ -391,20 +243,6 @@ make_obj_guard(Obj& obj,MemFun mem_fun,P1 p1,P2 p2)
|
||||
return obj_scope_guard_impl2<Obj,MemFun,P1,P2>(obj,mem_fun,p1,p2);
|
||||
}
|
||||
|
||||
template<bool cond, class Obj,typename MemFun,typename P1,typename P2>
|
||||
inline typename null_guard_return<cond,obj_scope_guard_impl2<Obj,MemFun,P1,P2> >::type
|
||||
make_obj_guard_if_c(Obj& obj,MemFun mem_fun,P1 p1,P2 p2)
|
||||
{
|
||||
return typename null_guard_return<cond,obj_scope_guard_impl2<Obj,MemFun,P1,P2> >::type(obj,mem_fun,p1,p2);
|
||||
}
|
||||
|
||||
template<typename C, class Obj,typename MemFun,typename P1,typename P2>
|
||||
inline typename null_guard_return<C::value,obj_scope_guard_impl2<Obj,MemFun,P1,P2> >::type
|
||||
make_obj_guard_if(Obj& obj,MemFun mem_fun,P1 p1,P2 p2)
|
||||
{
|
||||
return make_obj_guard_if_c<C::value>(obj,mem_fun,p1,p2);
|
||||
}
|
||||
|
||||
template<class Obj,typename MemFun,typename P1,typename P2,typename P3>
|
||||
class obj_scope_guard_impl3:public scope_guard_impl_base
|
||||
{
|
||||
@@ -430,20 +268,6 @@ make_obj_guard(Obj& obj,MemFun mem_fun,P1 p1,P2 p2,P3 p3)
|
||||
return obj_scope_guard_impl3<Obj,MemFun,P1,P2,P3>(obj,mem_fun,p1,p2,p3);
|
||||
}
|
||||
|
||||
template<bool cond, class Obj,typename MemFun,typename P1,typename P2,typename P3>
|
||||
inline typename null_guard_return<cond,obj_scope_guard_impl3<Obj,MemFun,P1,P2,P3> >::type
|
||||
make_obj_guard_if_c(Obj& obj,MemFun mem_fun,P1 p1,P2 p2,P3 p3)
|
||||
{
|
||||
return typename null_guard_return<cond,obj_scope_guard_impl3<Obj,MemFun,P1,P2,P3> >::type(obj,mem_fun,p1,p2,p3);
|
||||
}
|
||||
|
||||
template<typename C, class Obj,typename MemFun,typename P1,typename P2,typename P3>
|
||||
inline typename null_guard_return<C::value,obj_scope_guard_impl3<Obj,MemFun,P1,P2,P3> >::type
|
||||
make_obj_guard_if(Obj& obj,MemFun mem_fun,P1 p1,P2 p2,P3 p3)
|
||||
{
|
||||
return make_obj_guard_if_c<C::value>(obj,mem_fun,p1,p2,p3);
|
||||
}
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2019 Joaquin M Lopez Munoz.
|
||||
/* Copyright 2003-2006 Joaquín M López Muñoz.
|
||||
* 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)
|
||||
@@ -9,14 +9,11 @@
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_SEQ_INDEX_NODE_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_SEQ_INDEX_NODE_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <algorithm>
|
||||
#include <boost/multi_index/detail/allocator_traits.hpp>
|
||||
#include <boost/multi_index/detail/raw_ptr.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
@@ -26,43 +23,36 @@ namespace detail{
|
||||
|
||||
/* doubly-linked node for use by sequenced_index */
|
||||
|
||||
template<typename Allocator>
|
||||
struct sequenced_index_node_impl
|
||||
{
|
||||
typedef typename rebind_alloc_for<
|
||||
Allocator,sequenced_index_node_impl
|
||||
>::type node_allocator;
|
||||
typedef allocator_traits<node_allocator> alloc_traits;
|
||||
typedef typename alloc_traits::pointer pointer;
|
||||
typedef typename alloc_traits::const_pointer const_pointer;
|
||||
typedef typename alloc_traits::difference_type difference_type;
|
||||
|
||||
pointer& prior(){return prior_;}
|
||||
pointer prior()const{return prior_;}
|
||||
pointer& next(){return next_;}
|
||||
pointer next()const{return next_;}
|
||||
sequenced_index_node_impl*& prior(){return prior_;}
|
||||
sequenced_index_node_impl* prior()const{return prior_;}
|
||||
sequenced_index_node_impl*& next(){return next_;}
|
||||
sequenced_index_node_impl* next()const{return next_;}
|
||||
|
||||
/* interoperability with bidir_node_iterator */
|
||||
|
||||
static void increment(pointer& x){x=x->next();}
|
||||
static void decrement(pointer& x){x=x->prior();}
|
||||
static void increment(sequenced_index_node_impl*& x){x=x->next();}
|
||||
static void decrement(sequenced_index_node_impl*& x){x=x->prior();}
|
||||
|
||||
/* algorithmic stuff */
|
||||
|
||||
static void link(pointer x,pointer header)
|
||||
static void link(
|
||||
sequenced_index_node_impl* x,sequenced_index_node_impl* header)
|
||||
{
|
||||
x->prior()=header->prior();
|
||||
x->next()=header;
|
||||
x->prior()->next()=x->next()->prior()=x;
|
||||
}
|
||||
};
|
||||
|
||||
static void unlink(pointer x)
|
||||
static void unlink(sequenced_index_node_impl* x)
|
||||
{
|
||||
x->prior()->next()=x->next();
|
||||
x->next()->prior()=x->prior();
|
||||
}
|
||||
|
||||
static void relink(pointer position,pointer x)
|
||||
static void relink(
|
||||
sequenced_index_node_impl* position,sequenced_index_node_impl* x)
|
||||
{
|
||||
unlink(x);
|
||||
x->prior()=position->prior();
|
||||
@@ -70,12 +60,14 @@ struct sequenced_index_node_impl
|
||||
x->prior()->next()=x->next()->prior()=x;
|
||||
}
|
||||
|
||||
static void relink(pointer position,pointer x,pointer y)
|
||||
static void relink(
|
||||
sequenced_index_node_impl* position,
|
||||
sequenced_index_node_impl* x,sequenced_index_node_impl* y)
|
||||
{
|
||||
/* position is assumed not to be in [x,y) */
|
||||
|
||||
if(x!=y){
|
||||
pointer z=y->prior();
|
||||
sequenced_index_node_impl* z=y->prior();
|
||||
x->prior()->next()=y;
|
||||
y->prior()=x->prior();
|
||||
x->prior()=position->prior();
|
||||
@@ -85,17 +77,17 @@ struct sequenced_index_node_impl
|
||||
}
|
||||
}
|
||||
|
||||
static void reverse(pointer header)
|
||||
static void reverse(sequenced_index_node_impl* header)
|
||||
{
|
||||
pointer x=header;
|
||||
sequenced_index_node_impl* x=header;
|
||||
do{
|
||||
pointer y=x->next();
|
||||
sequenced_index_node_impl* y=x->next();
|
||||
std::swap(x->prior(),x->next());
|
||||
x=y;
|
||||
}while(x!=header);
|
||||
}
|
||||
|
||||
static void swap(pointer x,pointer y)
|
||||
static void swap(sequenced_index_node_impl* x,sequenced_index_node_impl* y)
|
||||
{
|
||||
/* This swap function does not exchange the header nodes,
|
||||
* but rather their pointers. This is *not* used for implementing
|
||||
@@ -125,87 +117,53 @@ struct sequenced_index_node_impl
|
||||
}
|
||||
|
||||
private:
|
||||
pointer prior_;
|
||||
pointer next_;
|
||||
sequenced_index_node_impl* prior_;
|
||||
sequenced_index_node_impl* next_;
|
||||
};
|
||||
|
||||
template<typename Super>
|
||||
struct sequenced_index_node_trampoline:
|
||||
sequenced_index_node_impl<
|
||||
typename rebind_alloc_for<
|
||||
typename Super::allocator_type,
|
||||
char
|
||||
>::type
|
||||
>
|
||||
{
|
||||
typedef sequenced_index_node_impl<
|
||||
typename rebind_alloc_for<
|
||||
typename Super::allocator_type,
|
||||
char
|
||||
>::type
|
||||
> impl_type;
|
||||
};
|
||||
struct sequenced_index_node_trampoline:sequenced_index_node_impl{};
|
||||
|
||||
template<typename Super>
|
||||
struct sequenced_index_node:Super,sequenced_index_node_trampoline<Super>
|
||||
{
|
||||
private:
|
||||
typedef sequenced_index_node_trampoline<Super> trampoline;
|
||||
sequenced_index_node_impl*& prior(){return impl_type::prior();}
|
||||
sequenced_index_node_impl* prior()const{return impl_type::prior();}
|
||||
sequenced_index_node_impl*& next(){return impl_type::next();}
|
||||
sequenced_index_node_impl* next()const{return impl_type::next();}
|
||||
|
||||
public:
|
||||
typedef typename trampoline::impl_type impl_type;
|
||||
typedef typename trampoline::pointer impl_pointer;
|
||||
typedef typename trampoline::const_pointer const_impl_pointer;
|
||||
typedef typename trampoline::difference_type difference_type;
|
||||
sequenced_index_node_impl* impl()
|
||||
{return static_cast<impl_type*>(this);}
|
||||
const sequenced_index_node_impl* impl()const
|
||||
{return static_cast<const impl_type*>(this);}
|
||||
|
||||
impl_pointer& prior(){return trampoline::prior();}
|
||||
impl_pointer prior()const{return trampoline::prior();}
|
||||
impl_pointer& next(){return trampoline::next();}
|
||||
impl_pointer next()const{return trampoline::next();}
|
||||
|
||||
impl_pointer impl()
|
||||
static sequenced_index_node* from_impl(sequenced_index_node_impl *x)
|
||||
{return static_cast<sequenced_index_node*>(static_cast<impl_type*>(x));}
|
||||
static const sequenced_index_node* from_impl(
|
||||
const sequenced_index_node_impl* x)
|
||||
{
|
||||
return static_cast<impl_pointer>(
|
||||
static_cast<impl_type*>(static_cast<trampoline*>(this)));
|
||||
}
|
||||
|
||||
const_impl_pointer impl()const
|
||||
{
|
||||
return static_cast<const_impl_pointer>(
|
||||
static_cast<const impl_type*>(static_cast<const trampoline*>(this)));
|
||||
}
|
||||
|
||||
static sequenced_index_node* from_impl(impl_pointer x)
|
||||
{
|
||||
return
|
||||
static_cast<sequenced_index_node*>(
|
||||
static_cast<trampoline*>(
|
||||
raw_ptr<impl_type*>(x)));
|
||||
}
|
||||
|
||||
static const sequenced_index_node* from_impl(const_impl_pointer x)
|
||||
{
|
||||
return
|
||||
static_cast<const sequenced_index_node*>(
|
||||
static_cast<const trampoline*>(
|
||||
raw_ptr<const impl_type*>(x)));
|
||||
return static_cast<const sequenced_index_node*>(
|
||||
static_cast<const impl_type*>(x));
|
||||
}
|
||||
|
||||
/* interoperability with bidir_node_iterator */
|
||||
|
||||
static void increment(sequenced_index_node*& x)
|
||||
{
|
||||
impl_pointer xi=x->impl();
|
||||
trampoline::increment(xi);
|
||||
sequenced_index_node_impl* xi=x->impl();
|
||||
impl_type::increment(xi);
|
||||
x=from_impl(xi);
|
||||
}
|
||||
|
||||
static void decrement(sequenced_index_node*& x)
|
||||
{
|
||||
impl_pointer xi=x->impl();
|
||||
trampoline::decrement(xi);
|
||||
sequenced_index_node_impl* xi=x->impl();
|
||||
impl_type::decrement(xi);
|
||||
x=from_impl(xi);
|
||||
}
|
||||
|
||||
private:
|
||||
typedef sequenced_index_node_trampoline<Super> impl_type;
|
||||
};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user