diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index 6afd357c2c..0000000000
--- a/.gitattributes
+++ /dev/null
@@ -1,2 +0,0 @@
-.git* export-ignore
-/CMakeLists.txt export-subst
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 0b1472706b..0000000000
--- a/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.DS_Store
-/build
-/tags
-.idea
-.ycm_extra_conf.py
-.ycm_extra_conf.pyc
-Release
-Debug
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index 5bc30372cb..0000000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,152 +0,0 @@
-cmake_minimum_required(VERSION 2.8.6)
-
-set(VERSION "0.1")
-# $Format:Packaged from commit %H%nset(COMMIT %h)%nset(REFS "%d")$
-
-set_property(GLOBAL PROPERTY USE_FOLDERS ON)
-set(CMAKE_CONFIGURATION_TYPES Debug RelWithDebInfo Release CACHE TYPE INTERNAL)
-set(CMAKE_SKIP_INSTALL_RULES ON)
-set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY ON)
-set(CMAKE_SUPPRESS_REGENERATION ON)
-enable_testing()
-# copy CTestCustom.cmake to build dir to disable long running tests in 'make test'
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_CURRENT_BINARY_DIR})
-
-project(Bytecoin)
-
-include_directories(include src external "${CMAKE_CURRENT_BINARY_DIR}/version")
-if(APPLE)
- include_directories(SYSTEM /usr/include/malloc)
- enable_language(ASM)
-endif()
-
-if(MSVC)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Platform/Windows)
-elseif(APPLE)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Platform/OSX)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Platform/Posix)
-else()
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Platform/Linux)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Platform/Posix)
-endif()
-
-set(STATIC ${MSVC} CACHE BOOL "Link libraries statically")
-
-if(MSVC)
- add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /D_VARIADIC_MAX=8 /D__SSE4_1__")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10485760")
- if(STATIC)
- foreach(VAR CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE)
- string(REPLACE "/MD" "/MT" ${VAR} "${${VAR}}")
- endforeach()
- endif()
- include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/msc)
-else()
- if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
- # This option has no effect in glibc version less than 2.20.
- # Since glibc 2.20 _BSD_SOURCE is deprecated, this macro is recomended instead
- add_definitions("-D_DEFAULT_SOURCE -D_GNU_SOURCE")
- endif()
- set(ARCH native CACHE STRING "CPU to build for: -march value or default")
- if("${ARCH}" STREQUAL "default")
- set(ARCH_FLAG "")
- else()
- set(ARCH_FLAG "-march=${ARCH}")
- endif()
- set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Werror -Wno-error=extra -Wno-error=unused-function -Wno-error=deprecated-declarations -Wno-error=sign-compare -Wno-error=strict-aliasing -Wno-error=type-limits -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized -Wno-error=unused-result")
- if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
- set(WARNINGS "${WARNINGS} -Wno-error=mismatched-tags -Wno-error=null-conversion -Wno-overloaded-shift-op-parentheses -Wno-error=shift-count-overflow -Wno-error=tautological-constant-out-of-range-compare -Wno-error=unused-private-field -Wno-error=unneeded-internal-declaration -Wno-error=unused-function -Wno-error=missing-braces")
- else()
- set(WARNINGS "${WARNINGS} -Wlogical-op -Wno-error=maybe-uninitialized -Wno-error=clobbered -Wno-error=unused-but-set-variable")
- endif()
- if(MINGW)
- set(WARNINGS "${WARNINGS} -Wno-error=unused-value")
- set(MINGW_FLAG "-DWIN32_LEAN_AND_MEAN")
- include_directories(SYSTEM src/platform/mingw)
- else()
- set(MINGW_FLAG "")
- endif()
- if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.1))
- set(WARNINGS "${WARNINGS} -Wno-error=odr")
- endif()
- set(C_WARNINGS "-Waggregate-return -Wnested-externs -Wold-style-definition -Wstrict-prototypes")
- set(CXX_WARNINGS "-Wno-reorder -Wno-missing-field-initializers")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 ${MINGW_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG} -maes")
- if(NOT APPLE)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
- endif()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG} -maes")
- if(APPLE)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_HAS_TR1_TUPLE=0")
- endif()
- if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8))
- set(DEBUG_FLAGS "-g3 -Og -gdwarf-4 -fvar-tracking -fvar-tracking-assignments -fno-inline -fno-omit-frame-pointer")
- else()
- set(DEBUG_FLAGS "-g3 -O0 -fno-omit-frame-pointer")
- endif()
- set(RELEASE_FLAGS "-Ofast -DNDEBUG -Wno-unused-variable")
- if(NOT APPLE)
- # There is a clang bug that does not allow to compile code that uses AES-NI intrinsics if -flto is enabled
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux"
- AND CMAKE_BUILD_TYPE STREQUAL "Release" AND ((CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.9) OR (CMAKE_C_COMPILER_VERSION VERSION_EQUAL 4.9)))
- # On linux, to build in lto mode, check that ld.gold linker is used: 'update-alternatives --install /usr/bin/ld ld /usr/bin/ld.gold HIGHEST_PRIORITY'
- set(CMAKE_AR gcc-ar)
- set(CMAKE_RANLIB gcc-ranlib)
- endif()
- #set(RELEASE_FLAGS "${RELEASE_FLAGS} -flto")
- endif()
- #if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT MINGW)
- # set(RELEASE_FLAGS "${RELEASE_FLAGS} -fno-fat-lto-objects")
- #endif()
- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${DEBUG_FLAGS}")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_FLAGS}")
- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${RELEASE_FLAGS}")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${RELEASE_FLAGS}")
- if(STATIC AND NOT APPLE)
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
- endif()
-endif()
-
-if(STATIC)
- set(Boost_USE_STATIC_LIBS ON)
- set(Boost_USE_STATIC_RUNTIME ON)
-endif()
-find_package(Boost 1.55 REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options)
-include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
-if(MINGW)
- set(Boost_LIBRARIES "${Boost_LIBRARIES};ws2_32;mswsock")
-elseif(APPLE)
- set(Boost_LIBRARIES "${Boost_LIBRARIES}")
-elseif(NOT MSVC)
- set(Boost_LIBRARIES "${Boost_LIBRARIES};rt")
-endif()
-
-set(COMMIT_ID_IN_VERSION ON CACHE BOOL "Include commit ID in version")
-file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/version")
-if (NOT COMMIT_ID_IN_VERSION)
- set(VERSION "${VERSION}-unknown")
- configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version/version.h")
- add_custom_target(version ALL)
-elseif(DEFINED COMMIT)
- string(REPLACE "." "\\." VERSION_RE "${VERSION}")
- if(NOT REFS MATCHES "(\\(|, )tag: v${VERSION_RE}(\\)|, )")
- set(VERSION "${VERSION}-g${COMMIT}")
- endif()
- configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version/version.h")
- add_custom_target(version ALL)
-else()
- find_package(Git QUIET)
- if(Git_FOUND OR GIT_FOUND)
- message(STATUS "Found Git: ${GIT_EXECUTABLE}")
- add_custom_target(version ALL "${CMAKE_COMMAND}" "-D" "VERSION=${VERSION}" "-D" "GIT=${GIT_EXECUTABLE}" "-D" "TO=${CMAKE_CURRENT_BINARY_DIR}/version/version.h" "-P" "${CMAKE_CURRENT_SOURCE_DIR}/src/version.cmake" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
- else()
- message(STATUS "WARNING: Git was not found!")
- set(VERSION "${VERSION}-unknown")
- configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version/version.h")
- add_custom_target(version ALL)
- endif()
-endif()
-
-add_subdirectory(external)
-add_subdirectory(src)
-add_subdirectory(tests)
diff --git a/CTestCustom.cmake b/CTestCustom.cmake
deleted file mode 100644
index 088261fad1..0000000000
--- a/CTestCustom.cmake
+++ /dev/null
@@ -1,11 +0,0 @@
-set(CTEST_CUSTOM_TESTS_IGNORE
- CoreTests
- IntegrationTestLibrary
- TestGenerator
- CryptoTests
- IntegrationTests
- NodeRpcProxyTests
- PerformanceTests
- TransfersTests
- )
-
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 65c5ca88a6..0000000000
--- a/LICENSE
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 451319b086..0000000000
--- a/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-all: all-release
-
-cmake-debug:
- mkdir -p build/debug
- cd build/debug && cmake -D CMAKE_BUILD_TYPE=Debug ../..
-
-build-debug: cmake-debug
- cd build/debug && $(MAKE)
-
-test-debug: build-debug
- cd build/debug && $(MAKE) test
-
-all-debug: build-debug
-
-cmake-release:
- mkdir -p build/release
- cd build/release && cmake -D CMAKE_BUILD_TYPE=Release ../..
-
-build-release: cmake-release
- cd build/release && $(MAKE)
-
-test-release: build-release
- cd build/release && $(MAKE) test
-
-all-release: build-release
-
-clean:
- rm -rf build
-
-tags:
- ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ src contrib tests/gtest
-
-.PHONY: all cmake-debug build-debug test-debug all-debug cmake-release build-release test-release all-release clean tags
diff --git a/README b/README
index 1ab44e315c..ac6a90130d 100644
--- a/README
+++ b/README
@@ -1,32 +1,5 @@
--= Building CryptoNote =-
+IMPORTANT ANNOUNCEMENT
-On *nix:
-
-Dependencies: GCC 4.7.3 or later, CMake 2.8.6 or later, and Boost 1.55.
-You may download them from:
-http://gcc.gnu.org/
-http://www.cmake.org/
-http://www.boost.org/
-Alternatively, it may be possible to install them using a package manager.
-
-To build, change to a directory where this file is located, and run `make'. The resulting executables can be found in build/release/src.
-
-Advanced options:
-Parallel build: run `make -j' instead of `make'.
-Debug build: run `make build-debug'.
-Test suite: run `make test-release' to run tests in addition to building. Running `make test-debug' will do the same to the debug version.
-Building with Clang: it may be possible to use Clang instead of GCC, but this may not work everywhere. To build, run `export CC=clang CXX=clang++' before running `make'.
-
-On Windows:
-Dependencies: MSVC 2013 or later, CMake 2.8.6 or later, and Boost 1.55. You may download them from:
-http://www.microsoft.com/
-http://www.cmake.org/
-http://www.boost.org/
-
-To build, change to a directory where this file is located, and run this commands:
-mkdir build
-cd build
-cmake -G "Visual Studio 12 Win64" ..
-
-And then do Build.
-Good luck!
\ No newline at end of file
+Official development moved to https://github.com/bcndev/bytecoin.
+This repository won't be updated any more.
+The last revision of codebase is moved to the branch https://github.com/amjuarez/bytecoin/tree/frozen-master
diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt
deleted file mode 100644
index d80a5b29f7..0000000000
--- a/ReleaseNotes.txt
+++ /dev/null
@@ -1,190 +0,0 @@
-Release notes 2.1.0
-
-- Transaction pool issue fixes
-- Daemon synchronization improvements
-
-Release notes 2.0.7
-
-- Wallet synchronization enhancements
-- Daemon synchronization issue fix
-- Daemon stability enhancements
-
-Release notes 2.0.6
-
-- Wallet synchronization enhancements
-- Correct application closing
-- Daemon stability enhancements
-
-Release notes 2.0.5
-
-- Fixed Bytecoin RPC Wallet hang issue
-
-Release notes 2.0.4
-
-- Fixed an issue where some users experienced daemon hanging
-- Fixed block difficulty calculation issue
-
-Release notes 2.0.3
-
-- Stability enhancement
-- Various improvements
-
-Release notes 2.0.2
-
-- Security algorithm enhancement
-- Daemon synchronization issue fix
-- Wallet minor bug fixes
-- Bytecoin RPC Wallet log optimization
-
-Release notes 2.0.1
-
-- Bytecoin RPC Wallet API improvements
-
-Release notes 2.0.0
-
-- Completely revamped CryptoNote core
-- Blockchain storage changed to DB
-
-Release notes 1.0.11
-
-- New Bytecoin Wallet file format
-- Daemon loading optimization
-
-Release notes 1.0.10
-
-- Blocksize increase
-- Fusion transactions for Bytecoin RPC Wallet
-- Bytecoin RPC Wallet API improvements
-
-Release notes 1.0.9
-
-- New API for Bytecoin RPC Wallet
-- Various improvements
-
-Release notes 1.0.8
-
-- Fusion transactions for Bytecoin Wallet
-- IWallet high-level API update
-- JSON RPC improvements
-- Synchronization improvements for OS X
-
-Release notes 1.0.7
-
-- Fusion transactions support
-- Various simplewallet improvements
-
-Release notes 1.0.6
-
-- High-level API update
-- Aggregate multi-addresses for Bytecoin RPC Wallet
-- Wallet synchronization speed increase
-
-Release notes 1.0.5
-
-- High-level API for blockchain explorer
-- Full network layer refactoring
-- Transactions pool synchronization
-- list_transactions method for RPC Wallet
-- Various improvements
-
-Release notes 1.0.4
-
-- Bytecoin RPC Wallet
-- New multithreading library
-- Improved console logging
-- Further optimizations
-
-Release notes 1.0.3
-
-- Multisignature API
-- Low level API
-- High level API improvements
-- Instant transaction pool notifications
-- Fully refactored simplewallet
-
-Release notes 1.0.2
-
-- Transaction history for simplewallet
-- Reset command for simplewallet
-- Various simplewallet improvements
-
-Release notes 1.0.1
-
-- Fix transfers in simplewallet
-
-Release notes 1.0.0
-
-- Multi-signatures
-- Updated block reward scheme
-- Further optimization in daemon RAM consumption
-- Faster wallet refresh
-- Transaction priority based on tx fee
-- Transactions are returned from tx pools after 24 hours
-- Dynamic maximum block size limit
-- Reduced default transaction fee
-- Various network health updates
-
-Release notes 0.8.11
-
-- Increased minimum transaction fee
-- Transaction pool optimizations
-- High level API implementation
-- CryptoNight hash function optimization
-- Improvements for wallet JSON RPC API
-
-Release notes 0.8.10
-
-- Optimized blockchain storage memory usage
-- Various code improvements
-
-Release notes 0.8.9
-
-- JSON RPC v2.0 compatibility
-- JSON RPC over TCP added
-- Further optimizations
-
-Release notes 0.8.8
-
-- Fixed a bug with checkpoints behavior
-- UI improvements for daemon
-- Various updates from our forks
-
-Release notes 0.8.7
-
-- OSX support
-- Further optimizations
-
-Release notes 0.8.6
-
-- Simplwallet can set extra for transfers
-- Improvements in JSON RPC for wallet
-- UX improvements in simplewallet
-- Win32 compilation
-
-Release notes 0.8.5
-
-- Port mapping for daemon using UPnP
-- Improvements for daemon JSON RPC API
-
-Release notes 0.8.4
-
-- Formalization of high level API
-- Improvements for wallet JSON RPC API
-
-Release notes 0.8.3
-
-- JSON RPC for wallet
-- fixed bug with blockchain storing
-- fixed bug with correct display of transfer's change
-- bug fix in simple wallet
-
-Release notes 0.8.2
-
-- now wallet is still working when daemon stores blockchain and can't serve clients;
-- no-console option for a daemon;
-- fixed problem with network synchronization;
-- major bug fix in simple wallet.
-
-Release notes 0.8.1
-
-Bytecoin project is moved to GitHub
\ No newline at end of file
diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt
deleted file mode 100755
index a4ed8d4860..0000000000
--- a/external/CMakeLists.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-set(UPNPC_BUILD_STATIC ON CACHE BOOL "Build static library")
-set(UPNPC_BUILD_SHARED OFF CACHE BOOL "Build shared library")
-set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Build test executables")
-
-add_subdirectory(miniupnpc)
-add_subdirectory(gtest)
-
-if(MSVC)
- include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR} ../version)
- add_subdirectory(rocksDB EXCLUDE_FROM_ALL)
- set_property(TARGET upnpc-static gtest gtest_main rocksdblib PROPERTY FOLDER "external")
-elseif(NOT MSVC)
- set_property(TARGET upnpc-static gtest gtest_main PROPERTY FOLDER "external")
- add_custom_target(
- rocksdb
- COMMAND make static_lib
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/
- )
- add_library(rocksdblib STATIC IMPORTED GLOBAL)
- set_target_properties(rocksdblib PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/librocksdb.a)
- add_dependencies(rocksdblib rocksdb)
-endif()
-
-if(MSVC)
- set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267")
-elseif(NOT MSVC)
- set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value")
-endif()
-
diff --git a/external/google/dense_hash_map b/external/google/dense_hash_map
deleted file mode 100644
index 74c796bab6..0000000000
--- a/external/google/dense_hash_map
+++ /dev/null
@@ -1,333 +0,0 @@
-// Copyright (c) 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ----
-// Author: Craig Silverstein
-//
-// This is just a very thin wrapper over densehashtable.h, just
-// like sgi stl's stl_hash_map is a very thin wrapper over
-// stl_hashtable. The major thing we define is operator[], because
-// we have a concept of a data_type which stl_hashtable doesn't
-// (it only has a key and a value).
-//
-// NOTE: this is exactly like sparse_hash_map.h, with the word
-// "sparse" replaced by "dense", except for the addition of
-// set_empty_key().
-//
-// YOU MUST CALL SET_EMPTY_KEY() IMMEDIATELY AFTER CONSTRUCTION.
-//
-// Otherwise your program will die in mysterious ways. (Note if you
-// use the constructor that takes an InputIterator range, you pass in
-// the empty key in the constructor, rather than after. As a result,
-// this constructor differs from the standard STL version.)
-//
-// In other respects, we adhere mostly to the STL semantics for
-// hash-map. One important exception is that insert() may invalidate
-// iterators entirely -- STL semantics are that insert() may reorder
-// iterators, but they all still refer to something valid in the
-// hashtable. Not so for us. Likewise, insert() may invalidate
-// pointers into the hashtable. (Whether insert invalidates iterators
-// and pointers depends on whether it results in a hashtable resize).
-// On the plus side, delete() doesn't invalidate iterators or pointers
-// at all, or even change the ordering of elements.
-//
-// Here are a few "power user" tips:
-//
-// 1) set_deleted_key():
-// If you want to use erase() you *must* call set_deleted_key(),
-// in addition to set_empty_key(), after construction.
-// The deleted and empty keys must differ.
-//
-// 2) resize(0):
-// When an item is deleted, its memory isn't freed right
-// away. This allows you to iterate over a hashtable,
-// and call erase(), without invalidating the iterator.
-// To force the memory to be freed, call resize(0).
-// For tr1 compatibility, this can also be called as rehash(0).
-//
-// 3) min_load_factor(0.0)
-// Setting the minimum load factor to 0.0 guarantees that
-// the hash table will never shrink.
-//
-// Roughly speaking:
-// (1) dense_hash_map: fastest, uses the most memory unless entries are small
-// (2) sparse_hash_map: slowest, uses the least memory
-// (3) hash_map / unordered_map (STL): in the middle
-//
-// Typically I use sparse_hash_map when I care about space and/or when
-// I need to save the hashtable on disk. I use hash_map otherwise. I
-// don't personally use dense_hash_set ever; some people use it for
-// small sets with lots of lookups.
-//
-// - dense_hash_map has, typically, about 78% memory overhead (if your
-// data takes up X bytes, the hash_map uses .78X more bytes in overhead).
-// - sparse_hash_map has about 4 bits overhead per entry.
-// - sparse_hash_map can be 3-7 times slower than the others for lookup and,
-// especially, inserts. See time_hash_map.cc for details.
-//
-// See /usr/(local/)?doc/sparsehash-*/dense_hash_map.html
-// for information about how to use this class.
-
-#ifndef _DENSE_HASH_MAP_H_
-#define _DENSE_HASH_MAP_H_
-
-#include
-#include // for FILE * in read()/write()
-#include // for the default template args
-#include // for equal_to
-#include // for alloc<>
-#include // for pair<>
-#include HASH_FUN_H // defined in config.h
-#include
-#include
-
-
-_START_GOOGLE_NAMESPACE_
-
-using STL_NAMESPACE::pair;
-
-template , // defined in sparseconfig.h
- class EqualKey = STL_NAMESPACE::equal_to,
- class Alloc = libc_allocator_with_realloc > >
-class dense_hash_map {
- private:
- // Apparently select1st is not stl-standard, so we define our own
- struct SelectKey {
- typedef const Key& result_type;
- const Key& operator()(const pair& p) const {
- return p.first;
- }
- };
- struct SetKey {
- void operator()(pair* value, const Key& new_key) const {
- *const_cast(&value->first) = new_key;
- // It would be nice to clear the rest of value here as well, in
- // case it's taking up a lot of memory. We do this by clearing
- // the value. This assumes T has a zero-arg constructor!
- value->second = T();
- }
- };
- // For operator[].
- struct DefaultValue {
- STL_NAMESPACE::pair operator()(const Key& key) {
- return STL_NAMESPACE::make_pair(key, T());
- }
- };
-
- // The actual data
- typedef dense_hashtable, Key, HashFcn, SelectKey,
- SetKey, EqualKey, Alloc> ht;
- ht rep;
-
- public:
- typedef typename ht::key_type key_type;
- typedef T data_type;
- typedef T mapped_type;
- typedef typename ht::value_type value_type;
- typedef typename ht::hasher hasher;
- typedef typename ht::key_equal key_equal;
- typedef Alloc allocator_type;
-
- typedef typename ht::size_type size_type;
- typedef typename ht::difference_type difference_type;
- typedef typename ht::pointer pointer;
- typedef typename ht::const_pointer const_pointer;
- typedef typename ht::reference reference;
- typedef typename ht::const_reference const_reference;
-
- typedef typename ht::iterator iterator;
- typedef typename ht::const_iterator const_iterator;
- typedef typename ht::local_iterator local_iterator;
- typedef typename ht::const_local_iterator const_local_iterator;
-
- // Iterator functions
- iterator begin() { return rep.begin(); }
- iterator end() { return rep.end(); }
- const_iterator begin() const { return rep.begin(); }
- const_iterator end() const { return rep.end(); }
-
-
- // These come from tr1's unordered_map. For us, a bucket has 0 or 1 elements.
- local_iterator begin(size_type i) { return rep.begin(i); }
- local_iterator end(size_type i) { return rep.end(i); }
- const_local_iterator begin(size_type i) const { return rep.begin(i); }
- const_local_iterator end(size_type i) const { return rep.end(i); }
-
- // Accessor functions
- allocator_type get_allocator() const { return rep.get_allocator(); }
- hasher hash_funct() const { return rep.hash_funct(); }
- hasher hash_function() const { return hash_funct(); }
- key_equal key_eq() const { return rep.key_eq(); }
-
-
- // Constructors
- explicit dense_hash_map(size_type expected_max_items_in_table = 0,
- const hasher& hf = hasher(),
- const key_equal& eql = key_equal(),
- const allocator_type& alloc = allocator_type())
- : rep(expected_max_items_in_table, hf, eql, SelectKey(), SetKey(), alloc) {
- }
-
- template
- dense_hash_map(InputIterator f, InputIterator l,
- const key_type& empty_key_val,
- size_type expected_max_items_in_table = 0,
- const hasher& hf = hasher(),
- const key_equal& eql = key_equal(),
- const allocator_type& alloc = allocator_type())
- : rep(expected_max_items_in_table, hf, eql, SelectKey(), SetKey(), alloc) {
- set_empty_key(empty_key_val);
- rep.insert(f, l);
- }
- // We use the default copy constructor
- // We use the default operator=()
- // We use the default destructor
-
- void clear() { rep.clear(); }
- // This clears the hash map without resizing it down to the minimum
- // bucket count, but rather keeps the number of buckets constant
- void clear_no_resize() { rep.clear_no_resize(); }
- void swap(dense_hash_map& hs) { rep.swap(hs.rep); }
-
-
- // Functions concerning size
- size_type size() const { return rep.size(); }
- size_type max_size() const { return rep.max_size(); }
- bool empty() const { return rep.empty(); }
- size_type bucket_count() const { return rep.bucket_count(); }
- size_type max_bucket_count() const { return rep.max_bucket_count(); }
-
- // These are tr1 methods. bucket() is the bucket the key is or would be in.
- size_type bucket_size(size_type i) const { return rep.bucket_size(i); }
- size_type bucket(const key_type& key) const { return rep.bucket(key); }
- float load_factor() const {
- return size() * 1.0f / bucket_count();
- }
- float max_load_factor() const {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- return grow;
- }
- void max_load_factor(float new_grow) {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- rep.set_resizing_parameters(shrink, new_grow);
- }
- // These aren't tr1 methods but perhaps ought to be.
- float min_load_factor() const {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- return shrink;
- }
- void min_load_factor(float new_shrink) {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- rep.set_resizing_parameters(new_shrink, grow);
- }
- // Deprecated; use min_load_factor() or max_load_factor() instead.
- void set_resizing_parameters(float shrink, float grow) {
- rep.set_resizing_parameters(shrink, grow);
- }
-
- void resize(size_type hint) { rep.resize(hint); }
- void rehash(size_type hint) { resize(hint); } // the tr1 name
-
- // Lookup routines
- iterator find(const key_type& key) { return rep.find(key); }
- const_iterator find(const key_type& key) const { return rep.find(key); }
-
- data_type& operator[](const key_type& key) { // This is our value-add!
- // If key is in the hashtable, returns find(key)->second,
- // otherwise returns insert(value_type(key, T()).first->second.
- // Note it does not create an empty T unless the find fails.
- return rep.template find_or_insert(key).second;
- }
-
- size_type count(const key_type& key) const { return rep.count(key); }
-
- pair equal_range(const key_type& key) {
- return rep.equal_range(key);
- }
- pair equal_range(const key_type& key) const {
- return rep.equal_range(key);
- }
-
- // Insertion routines
- pair insert(const value_type& obj) { return rep.insert(obj); }
- template
- void insert(InputIterator f, InputIterator l) { rep.insert(f, l); }
- void insert(const_iterator f, const_iterator l) { rep.insert(f, l); }
- // required for std::insert_iterator; the passed-in iterator is ignored
- iterator insert(iterator, const value_type& obj) { return insert(obj).first; }
-
-
- // Deletion and empty routines
- // THESE ARE NON-STANDARD! I make you specify an "impossible" key
- // value to identify deleted and empty buckets. You can change the
- // deleted key as time goes on, or get rid of it entirely to be insert-only.
- void set_empty_key(const key_type& key) { // YOU MUST CALL THIS!
- rep.set_empty_key(value_type(key, data_type())); // rep wants a value
- }
- key_type empty_key() const {
- return rep.empty_key().first; // rep returns a value
- }
-
- void set_deleted_key(const key_type& key) { rep.set_deleted_key(key); }
- void clear_deleted_key() { rep.clear_deleted_key(); }
- key_type deleted_key() const { return rep.deleted_key(); }
-
- // These are standard
- size_type erase(const key_type& key) { return rep.erase(key); }
- void erase(iterator it) { rep.erase(it); }
- void erase(iterator f, iterator l) { rep.erase(f, l); }
-
-
- // Comparison
- bool operator==(const dense_hash_map& hs) const { return rep == hs.rep; }
- bool operator!=(const dense_hash_map& hs) const { return rep != hs.rep; }
-
-
- // I/O -- this is an add-on for writing metainformation to disk
- bool write_metadata(FILE *fp) { return rep.write_metadata(fp); }
- bool read_metadata(FILE *fp) { return rep.read_metadata(fp); }
- bool write_nopointer_data(FILE *fp) { return rep.write_nopointer_data(fp); }
- bool read_nopointer_data(FILE *fp) { return rep.read_nopointer_data(fp); }
-};
-
-// We need a global swap as well
-template
-inline void swap(dense_hash_map& hm1,
- dense_hash_map& hm2) {
- hm1.swap(hm2);
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#endif /* _DENSE_HASH_MAP_H_ */
diff --git a/external/google/dense_hash_set b/external/google/dense_hash_set
deleted file mode 100644
index fcf5db844c..0000000000
--- a/external/google/dense_hash_set
+++ /dev/null
@@ -1,308 +0,0 @@
-// Copyright (c) 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Craig Silverstein
-//
-// This is just a very thin wrapper over densehashtable.h, just
-// like sgi stl's stl_hash_set is a very thin wrapper over
-// stl_hashtable. The major thing we define is operator[], because
-// we have a concept of a data_type which stl_hashtable doesn't
-// (it only has a key and a value).
-//
-// This is more different from dense_hash_map than you might think,
-// because all iterators for sets are const (you obviously can't
-// change the key, and for sets there is no value).
-//
-// NOTE: this is exactly like sparse_hash_set.h, with the word
-// "sparse" replaced by "dense", except for the addition of
-// set_empty_key().
-//
-// YOU MUST CALL SET_EMPTY_KEY() IMMEDIATELY AFTER CONSTRUCTION.
-//
-// Otherwise your program will die in mysterious ways. (Note if you
-// use the constructor that takes an InputIterator range, you pass in
-// the empty key in the constructor, rather than after. As a result,
-// this constructor differs from the standard STL version.)
-//
-// In other respects, we adhere mostly to the STL semantics for
-// hash-map. One important exception is that insert() may invalidate
-// iterators entirely -- STL semantics are that insert() may reorder
-// iterators, but they all still refer to something valid in the
-// hashtable. Not so for us. Likewise, insert() may invalidate
-// pointers into the hashtable. (Whether insert invalidates iterators
-// and pointers depends on whether it results in a hashtable resize).
-// On the plus side, delete() doesn't invalidate iterators or pointers
-// at all, or even change the ordering of elements.
-//
-// Here are a few "power user" tips:
-//
-// 1) set_deleted_key():
-// If you want to use erase() you must call set_deleted_key(),
-// in addition to set_empty_key(), after construction.
-// The deleted and empty keys must differ.
-//
-// 2) resize(0):
-// When an item is deleted, its memory isn't freed right
-// away. This allows you to iterate over a hashtable,
-// and call erase(), without invalidating the iterator.
-// To force the memory to be freed, call resize(0).
-// For tr1 compatibility, this can also be called as rehash(0).
-//
-// 3) min_load_factor(0.0)
-// Setting the minimum load factor to 0.0 guarantees that
-// the hash table will never shrink.
-//
-// Roughly speaking:
-// (1) dense_hash_set: fastest, uses the most memory unless entries are small
-// (2) sparse_hash_set: slowest, uses the least memory
-// (3) hash_set / unordered_set (STL): in the middle
-//
-// Typically I use sparse_hash_set when I care about space and/or when
-// I need to save the hashtable on disk. I use hash_set otherwise. I
-// don't personally use dense_hash_set ever; some people use it for
-// small sets with lots of lookups.
-//
-// - dense_hash_set has, typically, about 78% memory overhead (if your
-// data takes up X bytes, the hash_set uses .78X more bytes in overhead).
-// - sparse_hash_set has about 4 bits overhead per entry.
-// - sparse_hash_set can be 3-7 times slower than the others for lookup and,
-// especially, inserts. See time_hash_map.cc for details.
-//
-// See /usr/(local/)?doc/sparsehash-*/dense_hash_set.html
-// for information about how to use this class.
-
-#ifndef _DENSE_HASH_SET_H_
-#define _DENSE_HASH_SET_H_
-
-#include
-#include // for FILE * in read()/write()
-#include // for the default template args
-#include // for equal_to
-#include // for alloc<>
-#include // for pair<>
-#include HASH_FUN_H // defined in config.h
-#include
-#include
-
-
-_START_GOOGLE_NAMESPACE_
-
-using STL_NAMESPACE::pair;
-
-template , // defined in sparseconfig.h
- class EqualKey = STL_NAMESPACE::equal_to,
- class Alloc = libc_allocator_with_realloc >
-class dense_hash_set {
- private:
- // Apparently identity is not stl-standard, so we define our own
- struct Identity {
- typedef const Value& result_type;
- const Value& operator()(const Value& v) const { return v; }
- };
- struct SetKey {
- void operator()(Value* value, const Value& new_key) const {
- *value = new_key;
- }
- };
-
- // The actual data
- typedef dense_hashtable ht;
- ht rep;
-
- public:
- typedef typename ht::key_type key_type;
- typedef typename ht::value_type value_type;
- typedef typename ht::hasher hasher;
- typedef typename ht::key_equal key_equal;
- typedef Alloc allocator_type;
-
- typedef typename ht::size_type size_type;
- typedef typename ht::difference_type difference_type;
- typedef typename ht::const_pointer pointer;
- typedef typename ht::const_pointer const_pointer;
- typedef typename ht::const_reference reference;
- typedef typename ht::const_reference const_reference;
-
- typedef typename ht::const_iterator iterator;
- typedef typename ht::const_iterator const_iterator;
- typedef typename ht::const_local_iterator local_iterator;
- typedef typename ht::const_local_iterator const_local_iterator;
-
-
- // Iterator functions -- recall all iterators are const
- iterator begin() const { return rep.begin(); }
- iterator end() const { return rep.end(); }
-
- // These come from tr1's unordered_set. For us, a bucket has 0 or 1 elements.
- local_iterator begin(size_type i) const { return rep.begin(i); }
- local_iterator end(size_type i) const { return rep.end(i); }
-
-
- // Accessor functions
- allocator_type get_allocator() const { return rep.get_allocator(); }
- hasher hash_funct() const { return rep.hash_funct(); }
- hasher hash_function() const { return hash_funct(); } // tr1 name
- key_equal key_eq() const { return rep.key_eq(); }
-
-
- // Constructors
- explicit dense_hash_set(size_type expected_max_items_in_table = 0,
- const hasher& hf = hasher(),
- const key_equal& eql = key_equal(),
- const allocator_type& alloc = allocator_type())
- : rep(expected_max_items_in_table, hf, eql, Identity(), SetKey(), alloc) {
- }
-
- template
- dense_hash_set(InputIterator f, InputIterator l,
- const key_type& empty_key_val,
- size_type expected_max_items_in_table = 0,
- const hasher& hf = hasher(),
- const key_equal& eql = key_equal(),
- const allocator_type& alloc = allocator_type())
- : rep(expected_max_items_in_table, hf, eql, Identity(), SetKey(), alloc) {
- set_empty_key(empty_key_val);
- rep.insert(f, l);
- }
- // We use the default copy constructor
- // We use the default operator=()
- // We use the default destructor
-
- void clear() { rep.clear(); }
- // This clears the hash set without resizing it down to the minimum
- // bucket count, but rather keeps the number of buckets constant
- void clear_no_resize() { rep.clear_no_resize(); }
- void swap(dense_hash_set& hs) { rep.swap(hs.rep); }
-
-
- // Functions concerning size
- size_type size() const { return rep.size(); }
- size_type max_size() const { return rep.max_size(); }
- bool empty() const { return rep.empty(); }
- size_type bucket_count() const { return rep.bucket_count(); }
- size_type max_bucket_count() const { return rep.max_bucket_count(); }
-
- // These are tr1 methods. bucket() is the bucket the key is or would be in.
- size_type bucket_size(size_type i) const { return rep.bucket_size(i); }
- size_type bucket(const key_type& key) const { return rep.bucket(key); }
- float load_factor() const {
- return size() * 1.0f / bucket_count();
- }
- float max_load_factor() const {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- return grow;
- }
- void max_load_factor(float new_grow) {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- rep.set_resizing_parameters(shrink, new_grow);
- }
- // These aren't tr1 methods but perhaps ought to be.
- float min_load_factor() const {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- return shrink;
- }
- void min_load_factor(float new_shrink) {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- rep.set_resizing_parameters(new_shrink, grow);
- }
- // Deprecated; use min_load_factor() or max_load_factor() instead.
- void set_resizing_parameters(float shrink, float grow) {
- rep.set_resizing_parameters(shrink, grow);
- }
-
- void resize(size_type hint) { rep.resize(hint); }
- void rehash(size_type hint) { resize(hint); } // the tr1 name
-
- // Lookup routines
- iterator find(const key_type& key) const { return rep.find(key); }
-
- size_type count(const key_type& key) const { return rep.count(key); }
-
- pair equal_range(const key_type& key) const {
- return rep.equal_range(key);
- }
-
-
- // Insertion routines
- pair insert(const value_type& obj) {
- pair p = rep.insert(obj);
- return pair(p.first, p.second); // const to non-const
- }
- template
- void insert(InputIterator f, InputIterator l) { rep.insert(f, l); }
- void insert(const_iterator f, const_iterator l) { rep.insert(f, l); }
- // required for std::insert_iterator; the passed-in iterator is ignored
- iterator insert(iterator, const value_type& obj) { return insert(obj).first; }
-
-
- // Deletion and empty routines
- // THESE ARE NON-STANDARD! I make you specify an "impossible" key
- // value to identify deleted and empty buckets. You can change the
- // deleted key as time goes on, or get rid of it entirely to be insert-only.
- void set_empty_key(const key_type& key) { rep.set_empty_key(key); }
- key_type empty_key() const { return rep.empty_key(); }
-
- void set_deleted_key(const key_type& key) { rep.set_deleted_key(key); }
- void clear_deleted_key() { rep.clear_deleted_key(); }
- key_type deleted_key() const { return rep.deleted_key(); }
-
- // These are standard
- size_type erase(const key_type& key) { return rep.erase(key); }
- void erase(iterator it) { rep.erase(it); }
- void erase(iterator f, iterator l) { rep.erase(f, l); }
-
-
- // Comparison
- bool operator==(const dense_hash_set& hs) const { return rep == hs.rep; }
- bool operator!=(const dense_hash_set& hs) const { return rep != hs.rep; }
-
-
- // I/O -- this is an add-on for writing metainformation to disk
- bool write_metadata(FILE *fp) { return rep.write_metadata(fp); }
- bool read_metadata(FILE *fp) { return rep.read_metadata(fp); }
- bool write_nopointer_data(FILE *fp) { return rep.write_nopointer_data(fp); }
- bool read_nopointer_data(FILE *fp) { return rep.read_nopointer_data(fp); }
-};
-
-template
-inline void swap(dense_hash_set& hs1,
- dense_hash_set& hs2) {
- hs1.swap(hs2);
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#endif /* _DENSE_HASH_SET_H_ */
diff --git a/external/google/sparse_hash_map b/external/google/sparse_hash_map
deleted file mode 100644
index 07e52d8b40..0000000000
--- a/external/google/sparse_hash_map
+++ /dev/null
@@ -1,310 +0,0 @@
-// Copyright (c) 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Craig Silverstein
-//
-// This is just a very thin wrapper over sparsehashtable.h, just
-// like sgi stl's stl_hash_map is a very thin wrapper over
-// stl_hashtable. The major thing we define is operator[], because
-// we have a concept of a data_type which stl_hashtable doesn't
-// (it only has a key and a value).
-//
-// We adhere mostly to the STL semantics for hash-map. One important
-// exception is that insert() may invalidate iterators entirely -- STL
-// semantics are that insert() may reorder iterators, but they all
-// still refer to something valid in the hashtable. Not so for us.
-// Likewise, insert() may invalidate pointers into the hashtable.
-// (Whether insert invalidates iterators and pointers depends on
-// whether it results in a hashtable resize). On the plus side,
-// delete() doesn't invalidate iterators or pointers at all, or even
-// change the ordering of elements.
-//
-// Here are a few "power user" tips:
-//
-// 1) set_deleted_key():
-// Unlike STL's hash_map, if you want to use erase() you
-// *must* call set_deleted_key() after construction.
-//
-// 2) resize(0):
-// When an item is deleted, its memory isn't freed right
-// away. This is what allows you to iterate over a hashtable
-// and call erase() without invalidating the iterator.
-// To force the memory to be freed, call resize(0).
-// For tr1 compatibility, this can also be called as rehash(0).
-//
-// 3) min_load_factor(0.0)
-// Setting the minimum load factor to 0.0 guarantees that
-// the hash table will never shrink.
-//
-// Roughly speaking:
-// (1) dense_hash_map: fastest, uses the most memory unless entries are small
-// (2) sparse_hash_map: slowest, uses the least memory
-// (3) hash_map / unordered_map (STL): in the middle
-//
-// Typically I use sparse_hash_map when I care about space and/or when
-// I need to save the hashtable on disk. I use hash_map otherwise. I
-// don't personally use dense_hash_map ever; some people use it for
-// small maps with lots of lookups.
-//
-// - dense_hash_map has, typically, about 78% memory overhead (if your
-// data takes up X bytes, the hash_map uses .78X more bytes in overhead).
-// - sparse_hash_map has about 4 bits overhead per entry.
-// - sparse_hash_map can be 3-7 times slower than the others for lookup and,
-// especially, inserts. See time_hash_map.cc for details.
-//
-// See /usr/(local/)?doc/sparsehash-*/sparse_hash_map.html
-// for information about how to use this class.
-
-#ifndef _SPARSE_HASH_MAP_H_
-#define _SPARSE_HASH_MAP_H_
-
-#include
-#include // for FILE * in read()/write()
-#include // for the default template args
-#include // for equal_to
-#include // for alloc<>
-#include // for pair<>
-#include HASH_FUN_H // defined in config.h
-#include
-#include
-
-
-_START_GOOGLE_NAMESPACE_
-
-using STL_NAMESPACE::pair;
-
-template , // defined in sparseconfig.h
- class EqualKey = STL_NAMESPACE::equal_to,
- class Alloc = libc_allocator_with_realloc > >
-class sparse_hash_map {
- private:
- // Apparently select1st is not stl-standard, so we define our own
- struct SelectKey {
- typedef const Key& result_type;
- const Key& operator()(const pair& p) const {
- return p.first;
- }
- };
- struct SetKey {
- void operator()(pair* value, const Key& new_key) const {
- *const_cast(&value->first) = new_key;
- // It would be nice to clear the rest of value here as well, in
- // case it's taking up a lot of memory. We do this by clearing
- // the value. This assumes T has a zero-arg constructor!
- value->second = T();
- }
- };
- // For operator[].
- struct DefaultValue {
- STL_NAMESPACE::pair operator()(const Key& key) {
- return STL_NAMESPACE::make_pair(key, T());
- }
- };
-
- // The actual data
- typedef sparse_hashtable, Key, HashFcn, SelectKey,
- SetKey, EqualKey, Alloc> ht;
- ht rep;
-
- public:
- typedef typename ht::key_type key_type;
- typedef T data_type;
- typedef T mapped_type;
- typedef typename ht::value_type value_type;
- typedef typename ht::hasher hasher;
- typedef typename ht::key_equal key_equal;
- typedef Alloc allocator_type;
-
- typedef typename ht::size_type size_type;
- typedef typename ht::difference_type difference_type;
- typedef typename ht::pointer pointer;
- typedef typename ht::const_pointer const_pointer;
- typedef typename ht::reference reference;
- typedef typename ht::const_reference const_reference;
-
- typedef typename ht::iterator iterator;
- typedef typename ht::const_iterator const_iterator;
- typedef typename ht::local_iterator local_iterator;
- typedef typename ht::const_local_iterator const_local_iterator;
-
- // Iterator functions
- iterator begin() { return rep.begin(); }
- iterator end() { return rep.end(); }
- const_iterator begin() const { return rep.begin(); }
- const_iterator end() const { return rep.end(); }
-
- // These come from tr1's unordered_map. For us, a bucket has 0 or 1 elements.
- local_iterator begin(size_type i) { return rep.begin(i); }
- local_iterator end(size_type i) { return rep.end(i); }
- const_local_iterator begin(size_type i) const { return rep.begin(i); }
- const_local_iterator end(size_type i) const { return rep.end(i); }
-
- // Accessor functions
- allocator_type get_allocator() const { return rep.get_allocator(); }
- hasher hash_funct() const { return rep.hash_funct(); }
- hasher hash_function() const { return hash_funct(); }
- key_equal key_eq() const { return rep.key_eq(); }
-
-
- // Constructors
- explicit sparse_hash_map(size_type expected_max_items_in_table = 0,
- const hasher& hf = hasher(),
- const key_equal& eql = key_equal(),
- const allocator_type& alloc = allocator_type())
- : rep(expected_max_items_in_table, hf, eql, SelectKey(), SetKey(), alloc) {
- }
-
- template
- sparse_hash_map(InputIterator f, InputIterator l,
- size_type expected_max_items_in_table = 0,
- const hasher& hf = hasher(),
- const key_equal& eql = key_equal(),
- const allocator_type& alloc = allocator_type())
- : rep(expected_max_items_in_table, hf, eql, SelectKey(), SetKey(), alloc) {
- rep.insert(f, l);
- }
- // We use the default copy constructor
- // We use the default operator=()
- // We use the default destructor
-
- void clear() { rep.clear(); }
- void swap(sparse_hash_map& hs) { rep.swap(hs.rep); }
-
-
- // Functions concerning size
- size_type size() const { return rep.size(); }
- size_type max_size() const { return rep.max_size(); }
- bool empty() const { return rep.empty(); }
- size_type bucket_count() const { return rep.bucket_count(); }
- size_type max_bucket_count() const { return rep.max_bucket_count(); }
-
- // These are tr1 methods. bucket() is the bucket the key is or would be in.
- size_type bucket_size(size_type i) const { return rep.bucket_size(i); }
- size_type bucket(const key_type& key) const { return rep.bucket(key); }
- float load_factor() const {
- return size() * 1.0f / bucket_count();
- }
- float max_load_factor() const {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- return grow;
- }
- void max_load_factor(float new_grow) {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- rep.set_resizing_parameters(shrink, new_grow);
- }
- // These aren't tr1 methods but perhaps ought to be.
- float min_load_factor() const {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- return shrink;
- }
- void min_load_factor(float new_shrink) {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- rep.set_resizing_parameters(new_shrink, grow);
- }
- // Deprecated; use min_load_factor() or max_load_factor() instead.
- void set_resizing_parameters(float shrink, float grow) {
- rep.set_resizing_parameters(shrink, grow);
- }
-
- void resize(size_type hint) { rep.resize(hint); }
- void rehash(size_type hint) { resize(hint); } // the tr1 name
-
- // Lookup routines
- iterator find(const key_type& key) { return rep.find(key); }
- const_iterator find(const key_type& key) const { return rep.find(key); }
-
- data_type& operator[](const key_type& key) { // This is our value-add!
- // If key is in the hashtable, returns find(key)->second,
- // otherwise returns insert(value_type(key, T()).first->second.
- // Note it does not create an empty T unless the find fails.
- return rep.template find_or_insert(key).second;
- }
-
- size_type count(const key_type& key) const { return rep.count(key); }
-
- pair equal_range(const key_type& key) {
- return rep.equal_range(key);
- }
- pair equal_range(const key_type& key) const {
- return rep.equal_range(key);
- }
-
- // Insertion routines
- pair insert(const value_type& obj) { return rep.insert(obj); }
- template
- void insert(InputIterator f, InputIterator l) { rep.insert(f, l); }
- void insert(const_iterator f, const_iterator l) { rep.insert(f, l); }
- // required for std::insert_iterator; the passed-in iterator is ignored
- iterator insert(iterator, const value_type& obj) { return insert(obj).first; }
-
-
- // Deletion routines
- // THESE ARE NON-STANDARD! I make you specify an "impossible" key
- // value to identify deleted buckets. You can change the key as
- // time goes on, or get rid of it entirely to be insert-only.
- void set_deleted_key(const key_type& key) {
- rep.set_deleted_key(key);
- }
- void clear_deleted_key() { rep.clear_deleted_key(); }
- key_type deleted_key() const { return rep.deleted_key(); }
-
- // These are standard
- size_type erase(const key_type& key) { return rep.erase(key); }
- void erase(iterator it) { rep.erase(it); }
- void erase(iterator f, iterator l) { rep.erase(f, l); }
-
-
- // Comparison
- bool operator==(const sparse_hash_map& hs) const { return rep == hs.rep; }
- bool operator!=(const sparse_hash_map& hs) const { return rep != hs.rep; }
-
-
- // I/O -- this is an add-on for writing metainformation to disk
- bool write_metadata(FILE *fp) { return rep.write_metadata(fp); }
- bool read_metadata(FILE *fp) { return rep.read_metadata(fp); }
- bool write_nopointer_data(FILE *fp) { return rep.write_nopointer_data(fp); }
- bool read_nopointer_data(FILE *fp) { return rep.read_nopointer_data(fp); }
-};
-
-// We need a global swap as well
-template
-inline void swap(sparse_hash_map& hm1,
- sparse_hash_map& hm2) {
- hm1.swap(hm2);
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#endif /* _SPARSE_HASH_MAP_H_ */
diff --git a/external/google/sparse_hash_set b/external/google/sparse_hash_set
deleted file mode 100644
index 6be16e9a62..0000000000
--- a/external/google/sparse_hash_set
+++ /dev/null
@@ -1,285 +0,0 @@
-// Copyright (c) 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Craig Silverstein
-//
-// This is just a very thin wrapper over sparsehashtable.h, just
-// like sgi stl's stl_hash_set is a very thin wrapper over
-// stl_hashtable. The major thing we define is operator[], because
-// we have a concept of a data_type which stl_hashtable doesn't
-// (it only has a key and a value).
-//
-// This is more different from sparse_hash_map than you might think,
-// because all iterators for sets are const (you obviously can't
-// change the key, and for sets there is no value).
-//
-// We adhere mostly to the STL semantics for hash-map. One important
-// exception is that insert() may invalidate iterators entirely -- STL
-// semantics are that insert() may reorder iterators, but they all
-// still refer to something valid in the hashtable. Not so for us.
-// Likewise, insert() may invalidate pointers into the hashtable.
-// (Whether insert invalidates iterators and pointers depends on
-// whether it results in a hashtable resize). On the plus side,
-// delete() doesn't invalidate iterators or pointers at all, or even
-// change the ordering of elements.
-//
-// Here are a few "power user" tips:
-//
-// 1) set_deleted_key():
-// Unlike STL's hash_map, if you want to use erase() you
-// *must* call set_deleted_key() after construction.
-//
-// 2) resize(0):
-// When an item is deleted, its memory isn't freed right
-// away. This allows you to iterate over a hashtable,
-// and call erase(), without invalidating the iterator.
-// To force the memory to be freed, call resize(0).
-// For tr1 compatibility, this can also be called as rehash(0).
-//
-// 3) min_load_factor(0.0)
-// Setting the minimum load factor to 0.0 guarantees that
-// the hash table will never shrink.
-//
-// Roughly speaking:
-// (1) dense_hash_set: fastest, uses the most memory unless entries are small
-// (2) sparse_hash_set: slowest, uses the least memory
-// (3) hash_set / unordered_set (STL): in the middle
-//
-// Typically I use sparse_hash_set when I care about space and/or when
-// I need to save the hashtable on disk. I use hash_set otherwise. I
-// don't personally use dense_hash_set ever; some people use it for
-// small sets with lots of lookups.
-//
-// - dense_hash_set has, typically, about 78% memory overhead (if your
-// data takes up X bytes, the hash_set uses .78X more bytes in overhead).
-// - sparse_hash_set has about 4 bits overhead per entry.
-// - sparse_hash_set can be 3-7 times slower than the others for lookup and,
-// especially, inserts. See time_hash_map.cc for details.
-//
-// See /usr/(local/)?doc/sparsehash-*/sparse_hash_set.html
-// for information about how to use this class.
-
-#ifndef _SPARSE_HASH_SET_H_
-#define _SPARSE_HASH_SET_H_
-
-#include
-#include // for FILE * in read()/write()
-#include // for the default template args
-#include // for equal_to
-#include // for alloc<>
-#include // for pair<>
-#include HASH_FUN_H // defined in config.h
-#include
-#include
-
-_START_GOOGLE_NAMESPACE_
-
-using STL_NAMESPACE::pair;
-
-template , // defined in sparseconfig.h
- class EqualKey = STL_NAMESPACE::equal_to,
- class Alloc = libc_allocator_with_realloc >
-class sparse_hash_set {
- private:
- // Apparently identity is not stl-standard, so we define our own
- struct Identity {
- typedef const Value& result_type;
- const Value& operator()(const Value& v) const { return v; }
- };
- struct SetKey {
- void operator()(Value* value, const Value& new_key) const {
- *value = new_key;
- }
- };
-
- typedef sparse_hashtable ht;
- ht rep;
-
- public:
- typedef typename ht::key_type key_type;
- typedef typename ht::value_type value_type;
- typedef typename ht::hasher hasher;
- typedef typename ht::key_equal key_equal;
- typedef Alloc allocator_type;
-
- typedef typename ht::size_type size_type;
- typedef typename ht::difference_type difference_type;
- typedef typename ht::const_pointer pointer;
- typedef typename ht::const_pointer const_pointer;
- typedef typename ht::const_reference reference;
- typedef typename ht::const_reference const_reference;
-
- typedef typename ht::const_iterator iterator;
- typedef typename ht::const_iterator const_iterator;
- typedef typename ht::const_local_iterator local_iterator;
- typedef typename ht::const_local_iterator const_local_iterator;
-
-
- // Iterator functions -- recall all iterators are const
- iterator begin() const { return rep.begin(); }
- iterator end() const { return rep.end(); }
-
- // These come from tr1's unordered_set. For us, a bucket has 0 or 1 elements.
- local_iterator begin(size_type i) const { return rep.begin(i); }
- local_iterator end(size_type i) const { return rep.end(i); }
-
-
- // Accessor functions
- allocator_type get_allocator() const { return rep.get_allocator(); }
- hasher hash_funct() const { return rep.hash_funct(); }
- hasher hash_function() const { return hash_funct(); } // tr1 name
- key_equal key_eq() const { return rep.key_eq(); }
-
-
- // Constructors
- explicit sparse_hash_set(size_type expected_max_items_in_table = 0,
- const hasher& hf = hasher(),
- const key_equal& eql = key_equal(),
- const allocator_type& alloc = allocator_type())
- : rep(expected_max_items_in_table, hf, eql, Identity(), SetKey(), alloc) {
- }
-
- template
- sparse_hash_set(InputIterator f, InputIterator l,
- size_type expected_max_items_in_table = 0,
- const hasher& hf = hasher(),
- const key_equal& eql = key_equal(),
- const allocator_type& alloc = allocator_type())
- : rep(expected_max_items_in_table, hf, eql, Identity(), SetKey(), alloc) {
- rep.insert(f, l);
- }
- // We use the default copy constructor
- // We use the default operator=()
- // We use the default destructor
-
- void clear() { rep.clear(); }
- void swap(sparse_hash_set& hs) { rep.swap(hs.rep); }
-
-
- // Functions concerning size
- size_type size() const { return rep.size(); }
- size_type max_size() const { return rep.max_size(); }
- bool empty() const { return rep.empty(); }
- size_type bucket_count() const { return rep.bucket_count(); }
- size_type max_bucket_count() const { return rep.max_bucket_count(); }
-
- // These are tr1 methods. bucket() is the bucket the key is or would be in.
- size_type bucket_size(size_type i) const { return rep.bucket_size(i); }
- size_type bucket(const key_type& key) const { return rep.bucket(key); }
- float load_factor() const {
- return size() * 1.0f / bucket_count();
- }
- float max_load_factor() const {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- return grow;
- }
- void max_load_factor(float new_grow) {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- rep.set_resizing_parameters(shrink, new_grow);
- }
- // These aren't tr1 methods but perhaps ought to be.
- float min_load_factor() const {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- return shrink;
- }
- void min_load_factor(float new_shrink) {
- float shrink, grow;
- rep.get_resizing_parameters(&shrink, &grow);
- rep.set_resizing_parameters(new_shrink, grow);
- }
- // Deprecated; use min_load_factor() or max_load_factor() instead.
- void set_resizing_parameters(float shrink, float grow) {
- rep.set_resizing_parameters(shrink, grow);
- }
-
- void resize(size_type hint) { rep.resize(hint); }
- void rehash(size_type hint) { resize(hint); } // the tr1 name
-
- // Lookup routines
- iterator find(const key_type& key) const { return rep.find(key); }
-
- size_type count(const key_type& key) const { return rep.count(key); }
-
- pair equal_range(const key_type& key) const {
- return rep.equal_range(key);
- }
-
- // Insertion routines
- pair insert(const value_type& obj) {
- pair p = rep.insert(obj);
- return pair(p.first, p.second); // const to non-const
- }
- template
- void insert(InputIterator f, InputIterator l) { rep.insert(f, l); }
- void insert(const_iterator f, const_iterator l) { rep.insert(f, l); }
- // required for std::insert_iterator; the passed-in iterator is ignored
- iterator insert(iterator, const value_type& obj) { return insert(obj).first; }
-
-
- // Deletion routines
- // THESE ARE NON-STANDARD! I make you specify an "impossible" key
- // value to identify deleted buckets. You can change the key as
- // time goes on, or get rid of it entirely to be insert-only.
- void set_deleted_key(const key_type& key) { rep.set_deleted_key(key); }
- void clear_deleted_key() { rep.clear_deleted_key(); }
- key_type deleted_key() const { return rep.deleted_key(); }
-
- // These are standard
- size_type erase(const key_type& key) { return rep.erase(key); }
- void erase(iterator it) { rep.erase(it); }
- void erase(iterator f, iterator l) { rep.erase(f, l); }
-
-
- // Comparison
- bool operator==(const sparse_hash_set& hs) const { return rep == hs.rep; }
- bool operator!=(const sparse_hash_set& hs) const { return rep != hs.rep; }
-
-
- // I/O -- this is an add-on for writing metainformation to disk
- bool write_metadata(FILE *fp) { return rep.write_metadata(fp); }
- bool read_metadata(FILE *fp) { return rep.read_metadata(fp); }
- bool write_nopointer_data(FILE *fp) { return rep.write_nopointer_data(fp); }
- bool read_nopointer_data(FILE *fp) { return rep.read_nopointer_data(fp); }
-};
-
-template
-inline void swap(sparse_hash_set& hs1,
- sparse_hash_set& hs2) {
- hs1.swap(hs2);
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#endif /* _SPARSE_HASH_SET_H_ */
diff --git a/external/google/sparsehash/densehashtable.h b/external/google/sparsehash/densehashtable.h
deleted file mode 100644
index 8a3126e3bd..0000000000
--- a/external/google/sparsehash/densehashtable.h
+++ /dev/null
@@ -1,1268 +0,0 @@
-// Copyright (c) 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Craig Silverstein
-//
-// A dense hashtable is a particular implementation of
-// a hashtable: one that is meant to minimize memory allocation.
-// It does this by using an array to store all the data. We
-// steal a value from the key space to indicate "empty" array
-// elements (ie indices where no item lives) and another to indicate
-// "deleted" elements.
-//
-// (Note it is possible to change the value of the delete key
-// on the fly; you can even remove it, though after that point
-// the hashtable is insert_only until you set it again. The empty
-// value however can't be changed.)
-//
-// To minimize allocation and pointer overhead, we use internal
-// probing, in which the hashtable is a single table, and collisions
-// are resolved by trying to insert again in another bucket. The
-// most cache-efficient internal probing schemes are linear probing
-// (which suffers, alas, from clumping) and quadratic probing, which
-// is what we implement by default.
-//
-// Type requirements: value_type is required to be Copy Constructible
-// and Default Constructible. It is not required to be (and commonly
-// isn't) Assignable.
-//
-// You probably shouldn't use this code directly. Use
-// or instead.
-
-// You can change the following below:
-// HT_OCCUPANCY_PCT -- how full before we double size
-// HT_EMPTY_PCT -- how empty before we halve size
-// HT_MIN_BUCKETS -- default smallest bucket size
-//
-// You can also change enlarge_factor (which defaults to
-// HT_OCCUPANCY_PCT), and shrink_factor (which defaults to
-// HT_EMPTY_PCT) with set_resizing_parameters().
-//
-// How to decide what values to use?
-// shrink_factor's default of .4 * OCCUPANCY_PCT, is probably good.
-// HT_MIN_BUCKETS is probably unnecessary since you can specify
-// (indirectly) the starting number of buckets at construct-time.
-// For enlarge_factor, you can use this chart to try to trade-off
-// expected lookup time to the space taken up. By default, this
-// code uses quadratic probing, though you can change it to linear
-// via _JUMP below if you really want to.
-//
-// From http://www.augustana.ca/~mohrj/courses/1999.fall/csc210/lecture_notes/hashing.html
-// NUMBER OF PROBES / LOOKUP Successful Unsuccessful
-// Quadratic collision resolution 1 - ln(1-L) - L/2 1/(1-L) - L - ln(1-L)
-// Linear collision resolution [1+1/(1-L)]/2 [1+1/(1-L)2]/2
-//
-// -- enlarge_factor -- 0.10 0.50 0.60 0.75 0.80 0.90 0.99
-// QUADRATIC COLLISION RES.
-// probes/successful lookup 1.05 1.44 1.62 2.01 2.21 2.85 5.11
-// probes/unsuccessful lookup 1.11 2.19 2.82 4.64 5.81 11.4 103.6
-// LINEAR COLLISION RES.
-// probes/successful lookup 1.06 1.5 1.75 2.5 3.0 5.5 50.5
-// probes/unsuccessful lookup 1.12 2.5 3.6 8.5 13.0 50.0 5000.0
-
-#ifndef _DENSEHASHTABLE_H_
-#define _DENSEHASHTABLE_H_
-
-// The probing method
-// Linear probing
-// #define JUMP_(key, num_probes) ( 1 )
-// Quadratic probing
-#define JUMP_(key, num_probes) ( num_probes )
-
-
-#include
-#include
-#include
-#include // for abort()
-#include // For swap(), eg
-#include // For length_error
-#include // For cerr
-#include // For uninitialized_fill, uninitialized_copy
-#include // for pair<>
-#include // for facts about iterator tags
-#include // for numeric_limits<>
-#include
-#include
-#include // for true_type, integral_constant, etc.
-
-_START_GOOGLE_NAMESPACE_
-
-using STL_NAMESPACE::pair;
-
-// Hashtable class, used to implement the hashed associative containers
-// hash_set and hash_map.
-
-// Value: what is stored in the table (each bucket is a Value).
-// Key: something in a 1-to-1 correspondence to a Value, that can be used
-// to search for a Value in the table (find() takes a Key).
-// HashFcn: Takes a Key and returns an integer, the more unique the better.
-// ExtractKey: given a Value, returns the unique Key associated with it.
-// Must inherit from unary_function, or at least have a
-// result_type enum indicating the return type of operator().
-// SetKey: given a Value* and a Key, modifies the value such that
-// ExtractKey(value) == key. We guarantee this is only called
-// with key == deleted_key or key == empty_key.
-// EqualKey: Given two Keys, says whether they are the same (that is,
-// if they are both associated with the same Value).
-// Alloc: STL allocator to use to allocate memory.
-
-template
-class dense_hashtable;
-
-template
-struct dense_hashtable_iterator;
-
-template
-struct dense_hashtable_const_iterator;
-
-// We're just an array, but we need to skip over empty and deleted elements
-template
-struct dense_hashtable_iterator {
- private:
- typedef typename A::template rebind::other value_alloc_type;
-
- public:
- typedef dense_hashtable_iterator iterator;
- typedef dense_hashtable_const_iterator const_iterator;
-
- typedef STL_NAMESPACE::forward_iterator_tag iterator_category;
- typedef V value_type;
- typedef typename value_alloc_type::difference_type difference_type;
- typedef typename value_alloc_type::size_type size_type;
- typedef typename value_alloc_type::reference reference;
- typedef typename value_alloc_type::pointer pointer;
-
- // "Real" constructor and default constructor
- dense_hashtable_iterator(const dense_hashtable *h,
- pointer it, pointer it_end, bool advance)
- : ht(h), pos(it), end(it_end) {
- if (advance) advance_past_empty_and_deleted();
- }
- dense_hashtable_iterator() { }
- // The default destructor is fine; we don't define one
- // The default operator= is fine; we don't define one
-
- // Happy dereferencer
- reference operator*() const { return *pos; }
- pointer operator->() const { return &(operator*()); }
-
- // Arithmetic. The only hard part is making sure that
- // we're not on an empty or marked-deleted array element
- void advance_past_empty_and_deleted() {
- while ( pos != end && (ht->test_empty(*this) || ht->test_deleted(*this)) )
- ++pos;
- }
- iterator& operator++() {
- assert(pos != end); ++pos; advance_past_empty_and_deleted(); return *this;
- }
- iterator operator++(int) { iterator tmp(*this); ++*this; return tmp; }
-
- // Comparison.
- bool operator==(const iterator& it) const { return pos == it.pos; }
- bool operator!=(const iterator& it) const { return pos != it.pos; }
-
-
- // The actual data
- const dense_hashtable *ht;
- pointer pos, end;
-};
-
-
-// Now do it all again, but with const-ness!
-template
-struct dense_hashtable_const_iterator {
- private:
- typedef typename A::template rebind::other value_alloc_type;
-
- public:
- typedef dense_hashtable_iterator iterator;
- typedef dense_hashtable_const_iterator const_iterator;
-
- typedef STL_NAMESPACE::forward_iterator_tag iterator_category;
- typedef V value_type;
- typedef typename value_alloc_type::difference_type difference_type;
- typedef typename value_alloc_type::size_type size_type;
- typedef typename value_alloc_type::const_reference reference;
- typedef typename value_alloc_type::const_pointer pointer;
-
- // "Real" constructor and default constructor
- dense_hashtable_const_iterator(
- const dense_hashtable *h,
- pointer it, pointer it_end, bool advance)
- : ht(h), pos(it), end(it_end) {
- if (advance) advance_past_empty_and_deleted();
- }
- dense_hashtable_const_iterator()
- : ht(NULL), pos(pointer()), end(pointer()) { }
- // This lets us convert regular iterators to const iterators
- dense_hashtable_const_iterator(const iterator &it)
- : ht(it.ht), pos(it.pos), end(it.end) { }
- // The default destructor is fine; we don't define one
- // The default operator= is fine; we don't define one
-
- // Happy dereferencer
- reference operator*() const { return *pos; }
- pointer operator->() const { return &(operator*()); }
-
- // Arithmetic. The only hard part is making sure that
- // we're not on an empty or marked-deleted array element
- void advance_past_empty_and_deleted() {
- while ( pos != end && (ht->test_empty(*this) || ht->test_deleted(*this)) )
- ++pos;
- }
- const_iterator& operator++() {
- assert(pos != end); ++pos; advance_past_empty_and_deleted(); return *this;
- }
- const_iterator operator++(int) { const_iterator tmp(*this); ++*this; return tmp; }
-
- // Comparison.
- bool operator==(const const_iterator& it) const { return pos == it.pos; }
- bool operator!=(const const_iterator& it) const { return pos != it.pos; }
-
-
- // The actual data
- const dense_hashtable *ht;
- pointer pos, end;
-};
-
-template
-class dense_hashtable {
- private:
- typedef typename Alloc::template rebind::other value_alloc_type;
-
- public:
- typedef Key key_type;
- typedef Value value_type;
- typedef HashFcn hasher;
- typedef EqualKey key_equal;
- typedef Alloc allocator_type;
-
- typedef typename value_alloc_type::size_type size_type;
- typedef typename value_alloc_type::difference_type difference_type;
- typedef typename value_alloc_type::reference reference;
- typedef typename value_alloc_type::const_reference const_reference;
- typedef typename value_alloc_type::pointer pointer;
- typedef typename value_alloc_type::const_pointer const_pointer;
- typedef dense_hashtable_iterator
- iterator;
-
- typedef dense_hashtable_const_iterator
- const_iterator;
-
- // These come from tr1. For us they're the same as regular iterators.
- typedef iterator local_iterator;
- typedef const_iterator const_local_iterator;
-
- // How full we let the table get before we resize, by default.
- // Knuth says .8 is good -- higher causes us to probe too much,
- // though it saves memory.
- static const int HT_OCCUPANCY_PCT; // = 50 (out of 100)
-
- // How empty we let the table get before we resize lower, by default.
- // (0.0 means never resize lower.)
- // It should be less than OCCUPANCY_PCT / 2 or we thrash resizing
- static const int HT_EMPTY_PCT; // = 0.4 * HT_OCCUPANCY_PCT;
-
- // Minimum size we're willing to let hashtables be.
- // Must be a power of two, and at least 4.
- // Note, however, that for a given hashtable, the initial size is a
- // function of the first constructor arg, and may be >HT_MIN_BUCKETS.
- static const size_type HT_MIN_BUCKETS = 4;
-
- // By default, if you don't specify a hashtable size at
- // construction-time, we use this size. Must be a power of two, and
- // at least HT_MIN_BUCKETS.
- static const size_type HT_DEFAULT_STARTING_BUCKETS = 32;
-
- // ITERATOR FUNCTIONS
- iterator begin() { return iterator(this, table,
- table + num_buckets, true); }
- iterator end() { return iterator(this, table + num_buckets,
- table + num_buckets, true); }
- const_iterator begin() const { return const_iterator(this, table,
- table+num_buckets,true);}
- const_iterator end() const { return const_iterator(this, table + num_buckets,
- table+num_buckets,true);}
-
- // These come from tr1 unordered_map. They iterate over 'bucket' n.
- // We'll just consider bucket n to be the n-th element of the table.
- local_iterator begin(size_type i) {
- return local_iterator(this, table + i, table + i+1, false);
- }
- local_iterator end(size_type i) {
- local_iterator it = begin(i);
- if (!test_empty(i) && !test_deleted(i))
- ++it;
- return it;
- }
- const_local_iterator begin(size_type i) const {
- return const_local_iterator(this, table + i, table + i+1, false);
- }
- const_local_iterator end(size_type i) const {
- const_local_iterator it = begin(i);
- if (!test_empty(i) && !test_deleted(i))
- ++it;
- return it;
- }
-
- // ACCESSOR FUNCTIONS for the things we templatize on, basically
- hasher hash_funct() const { return settings; }
- key_equal key_eq() const { return key_info; }
- allocator_type get_allocator() const {
- return allocator_type(val_info);
- }
-
- // Accessor function for statistics gathering.
- int num_table_copies() const { return settings.num_ht_copies(); }
-
- private:
- // Annoyingly, we can't copy values around, because they might have
- // const components (they're probably pair). We use
- // explicit destructor invocation and placement new to get around
- // this. Arg.
- void set_value(pointer dst, const_reference src) {
- dst->~value_type(); // delete the old value, if any
- new(dst) value_type(src);
- }
-
- void destroy_buckets(size_type first, size_type last) {
- for ( ; first != last; ++first)
- table[first].~value_type();
- }
-
- // DELETE HELPER FUNCTIONS
- // This lets the user describe a key that will indicate deleted
- // table entries. This key should be an "impossible" entry --
- // if you try to insert it for real, you won't be able to retrieve it!
- // (NB: while you pass in an entire value, only the key part is looked
- // at. This is just because I don't know how to assign just a key.)
- private:
- void squash_deleted() { // gets rid of any deleted entries we have
- if ( num_deleted ) { // get rid of deleted before writing
- dense_hashtable tmp(*this); // copying will get rid of deleted
- swap(tmp); // now we are tmp
- }
- assert(num_deleted == 0);
- }
-
- bool test_deleted_key(const key_type& key) const {
- // The num_deleted test is crucial for read(): after read(), the ht values
- // are garbage, and we don't want to think some of them are deleted.
- // Invariant: !use_deleted implies num_deleted is 0.
- assert(settings.use_deleted() || num_deleted == 0);
- return num_deleted > 0 && equals(key_info.delkey, key);
- }
-
- public:
- void set_deleted_key(const key_type &key) {
- // the empty indicator (if specified) and the deleted indicator
- // must be different
- assert((!settings.use_empty() || !equals(key, get_key(val_info.emptyval)))
- && "Passed the empty-key to set_deleted_key");
- // It's only safe to change what "deleted" means if we purge deleted guys
- squash_deleted();
- settings.set_use_deleted(true);
- key_info.delkey = key;
- }
- void clear_deleted_key() {
- squash_deleted();
- settings.set_use_deleted(false);
- }
- key_type deleted_key() const {
- assert(settings.use_deleted()
- && "Must set deleted key before calling deleted_key");
- return key_info.delkey;
- }
-
- // These are public so the iterators can use them
- // True if the item at position bucknum is "deleted" marker
- bool test_deleted(size_type bucknum) const {
- return test_deleted_key(get_key(table[bucknum]));
- }
- bool test_deleted(const iterator &it) const {
- return test_deleted_key(get_key(*it));
- }
- bool test_deleted(const const_iterator &it) const {
- return test_deleted_key(get_key(*it));
- }
-
- private:
- // Set it so test_deleted is true. true if object didn't used to be deleted.
- bool set_deleted(iterator &it) {
- assert(settings.use_deleted());
- bool retval = !test_deleted(it);
- // &* converts from iterator to value-type.
- set_key(&(*it), key_info.delkey);
- return retval;
- }
- // Set it so test_deleted is false. true if object used to be deleted.
- bool clear_deleted(iterator &it) {
- assert(settings.use_deleted());
- // Happens automatically when we assign something else in its place.
- return test_deleted(it);
- }
-
- // We also allow to set/clear the deleted bit on a const iterator.
- // We allow a const_iterator for the same reason you can delete a
- // const pointer: it's convenient, and semantically you can't use
- // 'it' after it's been deleted anyway, so its const-ness doesn't
- // really matter.
- bool set_deleted(const_iterator &it) {
- assert(settings.use_deleted());
- bool retval = !test_deleted(it);
- set_key(const_cast(&(*it)), key_info.delkey);
- return retval;
- }
- // Set it so test_deleted is false. true if object used to be deleted.
- bool clear_deleted(const_iterator &it) {
- assert(settings.use_deleted());
- return test_deleted(it);
- }
-
- // EMPTY HELPER FUNCTIONS
- // This lets the user describe a key that will indicate empty (unused)
- // table entries. This key should be an "impossible" entry --
- // if you try to insert it for real, you won't be able to retrieve it!
- // (NB: while you pass in an entire value, only the key part is looked
- // at. This is just because I don't know how to assign just a key.)
- public:
- // These are public so the iterators can use them
- // True if the item at position bucknum is "empty" marker
- bool test_empty(size_type bucknum) const {
- assert(settings.use_empty()); // we always need to know what's empty!
- return equals(get_key(val_info.emptyval), get_key(table[bucknum]));
- }
- bool test_empty(const iterator &it) const {
- assert(settings.use_empty()); // we always need to know what's empty!
- return equals(get_key(val_info.emptyval), get_key(*it));
- }
- bool test_empty(const const_iterator &it) const {
- assert(settings.use_empty()); // we always need to know what's empty!
- return equals(get_key(val_info.emptyval), get_key(*it));
- }
-
- private:
- void fill_range_with_empty(pointer table_start, pointer table_end) {
- STL_NAMESPACE::uninitialized_fill(table_start, table_end, val_info.emptyval);
- }
-
- public:
- // TODO(csilvers): change all callers of this to pass in a key instead,
- // and take a const key_type instead of const value_type.
- void set_empty_key(const_reference val) {
- // Once you set the empty key, you can't change it
- assert(!settings.use_empty() && "Calling set_empty_key multiple times");
- // The deleted indicator (if specified) and the empty indicator
- // must be different.
- assert((!settings.use_deleted() || !equals(get_key(val), key_info.delkey))
- && "Setting the empty key the same as the deleted key");
- settings.set_use_empty(true);
- set_value(&val_info.emptyval, val);
-
- assert(!table); // must set before first use
- // num_buckets was set in constructor even though table was NULL
- table = val_info.allocate(num_buckets);
- assert(table);
- fill_range_with_empty(table, table + num_buckets);
- }
- // TODO(sjackman): return a key_type rather than a value_type
- value_type empty_key() const {
- assert(settings.use_empty());
- return val_info.emptyval;
- }
-
- // FUNCTIONS CONCERNING SIZE
- public:
- size_type size() const { return num_elements - num_deleted; }
- size_type max_size() const { return val_info.max_size(); }
- bool empty() const { return size() == 0; }
- size_type bucket_count() const { return num_buckets; }
- size_type max_bucket_count() const { return max_size(); }
- size_type nonempty_bucket_count() const { return num_elements; }
- // These are tr1 methods. Their idea of 'bucket' doesn't map well to
- // what we do. We just say every bucket has 0 or 1 items in it.
- size_type bucket_size(size_type i) const {
- return begin(i) == end(i) ? 0 : 1;
- }
-
- private:
- // Because of the above, size_type(-1) is never legal; use it for errors
- static const size_type ILLEGAL_BUCKET = size_type(-1);
-
- // Used after a string of deletes. Returns true if we actually shrunk.
- // TODO(csilvers): take a delta so we can take into account inserts
- // done after shrinking. Maybe make part of the Settings class?
- bool maybe_shrink() {
- assert(num_elements >= num_deleted);
- assert((bucket_count() & (bucket_count()-1)) == 0); // is a power of two
- assert(bucket_count() >= HT_MIN_BUCKETS);
- bool retval = false;
-
- // If you construct a hashtable with < HT_DEFAULT_STARTING_BUCKETS,
- // we'll never shrink until you get relatively big, and we'll never
- // shrink below HT_DEFAULT_STARTING_BUCKETS. Otherwise, something
- // like "dense_hash_set x; x.insert(4); x.erase(4);" will
- // shrink us down to HT_MIN_BUCKETS buckets, which is too small.
- const size_type num_remain = num_elements - num_deleted;
- const size_type shrink_threshold = settings.shrink_threshold();
- if (shrink_threshold > 0 && num_remain < shrink_threshold &&
- bucket_count() > HT_DEFAULT_STARTING_BUCKETS) {
- const float shrink_factor = settings.shrink_factor();
- size_type sz = bucket_count() / 2; // find how much we should shrink
- while (sz > HT_DEFAULT_STARTING_BUCKETS &&
- num_remain < sz * shrink_factor) {
- sz /= 2; // stay a power of 2
- }
- dense_hashtable tmp(*this, sz); // Do the actual resizing
- swap(tmp); // now we are tmp
- retval = true;
- }
- settings.set_consider_shrink(false); // because we just considered it
- return retval;
- }
-
- // We'll let you resize a hashtable -- though this makes us copy all!
- // When you resize, you say, "make it big enough for this many more elements"
- // Returns true if we actually resized, false if size was already ok.
- bool resize_delta(size_type delta) {
- bool did_resize = false;
- if ( settings.consider_shrink() ) { // see if lots of deletes happened
- if ( maybe_shrink() )
- did_resize = true;
- }
- if (num_elements >= (STL_NAMESPACE::numeric_limits::max)() - delta)
- throw std::length_error("resize overflow");
- if ( bucket_count() >= HT_MIN_BUCKETS &&
- (num_elements + delta) <= settings.enlarge_threshold() )
- return did_resize; // we're ok as we are
-
- // Sometimes, we need to resize just to get rid of all the
- // "deleted" buckets that are clogging up the hashtable. So when
- // deciding whether to resize, count the deleted buckets (which
- // are currently taking up room). But later, when we decide what
- // size to resize to, *don't* count deleted buckets, since they
- // get discarded during the resize.
- const size_type needed_size = settings.min_buckets(num_elements + delta, 0);
- if ( needed_size <= bucket_count() ) // we have enough buckets
- return did_resize;
-
- size_type resize_to =
- settings.min_buckets(num_elements - num_deleted + delta, bucket_count());
-
- if (resize_to < needed_size && // may double resize_to
- resize_to < (STL_NAMESPACE::numeric_limits::max)() / 2) {
- // This situation means that we have enough deleted elements,
- // that once we purge them, we won't actually have needed to
- // grow. But we may want to grow anyway: if we just purge one
- // element, say, we'll have to grow anyway next time we
- // insert. Might as well grow now, since we're already going
- // through the trouble of copying (in order to purge the
- // deleted elements).
- const size_type target =
- static_cast(settings.shrink_size(resize_to*2));
- if (num_elements - num_deleted + delta >= target) {
- // Good, we won't be below the shrink threshhold even if we double.
- resize_to *= 2;
- }
- }
- dense_hashtable tmp(*this, resize_to);
- swap(tmp); // now we are tmp
- return true;
- }
-
- // We require table be not-NULL and empty before calling this.
- void resize_table(size_type /*old_size*/, size_type new_size,
- true_type) {
- table = val_info.realloc_or_die(table, new_size);
- }
-
- void resize_table(size_type old_size, size_type new_size, false_type) {
- val_info.deallocate(table, old_size);
- table = val_info.allocate(new_size);
- }
-
- // Used to actually do the rehashing when we grow/shrink a hashtable
- void copy_from(const dense_hashtable &ht, size_type min_buckets_wanted) {
- clear_to_size(settings.min_buckets(ht.size(), min_buckets_wanted));
-
- // We use a normal iterator to get non-deleted bcks from ht
- // We could use insert() here, but since we know there are
- // no duplicates and no deleted items, we can be more efficient
- assert((bucket_count() & (bucket_count()-1)) == 0); // a power of two
- for ( const_iterator it = ht.begin(); it != ht.end(); ++it ) {
- size_type num_probes = 0; // how many times we've probed
- size_type bucknum;
- const size_type bucket_count_minus_one = bucket_count() - 1;
- for (bucknum = hash(get_key(*it)) & bucket_count_minus_one;
- !test_empty(bucknum); // not empty
- bucknum = (bucknum + JUMP_(key, num_probes)) & bucket_count_minus_one) {
- ++num_probes;
- assert(num_probes < bucket_count()
- && "Hashtable is full: an error in key_equal<> or hash<>");
- }
- set_value(&table[bucknum], *it); // copies the value to here
- num_elements++;
- }
- settings.inc_num_ht_copies();
- }
-
- // Required by the spec for hashed associative container
- public:
- // Though the docs say this should be num_buckets, I think it's much
- // more useful as num_elements. As a special feature, calling with
- // req_elements==0 will cause us to shrink if we can, saving space.
- void resize(size_type req_elements) { // resize to this or larger
- if ( settings.consider_shrink() || req_elements == 0 )
- maybe_shrink();
- if ( req_elements > num_elements )
- resize_delta(req_elements - num_elements);
- }
-
- // Get and change the value of shrink_factor and enlarge_factor. The
- // description at the beginning of this file explains how to choose
- // the values. Setting the shrink parameter to 0.0 ensures that the
- // table never shrinks.
- void get_resizing_parameters(float* shrink, float* grow) const {
- *shrink = settings.shrink_factor();
- *grow = settings.enlarge_factor();
- }
- void set_resizing_parameters(float shrink, float grow) {
- settings.set_resizing_parameters(shrink, grow);
- settings.reset_thresholds(bucket_count());
- }
-
- // CONSTRUCTORS -- as required by the specs, we take a size,
- // but also let you specify a hashfunction, key comparator,
- // and key extractor. We also define a copy constructor and =.
- // DESTRUCTOR -- needs to free the table
- explicit dense_hashtable(size_type expected_max_items_in_table = 0,
- const HashFcn& hf = HashFcn(),
- const EqualKey& eql = EqualKey(),
- const ExtractKey& ext = ExtractKey(),
- const SetKey& set = SetKey(),
- const Alloc& alloc = Alloc())
- : settings(hf),
- key_info(ext, set, eql),
- num_deleted(0),
- num_elements(0),
- num_buckets(expected_max_items_in_table == 0
- ? HT_DEFAULT_STARTING_BUCKETS
- : settings.min_buckets(expected_max_items_in_table, 0)),
- val_info(alloc_impl(alloc)),
- table(NULL) {
- // table is NULL until emptyval is set. However, we set num_buckets
- // here so we know how much space to allocate once emptyval is set
- settings.reset_thresholds(bucket_count());
- }
-
- // As a convenience for resize(), we allow an optional second argument
- // which lets you make this new hashtable a different size than ht
- dense_hashtable(const dense_hashtable& ht,
- size_type min_buckets_wanted = HT_DEFAULT_STARTING_BUCKETS)
- : settings(ht.settings),
- key_info(ht.key_info),
- num_deleted(0),
- num_elements(0),
- num_buckets(0),
- val_info(ht.val_info),
- table(NULL) {
- if (!ht.settings.use_empty()) {
- // If use_empty isn't set, copy_from will crash, so we do our own copying.
- assert(ht.empty());
- num_buckets = settings.min_buckets(ht.size(), min_buckets_wanted);
- settings.reset_thresholds(bucket_count());
- return;
- }
- settings.reset_thresholds(bucket_count());
- copy_from(ht, min_buckets_wanted); // copy_from() ignores deleted entries
- }
-
- dense_hashtable& operator= (const dense_hashtable& ht) {
- if (&ht == this) return *this; // don't copy onto ourselves
- if (!ht.settings.use_empty()) {
- assert(ht.empty());
- dense_hashtable empty_table(ht); // empty table with ht's thresholds
- this->swap(empty_table);
- return *this;
- }
- settings = ht.settings;
- key_info = ht.key_info;
- set_value(&val_info.emptyval, ht.val_info.emptyval);
- // copy_from() calls clear and sets num_deleted to 0 too
- copy_from(ht, HT_MIN_BUCKETS);
- // we purposefully don't copy the allocator, which may not be copyable
- return *this;
- }
-
- ~dense_hashtable() {
- if (table) {
- destroy_buckets(0, num_buckets);
- val_info.deallocate(table, num_buckets);
- }
- }
-
- // Many STL algorithms use swap instead of copy constructors
- void swap(dense_hashtable& ht) {
- STL_NAMESPACE::swap(settings, ht.settings);
- STL_NAMESPACE::swap(key_info, ht.key_info);
- STL_NAMESPACE::swap(num_deleted, ht.num_deleted);
- STL_NAMESPACE::swap(num_elements, ht.num_elements);
- STL_NAMESPACE::swap(num_buckets, ht.num_buckets);
- { value_type tmp; // for annoying reasons, swap() doesn't work
- set_value(&tmp, val_info.emptyval);
- set_value(&val_info.emptyval, ht.val_info.emptyval);
- set_value(&ht.val_info.emptyval, tmp);
- }
- STL_NAMESPACE::swap(table, ht.table);
- settings.reset_thresholds(bucket_count()); // this also resets consider_shrink
- ht.settings.reset_thresholds(bucket_count());
- // we purposefully don't swap the allocator, which may not be swap-able
- }
-
- private:
- void clear_to_size(size_type new_num_buckets) {
- if (!table) {
- table = val_info.allocate(new_num_buckets);
- } else {
- destroy_buckets(0, num_buckets);
- if (new_num_buckets != num_buckets) { // resize, if necessary
- typedef integral_constant >::value>
- realloc_ok;
- resize_table(num_buckets, new_num_buckets, realloc_ok());
- }
- }
- assert(table);
- fill_range_with_empty(table, table + new_num_buckets);
- num_elements = 0;
- num_deleted = 0;
- num_buckets = new_num_buckets; // our new size
- settings.reset_thresholds(bucket_count());
- }
-
- public:
- // It's always nice to be able to clear a table without deallocating it
- void clear() {
- // If the table is already empty, and the number of buckets is
- // already as we desire, there's nothing to do.
- const size_type new_num_buckets = settings.min_buckets(0, 0);
- if (num_elements == 0 && new_num_buckets == num_buckets) {
- return;
- }
- clear_to_size(new_num_buckets);
- }
-
- // Clear the table without resizing it.
- // Mimicks the stl_hashtable's behaviour when clear()-ing in that it
- // does not modify the bucket count
- void clear_no_resize() {
- if (num_elements > 0) {
- assert(table);
- destroy_buckets(0, num_buckets);
- fill_range_with_empty(table, table + num_buckets);
- }
- // don't consider to shrink before another erase()
- settings.reset_thresholds(bucket_count());
- num_elements = 0;
- num_deleted = 0;
- }
-
- // LOOKUP ROUTINES
- private:
- // Returns a pair of positions: 1st where the object is, 2nd where
- // it would go if you wanted to insert it. 1st is ILLEGAL_BUCKET
- // if object is not found; 2nd is ILLEGAL_BUCKET if it is.
- // Note: because of deletions where-to-insert is not trivial: it's the
- // first deleted bucket we see, as long as we don't find the key later
- pair find_position(const key_type &key) const {
- size_type num_probes = 0; // how many times we've probed
- const size_type bucket_count_minus_one = bucket_count() - 1;
- size_type bucknum = hash(key) & bucket_count_minus_one;
- size_type insert_pos = ILLEGAL_BUCKET; // where we would insert
- while ( 1 ) { // probe until something happens
- if ( test_empty(bucknum) ) { // bucket is empty
- if ( insert_pos == ILLEGAL_BUCKET ) // found no prior place to insert
- return pair(ILLEGAL_BUCKET, bucknum);
- else
- return pair(ILLEGAL_BUCKET, insert_pos);
-
- } else if ( test_deleted(bucknum) ) {// keep searching, but mark to insert
- if ( insert_pos == ILLEGAL_BUCKET )
- insert_pos = bucknum;
-
- } else if ( equals(key, get_key(table[bucknum])) ) {
- return pair(bucknum, ILLEGAL_BUCKET);
- }
- ++num_probes; // we're doing another probe
- bucknum = (bucknum + JUMP_(key, num_probes)) & bucket_count_minus_one;
- assert(num_probes < bucket_count()
- && "Hashtable is full: an error in key_equal<> or hash<>");
- }
- }
-
- public:
- iterator find(const key_type& key) {
- if ( size() == 0 ) return end();
- pair pos = find_position(key);
- if ( pos.first == ILLEGAL_BUCKET ) // alas, not there
- return end();
- else
- return iterator(this, table + pos.first, table + num_buckets, false);
- }
-
- const_iterator find(const key_type& key) const {
- if ( size() == 0 ) return end();
- pair pos = find_position(key);
- if ( pos.first == ILLEGAL_BUCKET ) // alas, not there
- return end();
- else
- return const_iterator(this, table + pos.first, table+num_buckets, false);
- }
-
- // This is a tr1 method: the bucket a given key is in, or what bucket
- // it would be put in, if it were to be inserted. Shrug.
- size_type bucket(const key_type& key) const {
- pair pos = find_position(key);
- return pos.first == ILLEGAL_BUCKET ? pos.second : pos.first;
- }
-
- // Counts how many elements have key key. For maps, it's either 0 or 1.
- size_type count(const key_type &key) const {
- pair pos = find_position(key);
- return pos.first == ILLEGAL_BUCKET ? 0 : 1;
- }
-
- // Likewise, equal_range doesn't really make sense for us. Oh well.
- pair equal_range(const key_type& key) {
- iterator pos = find(key); // either an iterator or end
- if (pos == end()) {
- return pair(pos, pos);
- } else {
- const iterator startpos = pos++;
- return pair(startpos, pos);
- }
- }
- pair equal_range(const key_type& key) const {
- const_iterator pos = find(key); // either an iterator or end
- if (pos == end()) {
- return pair(pos, pos);
- } else {
- const const_iterator startpos = pos++;
- return pair(startpos, pos);
- }
- }
-
-
- // INSERTION ROUTINES
- private:
- // Private method used by insert_noresize and find_or_insert.
- iterator insert_at(const_reference obj, size_type pos) {
- if (size() >= max_size())
- throw std::length_error("insert overflow");
- if ( test_deleted(pos) ) { // just replace if it's been del.
- // shrug: shouldn't need to be const.
- const_iterator delpos(this, table + pos, table + num_buckets, false);
- clear_deleted(delpos);
- assert( num_deleted > 0);
- --num_deleted; // used to be, now it isn't
- } else {
- ++num_elements; // replacing an empty bucket
- }
- set_value(&table[pos], obj);
- return iterator(this, table + pos, table + num_buckets, false);
- }
-
- // If you know *this is big enough to hold obj, use this routine
- pair insert_noresize(const_reference obj) {
- // First, double-check we're not inserting delkey or emptyval
- assert((!settings.use_empty() || !equals(get_key(obj),
- get_key(val_info.emptyval)))
- && "Inserting the empty key");
- assert((!settings.use_deleted() || !equals(get_key(obj), key_info.delkey))
- && "Inserting the deleted key");
- const pair pos = find_position(get_key(obj));
- if ( pos.first != ILLEGAL_BUCKET) { // object was already there
- return pair(iterator(this, table + pos.first,
- table + num_buckets, false),
- false); // false: we didn't insert
- } else { // pos.second says where to put it
- return pair(insert_at(obj, pos.second), true);
- }
- }
-
- // Specializations of insert(it, it) depending on the power of the iterator:
- // (1) Iterator supports operator-, resize before inserting
- template
- void insert(ForwardIterator f, ForwardIterator l, STL_NAMESPACE::forward_iterator_tag) {
- size_t dist = STL_NAMESPACE::distance(f, l);
- if (dist >= (std::numeric_limits::max)())
- throw std::length_error("insert-range overflow");
- resize_delta(static_cast(dist));
- for ( ; dist > 0; --dist, ++f) {
- insert_noresize(*f);
- }
- }
-
- // (2) Arbitrary iterator, can't tell how much to resize
- template
- void insert(InputIterator f, InputIterator l, STL_NAMESPACE::input_iterator_tag) {
- for ( ; f != l; ++f)
- insert(*f);
- }
-
- public:
- // This is the normal insert routine, used by the outside world
- pair insert(const_reference obj) {
- resize_delta(1); // adding an object, grow if need be
- return insert_noresize(obj);
- }
-
- // When inserting a lot at a time, we specialize on the type of iterator
- template
- void insert(InputIterator f, InputIterator l) {
- // specializes on iterator type
- insert(f, l, typename STL_NAMESPACE::iterator_traits::iterator_category());
- }
-
- // DefaultValue is a functor that takes a key and returns a value_type
- // representing the default value to be inserted if none is found.
- template
- value_type& find_or_insert(const key_type& key) {
- // First, double-check we're not inserting emptykey or delkey
- assert((!settings.use_empty() || !equals(key, get_key(val_info.emptyval)))
- && "Inserting the empty key");
- assert((!settings.use_deleted() || !equals(key, key_info.delkey))
- && "Inserting the deleted key");
- const pair pos = find_position(key);
- DefaultValue default_value;
- if ( pos.first != ILLEGAL_BUCKET) { // object was already there
- return table[pos.first];
- } else if (resize_delta(1)) { // needed to rehash to make room
- // Since we resized, we can't use pos, so recalculate where to insert.
- return *insert_noresize(default_value(key)).first;
- } else { // no need to rehash, insert right here
- return *insert_at(default_value(key), pos.second);
- }
- }
-
- // DELETION ROUTINES
- size_type erase(const key_type& key) {
- // First, double-check we're not trying to erase delkey or emptyval.
- assert((!settings.use_empty() || !equals(key, get_key(val_info.emptyval)))
- && "Erasing the empty key");
- assert((!settings.use_deleted() || !equals(key, key_info.delkey))
- && "Erasing the deleted key");
- const_iterator pos = find(key); // shrug: shouldn't need to be const
- if ( pos != end() ) {
- assert(!test_deleted(pos)); // or find() shouldn't have returned it
- set_deleted(pos);
- ++num_deleted;
- settings.set_consider_shrink(true); // will think about shrink after next insert
- return 1; // because we deleted one thing
- } else {
- return 0; // because we deleted nothing
- }
- }
-
- // We return the iterator past the deleted item.
- void erase(iterator pos) {
- if ( pos == end() ) return; // sanity check
- if ( set_deleted(pos) ) { // true if object has been newly deleted
- ++num_deleted;
- settings.set_consider_shrink(true); // will think about shrink after next insert
- }
- }
-
- void erase(iterator f, iterator l) {
- for ( ; f != l; ++f) {
- if ( set_deleted(f) ) // should always be true
- ++num_deleted;
- }
- settings.set_consider_shrink(true); // will think about shrink after next insert
- }
-
- // We allow you to erase a const_iterator just like we allow you to
- // erase an iterator. This is in parallel to 'delete': you can delete
- // a const pointer just like a non-const pointer. The logic is that
- // you can't use the object after it's erased anyway, so it doesn't matter
- // if it's const or not.
- void erase(const_iterator pos) {
- if ( pos == end() ) return; // sanity check
- if ( set_deleted(pos) ) { // true if object has been newly deleted
- ++num_deleted;
- settings.set_consider_shrink(true); // will think about shrink after next insert
- }
- }
- void erase(const_iterator f, const_iterator l) {
- for ( ; f != l; ++f) {
- if ( set_deleted(f) ) // should always be true
- ++num_deleted;
- }
- settings.set_consider_shrink(true); // will think about shrink after next insert
- }
-
-
- // COMPARISON
- bool operator==(const dense_hashtable& ht) const {
- if (size() != ht.size()) {
- return false;
- } else if (this == &ht) {
- return true;
- } else {
- // Iterate through the elements in "this" and see if the
- // corresponding element is in ht
- for ( const_iterator it = begin(); it != end(); ++it ) {
- const_iterator it2 = ht.find(get_key(*it));
- if ((it2 == ht.end()) || (*it != *it2)) {
- return false;
- }
- }
- return true;
- }
- }
- bool operator!=(const dense_hashtable& ht) const {
- return !(*this == ht);
- }
-
-
- // I/O
- // We support reading and writing hashtables to disk. Alas, since
- // I don't know how to write a hasher or key_equal, you have to make
- // sure everything but the table is the same. We compact before writing
- //
- // NOTE: These functions are currently TODO. They've not been implemented.
- bool write_metadata(FILE * /*fp*/) {
- squash_deleted(); // so we don't have to worry about delkey
- return false; // TODO
- }
-
- bool read_metadata(FILE* /*fp*/) {
- num_deleted = 0; // since we got rid before writing
- assert(settings.use_empty() && "empty_key not set for read_metadata");
- if (table) val_info.deallocate(table, num_buckets); // we'll make our own
- // TODO: read magic number
- // TODO: read num_buckets
- settings.reset_thresholds(bucket_count());
- table = val_info.allocate(num_buckets);
- assert(table);
- fill_range_with_empty(table, table + num_buckets);
- // TODO: read num_elements
- for ( size_type i = 0; i < num_elements; ++i ) {
- // TODO: read bucket_num
- // TODO: set with non-empty, non-deleted value
- }
- return false; // TODO
- }
-
- // If your keys and values are simple enough, we can write them to
- // disk for you. "simple enough" means value_type is a POD type
- // that contains no pointers. However, we don't try to normalize
- // endianness
- bool write_nopointer_data(FILE *fp) const {
- for ( const_iterator it = begin(); it != end(); ++it ) {
- // TODO: skip empty/deleted values
- if ( !fwrite(&*it, sizeof(*it), 1, fp) ) return false;
- }
- return false;
- }
-
- // When reading, we have to override the potential const-ness of *it
- bool read_nopointer_data(FILE *fp) {
- for ( iterator it = begin(); it != end(); ++it ) {
- // TODO: skip empty/deleted values
- if ( !fread(reinterpret_cast(&(*it)), sizeof(*it), 1, fp) )
- return false;
- }
- return false;
- }
-
- private:
- template
- class alloc_impl : public A {
- public:
- typedef typename A::pointer pointer;
- typedef typename A::size_type size_type;
-
- // Convert a normal allocator to one that has realloc_or_die()
- alloc_impl(const A& a) : A(a) { }
-
- // realloc_or_die should only be used when using the default
- // allocator (libc_allocator_with_realloc).
- pointer realloc_or_die(pointer /*ptr*/, size_type /*n*/) {
- fprintf(stderr, "realloc_or_die is only supported for "
- "libc_allocator_with_realloc");
- exit(1);
- return NULL;
- }
- };
-
- // A template specialization of alloc_impl for
- // libc_allocator_with_realloc that can handle realloc_or_die.
- template
- class alloc_impl >
- : public libc_allocator_with_realloc {
- public:
- typedef typename libc_allocator_with_realloc::pointer pointer;
- typedef typename libc_allocator_with_realloc::size_type size_type;
-
- alloc_impl(const libc_allocator_with_realloc& a)
- : libc_allocator_with_realloc(a) { }
-
- pointer realloc_or_die(pointer ptr, size_type n) {
- pointer retval = this->reallocate(ptr, n);
- if (retval == NULL) {
- // We really should use PRIuS here, but I don't want to have to add
- // a whole new configure option, with concomitant macro namespace
- // pollution, just to print this (unlikely) error message. So I cast.
- fprintf(stderr, "sparsehash: FATAL ERROR: failed to reallocate "
- "%lu elements for ptr %p",
- static_cast(n), ptr);
- exit(1);
- }
- return retval;
- }
- };
-
- // Package allocator with emptyval to eliminate memory needed for
- // the zero-size allocator.
- // If new fields are added to this class, we should add them to
- // operator= and swap.
- class ValInfo : public alloc_impl {
- public:
- typedef typename alloc_impl::value_type value_type;
-
- ValInfo(const alloc_impl& a)
- : alloc_impl(a), emptyval() { }
- ValInfo(const ValInfo& v)
- : alloc_impl(v), emptyval(v.emptyval) { }
-
- value_type emptyval; // which key marks unused entries
- };
-
-
- // Package functors with another class to eliminate memory needed for
- // zero-size functors. Since ExtractKey and hasher's operator() might
- // have the same function signature, they must be packaged in
- // different classes.
- struct Settings :
- sh_hashtable_settings {
- explicit Settings(const hasher& hf)
- : sh_hashtable_settings(
- hf, HT_OCCUPANCY_PCT / 100.0f, HT_EMPTY_PCT / 100.0f) {}
- };
-
- // Packages ExtractKey and SetKey functors.
- class KeyInfo : public ExtractKey, public SetKey, public key_equal {
- public:
- KeyInfo(const ExtractKey& ek, const SetKey& sk, const key_equal& eq)
- : ExtractKey(ek),
- SetKey(sk),
- key_equal(eq) {
- }
-
- // We want to return the exact same type as ExtractKey: Key or const Key&
- typename ExtractKey::result_type get_key(const_reference v) const {
- return ExtractKey::operator()(v);
- }
- void set_key(pointer v, const key_type& k) const {
- SetKey::operator()(v, k);
- }
- bool equals(const key_type& a, const key_type& b) const {
- return key_equal::operator()(a, b);
- }
-
- // Which key marks deleted entries.
- // TODO(csilvers): make a pointer, and get rid of use_deleted (benchmark!)
- typename remove_const::type delkey;
- };
-
- // Utility functions to access the templated operators
- size_type hash(const key_type& v) const {
- return settings.hash(v);
- }
- bool equals(const key_type& a, const key_type& b) const {
- return key_info.equals(a, b);
- }
- typename ExtractKey::result_type get_key(const_reference v) const {
- return key_info.get_key(v);
- }
- void set_key(pointer v, const key_type& k) const {
- key_info.set_key(v, k);
- }
-
- private:
- // Actual data
- Settings settings;
- KeyInfo key_info;
-
- size_type num_deleted; // how many occupied buckets are marked deleted
- size_type num_elements;
- size_type num_buckets;
- ValInfo val_info; // holds emptyval, and also the allocator
- pointer table;
-};
-
-
-// We need a global swap as well
-template
-inline void swap(dense_hashtable &x,
- dense_hashtable &y) {
- x.swap(y);
-}
-
-#undef JUMP_
-
-template
-const typename dense_hashtable::size_type
- dense_hashtable::ILLEGAL_BUCKET;
-
-// How full we let the table get before we resize. Knuth says .8 is
-// good -- higher causes us to probe too much, though saves memory.
-// However, we go with .5, getting better performance at the cost of
-// more space (a trade-off densehashtable explicitly chooses to make).
-// Feel free to play around with different values, though.
-template
-const int dense_hashtable::HT_OCCUPANCY_PCT = 50;
-
-// How empty we let the table get before we resize lower.
-// It should be less than OCCUPANCY_PCT / 2 or we thrash resizing
-template
-const int dense_hashtable::HT_EMPTY_PCT
- = static_cast(0.4 *
- dense_hashtable::HT_OCCUPANCY_PCT);
-
-_END_GOOGLE_NAMESPACE_
-
-#endif /* _DENSEHASHTABLE_H_ */
diff --git a/external/google/sparsehash/hashtable-common.h b/external/google/sparsehash/hashtable-common.h
deleted file mode 100644
index e823b12429..0000000000
--- a/external/google/sparsehash/hashtable-common.h
+++ /dev/null
@@ -1,178 +0,0 @@
-// Copyright (c) 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Giao Nguyen
-
-#ifndef UTIL_GTL_HASHTABLE_COMMON_H_
-#define UTIL_GTL_HASHTABLE_COMMON_H_
-
-#include
-
-// Settings contains parameters for growing and shrinking the table.
-// It also packages zero-size functor (ie. hasher).
-
-template
-class sh_hashtable_settings : public HashFunc {
- public:
- typedef Key key_type;
- typedef HashFunc hasher;
- typedef SizeType size_type;
-
- public:
- sh_hashtable_settings(const hasher& hf,
- const float ht_occupancy_flt,
- const float ht_empty_flt)
- : hasher(hf),
- enlarge_threshold_(0),
- shrink_threshold_(0),
- consider_shrink_(false),
- use_empty_(false),
- use_deleted_(false),
- num_ht_copies_(0) {
- set_enlarge_factor(ht_occupancy_flt);
- set_shrink_factor(ht_empty_flt);
- }
-
- size_type hash(const key_type& v) const {
- return hasher::operator()(v);
- }
-
- float enlarge_factor() const {
- return enlarge_factor_;
- }
- void set_enlarge_factor(float f) {
- enlarge_factor_ = f;
- }
- float shrink_factor() const {
- return shrink_factor_;
- }
- void set_shrink_factor(float f) {
- shrink_factor_ = f;
- }
-
- size_type enlarge_threshold() const {
- return enlarge_threshold_;
- }
- void set_enlarge_threshold(size_type t) {
- enlarge_threshold_ = t;
- }
- size_type shrink_threshold() const {
- return shrink_threshold_;
- }
- void set_shrink_threshold(size_type t) {
- shrink_threshold_ = t;
- }
-
- size_type enlarge_size(size_type x) const {
- return static_cast(x * enlarge_factor_);
- }
- size_type shrink_size(size_type x) const {
- return static_cast(x * shrink_factor_);
- }
-
- bool consider_shrink() const {
- return consider_shrink_;
- }
- void set_consider_shrink(bool t) {
- consider_shrink_ = t;
- }
-
- bool use_empty() const {
- return use_empty_;
- }
- void set_use_empty(bool t) {
- use_empty_ = t;
- }
-
- bool use_deleted() const {
- return use_deleted_;
- }
- void set_use_deleted(bool t) {
- use_deleted_ = t;
- }
-
- size_type num_ht_copies() const {
- return static_cast(num_ht_copies_);
- }
- void inc_num_ht_copies() {
- ++num_ht_copies_;
- }
-
- // Reset the enlarge and shrink thresholds
- void reset_thresholds(size_type num_buckets) {
- set_enlarge_threshold(enlarge_size(num_buckets));
- set_shrink_threshold(shrink_size(num_buckets));
- // whatever caused us to reset already considered
- set_consider_shrink(false);
- }
-
- // Caller is resposible for calling reset_threshold right after
- // set_resizing_parameters.
- void set_resizing_parameters(float shrink, float grow) {
- assert(shrink >= 0.0);
- assert(grow <= 1.0);
- if (shrink > grow/2.0f)
- shrink = grow / 2.0f; // otherwise we thrash hashtable size
- set_shrink_factor(shrink);
- set_enlarge_factor(grow);
- }
-
- // This is the smallest size a hashtable can be without being too crowded
- // If you like, you can give a min #buckets as well as a min #elts
- size_type min_buckets(size_type num_elts, size_type min_buckets_wanted) {
- float enlarge = enlarge_factor();
- size_type sz = HT_MIN_BUCKETS; // min buckets allowed
- while ( sz < min_buckets_wanted ||
- num_elts >= static_cast(sz * enlarge) ) {
- // This just prevents overflowing size_type, since sz can exceed
- // max_size() here.
- if (static_cast(sz * 2) < sz) {
- throw std::length_error("resize overflow"); // protect against overflow
- }
- sz *= 2;
- }
- return sz;
- }
-
- private:
- size_type enlarge_threshold_; // table.size() * enlarge_factor
- size_type shrink_threshold_; // table.size() * shrink_factor
- float enlarge_factor_; // how full before resize
- float shrink_factor_; // how empty before resize
- // consider_shrink=true if we should try to shrink before next insert
- bool consider_shrink_;
- bool use_empty_; // used only by densehashtable, not sparsehashtable
- bool use_deleted_; // false until delkey has been set
- // num_ht_copies is a counter incremented every Copy/Move
- unsigned int num_ht_copies_;
-};
-
-#endif // UTIL_GTL_HASHTABLE_COMMON_H_
diff --git a/external/google/sparsehash/libc_allocator_with_realloc.h b/external/google/sparsehash/libc_allocator_with_realloc.h
deleted file mode 100644
index 4ba1db48b5..0000000000
--- a/external/google/sparsehash/libc_allocator_with_realloc.h
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright (c) 2010, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Guilin Chen
-
-#ifndef UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_
-#define UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_
-
-#include
-
-#include // for malloc/realloc/free
-#include // for ptrdiff_t
-
-
-_START_GOOGLE_NAMESPACE_
-
-template
-class libc_allocator_with_realloc {
- public:
- typedef T value_type;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
-
- typedef T* pointer;
- typedef const T* const_pointer;
- typedef T& reference;
- typedef const T& const_reference;
-
- libc_allocator_with_realloc() {}
- libc_allocator_with_realloc(const libc_allocator_with_realloc&) {}
- ~libc_allocator_with_realloc() {}
-
- pointer address(reference r) const { return &r; }
- const_pointer address(const_reference r) const { return &r; }
-
- pointer allocate(size_type n, const_pointer = 0) {
- return static_cast(malloc(n * sizeof(value_type)));
- }
- void deallocate(pointer p, size_type) {
- free(p);
- }
- pointer reallocate(pointer p, size_type n) {
- return static_cast(realloc(p, n * sizeof(value_type)));
- }
-
- size_type max_size() const {
- return static_cast(-1) / sizeof(value_type);
- }
-
- void construct(pointer p, const value_type& val) {
- new(p) value_type(val);
- }
- void destroy(pointer p) { p->~value_type(); }
-
- template
- libc_allocator_with_realloc(const libc_allocator_with_realloc&) {}
-
- template
- struct rebind {
- typedef libc_allocator_with_realloc other;
- };
-};
-
-// libc_allocator_with_realloc specialization.
-template<>
-class libc_allocator_with_realloc {
- public:
- typedef void value_type;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef void* pointer;
- typedef const void* const_pointer;
-
- template
- struct rebind {
- typedef libc_allocator_with_realloc other;
- };
-};
-
-template
-inline bool operator==(const libc_allocator_with_realloc&,
- const libc_allocator_with_realloc&) {
- return true;
-}
-
-template
-inline bool operator!=(const libc_allocator_with_realloc&,
- const libc_allocator_with_realloc&) {
- return false;
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#endif // UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_
diff --git a/external/google/sparsehash/os_config.h b/external/google/sparsehash/os_config.h
deleted file mode 100644
index 0a397192d3..0000000000
--- a/external/google/sparsehash/os_config.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _MSC_VER
-//non-win version
-
-/* Define to 1 if you have the header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if the system has the type `uint16_t'. */
-#define HAVE_UINT16_T 1
-
-/* Define to 1 if the system has the type `u_int16_t'. */
-#define HAVE_U_INT16_T 1
-
-/* Define to 1 if the system has the type `__uint16'. */
-/* #undef HAVE___UINT16 */
-
-#else
-//win version
-
-/* Define to 1 if you have the header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if the system has the type `uint16_t'. */
-#undef HAVE_UINT16_T
-
-/* Define to 1 if the system has the type `u_int16_t'. */
-#undef HAVE_U_INT16_T
-
-/* Define to 1 if the system has the type `__uint16'. */
-#define HAVE___UINT16 1
-
-#endif
diff --git a/external/google/sparsehash/sparseconfig.h b/external/google/sparsehash/sparseconfig.h
deleted file mode 100644
index fbfa328ae1..0000000000
--- a/external/google/sparsehash/sparseconfig.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * NOTE: This file is for internal use only.
- * Do not use these #defines in your own program!
- */
-
-/* Namespace for Google classes */
-#define GOOGLE_NAMESPACE ::google
-
-/* the location of the header defining hash functions */
-#define HASH_FUN_H
-
-/* the namespace of the hash<> function */
-#define HASH_NAMESPACE std
-
-/* Define to 1 if the system has the type `long long'. */
-#define HAVE_LONG_LONG 1
-
-/* Define to 1 if you have the `memcpy' function. */
-#define HAVE_MEMCPY 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* The system-provided hash function including the namespace. */
-#define SPARSEHASH_HASH HASH_NAMESPACE::hash
-
-/* The system-provided hash function, in namespace HASH_NAMESPACE. */
-#define SPARSEHASH_HASH_NO_NAMESPACE hash
-
-/* the namespace where STL code like vector<> is defined */
-#define STL_NAMESPACE std
-
-/* Stops putting the code inside the Google namespace */
-#define _END_GOOGLE_NAMESPACE_ }
-
-/* Puts following code inside the Google namespace */
-#define _START_GOOGLE_NAMESPACE_ namespace google {
-
-#include "os_config.h"
diff --git a/external/google/sparsehash/sparseconfig_win.h b/external/google/sparsehash/sparseconfig_win.h
deleted file mode 100644
index a4607139ee..0000000000
--- a/external/google/sparsehash/sparseconfig_win.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * NOTE: This file is for internal use only.
- * Do not use these #defines in your own program!
- */
-
-/* Namespace for Google classes */
-#define GOOGLE_NAMESPACE ::google
-
-/* the location of the header defining hash functions */
-#define HASH_FUN_H
-
-/* the namespace of the hash<> function */
-#define HASH_NAMESPACE std
-
-/* Define to 1 if the system has the type `long long'. */
-#define HAVE_LONG_LONG 1
-
-/* Define to 1 if you have the `memcpy' function. */
-#define HAVE_MEMCPY 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* The system-provided hash function including the namespace. */
-#define SPARSEHASH_HASH HASH_NAMESPACE::hash
-
-/* The system-provided hash function, in namespace HASH_NAMESPACE. */
-#define SPARSEHASH_HASH_NO_NAMESPACE hash
-
-/* the namespace where STL code like vector<> is defined */
-#define STL_NAMESPACE std
-
-/* Stops putting the code inside the Google namespace */
-#define _END_GOOGLE_NAMESPACE_ }
-
-/* Puts following code inside the Google namespace */
-#define _START_GOOGLE_NAMESPACE_ namespace google {
diff --git a/external/google/sparsehash/sparsehashtable.h b/external/google/sparsehash/sparsehashtable.h
deleted file mode 100644
index 9f2d1443dc..0000000000
--- a/external/google/sparsehash/sparsehashtable.h
+++ /dev/null
@@ -1,1190 +0,0 @@
-// Copyright (c) 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Craig Silverstein
-//
-// A sparse hashtable is a particular implementation of
-// a hashtable: one that is meant to minimize memory use.
-// It does this by using a *sparse table* (cf sparsetable.h),
-// which uses between 1 and 2 bits to store empty buckets
-// (we may need another bit for hashtables that support deletion).
-//
-// When empty buckets are so cheap, an appealing hashtable
-// implementation is internal probing, in which the hashtable
-// is a single table, and collisions are resolved by trying
-// to insert again in another bucket. The most cache-efficient
-// internal probing schemes are linear probing (which suffers,
-// alas, from clumping) and quadratic probing, which is what
-// we implement by default.
-//
-// Deleted buckets are a bit of a pain. We have to somehow mark
-// deleted buckets (the probing must distinguish them from empty
-// buckets). The most principled way is to have another bitmap,
-// but that's annoying and takes up space. Instead we let the
-// user specify an "impossible" key. We set deleted buckets
-// to have the impossible key.
-//
-// Note it is possible to change the value of the delete key
-// on the fly; you can even remove it, though after that point
-// the hashtable is insert_only until you set it again.
-//
-// You probably shouldn't use this code directly. Use
-// or instead.
-//
-// You can modify the following, below:
-// HT_OCCUPANCY_PCT -- how full before we double size
-// HT_EMPTY_PCT -- how empty before we halve size
-// HT_MIN_BUCKETS -- smallest bucket size
-// HT_DEFAULT_STARTING_BUCKETS -- default bucket size at construct-time
-//
-// You can also change enlarge_factor (which defaults to
-// HT_OCCUPANCY_PCT), and shrink_factor (which defaults to
-// HT_EMPTY_PCT) with set_resizing_parameters().
-//
-// How to decide what values to use?
-// shrink_factor's default of .4 * OCCUPANCY_PCT, is probably good.
-// HT_MIN_BUCKETS is probably unnecessary since you can specify
-// (indirectly) the starting number of buckets at construct-time.
-// For enlarge_factor, you can use this chart to try to trade-off
-// expected lookup time to the space taken up. By default, this
-// code uses quadratic probing, though you can change it to linear
-// via _JUMP below if you really want to.
-//
-// From http://www.augustana.ca/~mohrj/courses/1999.fall/csc210/lecture_notes/hashing.html
-// NUMBER OF PROBES / LOOKUP Successful Unsuccessful
-// Quadratic collision resolution 1 - ln(1-L) - L/2 1/(1-L) - L - ln(1-L)
-// Linear collision resolution [1+1/(1-L)]/2 [1+1/(1-L)2]/2
-//
-// -- enlarge_factor -- 0.10 0.50 0.60 0.75 0.80 0.90 0.99
-// QUADRATIC COLLISION RES.
-// probes/successful lookup 1.05 1.44 1.62 2.01 2.21 2.85 5.11
-// probes/unsuccessful lookup 1.11 2.19 2.82 4.64 5.81 11.4 103.6
-// LINEAR COLLISION RES.
-// probes/successful lookup 1.06 1.5 1.75 2.5 3.0 5.5 50.5
-// probes/unsuccessful lookup 1.12 2.5 3.6 8.5 13.0 50.0 5000.0
-//
-// The value type is required to be copy constructible and default
-// constructible, but it need not be (and commonly isn't) assignable.
-
-#ifndef _SPARSEHASHTABLE_H_
-#define _SPARSEHASHTABLE_H_
-
-#ifndef SPARSEHASH_STAT_UPDATE
-#define SPARSEHASH_STAT_UPDATE(x) ((void) 0)
-#endif
-
-// The probing method
-// Linear probing
-// #define JUMP_(key, num_probes) ( 1 )
-// Quadratic probing
-#define JUMP_(key, num_probes) ( num_probes )
-
-#include
-#include
-#include // For swap(), eg
-#include // For length_error
-#include // for facts about iterator tags
-#include // for numeric_limits<>
-#include // for pair<>
-#include
-#include // Since that's basically what we are
-
-_START_GOOGLE_NAMESPACE_
-
-using STL_NAMESPACE::pair;
-
-// The smaller this is, the faster lookup is (because the group bitmap is
-// smaller) and the faster insert is, because there's less to move.
-// On the other hand, there are more groups. Since group::size_type is
-// a short, this number should be of the form 32*x + 16 to avoid waste.
-static const u_int16_t DEFAULT_GROUP_SIZE = 48; // fits in 1.5 words
-
-// Hashtable class, used to implement the hashed associative containers
-// hash_set and hash_map.
-//
-// Value: what is stored in the table (each bucket is a Value).
-// Key: something in a 1-to-1 correspondence to a Value, that can be used
-// to search for a Value in the table (find() takes a Key).
-// HashFcn: Takes a Key and returns an integer, the more unique the better.
-// ExtractKey: given a Value, returns the unique Key associated with it.
-// Must inherit from unary_function, or at least have a
-// result_type enum indicating the return type of operator().
-// SetKey: given a Value* and a Key, modifies the value such that
-// ExtractKey(value) == key. We guarantee this is only called
-// with key == deleted_key.
-// EqualKey: Given two Keys, says whether they are the same (that is,
-// if they are both associated with the same Value).
-// Alloc: STL allocator to use to allocate memory.
-
-template
-class sparse_hashtable;
-
-template
-struct sparse_hashtable_iterator;
-
-template
-struct sparse_hashtable_const_iterator;
-
-// As far as iterating, we're basically just a sparsetable
-// that skips over deleted elements.
-template
-struct sparse_hashtable_iterator {
- private:
- typedef typename A::template rebind::other value_alloc_type;
-
- public:
- typedef sparse_hashtable_iterator iterator;
- typedef sparse_hashtable_const_iterator const_iterator;
- typedef typename sparsetable::nonempty_iterator
- st_iterator;
-
- typedef STL_NAMESPACE::forward_iterator_tag iterator_category;
- typedef V value_type;
- typedef typename value_alloc_type::difference_type difference_type;
- typedef typename value_alloc_type::size_type size_type;
- typedef typename value_alloc_type::reference reference;
- typedef typename value_alloc_type::pointer pointer;
-
- // "Real" constructor and default constructor
- sparse_hashtable_iterator(const sparse_hashtable *h,
- st_iterator it, st_iterator it_end)
- : ht(h), pos(it), end(it_end) { advance_past_deleted(); }
- sparse_hashtable_iterator() { } // not ever used internally
- // The default destructor is fine; we don't define one
- // The default operator= is fine; we don't define one
-
- // Happy dereferencer
- reference operator*() const { return *pos; }
- pointer operator->() const { return &(operator*()); }
-
- // Arithmetic. The only hard part is making sure that
- // we're not on a marked-deleted array element
- void advance_past_deleted() {
- while ( pos != end && ht->test_deleted(*this) )
- ++pos;
- }
- iterator& operator++() {
- assert(pos != end); ++pos; advance_past_deleted(); return *this;
- }
- iterator operator++(int) { iterator tmp(*this); ++*this; return tmp; }
-
- // Comparison.
- bool operator==(const iterator& it) const { return pos == it.pos; }
- bool operator!=(const iterator& it) const { return pos != it.pos; }
-
-
- // The actual data
- const sparse_hashtable *ht;
- st_iterator pos, end;
-};
-
-// Now do it all again, but with const-ness!
-template
-struct sparse_hashtable_const_iterator {
- private:
- typedef typename A::template rebind::other value_alloc_type;
-
- public:
- typedef sparse_hashtable_iterator iterator;
- typedef sparse_hashtable_const_iterator const_iterator;
- typedef typename sparsetable::const_nonempty_iterator
- st_iterator;
-
- typedef STL_NAMESPACE::forward_iterator_tag iterator_category;
- typedef V value_type;
- typedef typename value_alloc_type::difference_type difference_type;
- typedef typename value_alloc_type::size_type size_type;
- typedef typename value_alloc_type::const_reference reference;
- typedef typename value_alloc_type::const_pointer pointer;
-
- // "Real" constructor and default constructor
- sparse_hashtable_const_iterator(const sparse_hashtable *h,
- st_iterator it, st_iterator it_end)
- : ht(h), pos(it), end(it_end) { advance_past_deleted(); }
- // This lets us convert regular iterators to const iterators
- sparse_hashtable_const_iterator() { } // never used internally
- sparse_hashtable_const_iterator(const iterator &it)
- : ht(it.ht), pos(it.pos), end(it.end) { }
- // The default destructor is fine; we don't define one
- // The default operator= is fine; we don't define one
-
- // Happy dereferencer
- reference operator*() const { return *pos; }
- pointer operator->() const { return &(operator*()); }
-
- // Arithmetic. The only hard part is making sure that
- // we're not on a marked-deleted array element
- void advance_past_deleted() {
- while ( pos != end && ht->test_deleted(*this) )
- ++pos;
- }
- const_iterator& operator++() {
- assert(pos != end); ++pos; advance_past_deleted(); return *this;
- }
- const_iterator operator++(int) { const_iterator tmp(*this); ++*this; return tmp; }
-
- // Comparison.
- bool operator==(const const_iterator& it) const { return pos == it.pos; }
- bool operator!=(const const_iterator& it) const { return pos != it.pos; }
-
-
- // The actual data
- const sparse_hashtable *ht;
- st_iterator pos, end;
-};
-
-// And once again, but this time freeing up memory as we iterate
-template
-struct sparse_hashtable_destructive_iterator {
- private:
- typedef typename A::template rebind