passenger_dudemeister 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/DEVELOPERS.TXT +113 -0
- data/INSTALL +6 -0
- data/LICENSE +19 -0
- data/NEWS +429 -0
- data/PACKAGING.TXT +25 -0
- data/README +45 -0
- data/Rakefile +56 -0
- data/bin/passenger +32 -0
- data/bin/passenger-config +46 -0
- data/bin/passenger-install-apache2-module +237 -0
- data/bin/passenger-install-nginx-module +476 -0
- data/bin/passenger-make-enterprisey +82 -0
- data/bin/passenger-memory-stats +171 -0
- data/bin/passenger-status +211 -0
- data/build/agents.rb +80 -0
- data/build/apache2.rb +168 -0
- data/build/basics.rb +105 -0
- data/build/common_library.rb +268 -0
- data/build/config.rb +42 -0
- data/build/cplusplus_support.rb +61 -0
- data/build/cxx_tests.rb +219 -0
- data/build/documentation.rb +84 -0
- data/build/gempackagetask.rb +99 -0
- data/build/integration_tests.rb +64 -0
- data/build/misc.rb +153 -0
- data/build/nginx.rb +72 -0
- data/build/oxt_tests.rb +59 -0
- data/build/packagetask.rb +186 -0
- data/build/packaging.rb +194 -0
- data/build/rake_extensions.rb +182 -0
- data/build/rdoctask.rb +209 -0
- data/build/rpm.rb +98 -0
- data/build/ruby_extension.rb +52 -0
- data/build/ruby_tests.rb +49 -0
- data/build/test_basics.rb +43 -0
- data/debian/README.Debian +15 -0
- data/debian/changelog +185 -0
- data/debian/compat +1 -0
- data/debian/control +49 -0
- data/debian/copyright +20 -0
- data/debian/libapache2-mod-passenger.install +1 -0
- data/debian/libapache2-mod-passenger.postinst +36 -0
- data/debian/libapache2-mod-passenger.prerm +15 -0
- data/debian/passenger-common.install +4 -0
- data/debian/passenger.conf +4 -0
- data/debian/passenger.load +1 -0
- data/debian/prerm +2 -0
- data/debian/rules +37 -0
- data/debian/watch +3 -0
- data/dev/copy_boost_headers.rb +155 -0
- data/dev/find_owner_pipe_leaks.rb +128 -0
- data/dev/render_error_pages.rb +116 -0
- data/doc/ApplicationPool algorithm.txt +615 -0
- data/doc/Architectural overview.html +1 -0
- data/doc/Architectural overview.txt +334 -0
- data/doc/Doxyfile +241 -0
- data/doc/Security of user switching support.html +1 -0
- data/doc/Security of user switching support.txt +197 -0
- data/doc/Users guide Apache.html +1 -0
- data/doc/Users guide Apache.txt +2208 -0
- data/doc/Users guide Nginx.html +1 -0
- data/doc/Users guide Nginx.txt +1394 -0
- data/doc/Users guide Standalone.html +1 -0
- data/doc/Users guide Standalone.txt +40 -0
- data/doc/definitions.h +5 -0
- data/doc/images/by_sa.png +0 -0
- data/doc/images/conservative_spawning.png +0 -0
- data/doc/images/conservative_spawning.svg +248 -0
- data/doc/images/icons/README +5 -0
- data/doc/images/icons/callouts/1.png +0 -0
- data/doc/images/icons/callouts/10.png +0 -0
- data/doc/images/icons/callouts/11.png +0 -0
- data/doc/images/icons/callouts/12.png +0 -0
- data/doc/images/icons/callouts/13.png +0 -0
- data/doc/images/icons/callouts/14.png +0 -0
- data/doc/images/icons/callouts/15.png +0 -0
- data/doc/images/icons/callouts/2.png +0 -0
- data/doc/images/icons/callouts/3.png +0 -0
- data/doc/images/icons/callouts/4.png +0 -0
- data/doc/images/icons/callouts/5.png +0 -0
- data/doc/images/icons/callouts/6.png +0 -0
- data/doc/images/icons/callouts/7.png +0 -0
- data/doc/images/icons/callouts/8.png +0 -0
- data/doc/images/icons/callouts/9.png +0 -0
- data/doc/images/icons/caution.png +0 -0
- data/doc/images/icons/example.png +0 -0
- data/doc/images/icons/home.png +0 -0
- data/doc/images/icons/important.png +0 -0
- data/doc/images/icons/next.png +0 -0
- data/doc/images/icons/note.png +0 -0
- data/doc/images/icons/prev.png +0 -0
- data/doc/images/icons/tip.png +0 -0
- data/doc/images/icons/up.png +0 -0
- data/doc/images/icons/warning.png +0 -0
- data/doc/images/passenger_architecture.png +0 -0
- data/doc/images/passenger_architecture.svg +401 -0
- data/doc/images/phusion_banner.png +0 -0
- data/doc/images/smart-lv2.png +0 -0
- data/doc/images/smart-lv2.svg +320 -0
- data/doc/images/spawn_server_architecture.png +0 -0
- data/doc/images/spawn_server_architecture.svg +655 -0
- data/doc/images/typical_isolated_web_application.png +0 -0
- data/doc/images/typical_isolated_web_application.svg +213 -0
- data/doc/rdoc/classes/ConditionVariable.html +215 -0
- data/doc/rdoc/classes/Exception.html +120 -0
- data/doc/rdoc/classes/GC.html +113 -0
- data/doc/rdoc/classes/IO.html +221 -0
- data/doc/rdoc/classes/PhusionPassenger.html +397 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractInstaller.html +180 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractRequestHandler.html +647 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer.html +654 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer/InvalidPassword.html +92 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerAlreadyStarted.html +97 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerError.html +96 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerNotStarted.html +97 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer/UnknownMessage.html +96 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractServerCollection.html +619 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools.html +142 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/MemoryStats.html +368 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/MemoryStats/Process.html +231 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance.html +588 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/CorruptedDirectoryError.html +92 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/GenerationsAbsentError.html +92 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/Group.html +147 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/Process.html +279 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/RoleDeniedError.html +92 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/StaleDirectoryError.html +92 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/Stats.html +123 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/UnsupportedGenerationStructureVersionError.html +92 -0
- data/doc/rdoc/classes/PhusionPassenger/AnalyticsLogger.html +341 -0
- data/doc/rdoc/classes/PhusionPassenger/AnalyticsLogger/Log.html +294 -0
- data/doc/rdoc/classes/PhusionPassenger/AnalyticsLogger/SharedData.html +199 -0
- data/doc/rdoc/classes/PhusionPassenger/AppInitError.html +155 -0
- data/doc/rdoc/classes/PhusionPassenger/AppProcess.html +367 -0
- data/doc/rdoc/classes/PhusionPassenger/ClassicRails.html +95 -0
- data/doc/rdoc/classes/PhusionPassenger/ClassicRails/ApplicationSpawner.html +351 -0
- data/doc/rdoc/classes/PhusionPassenger/ClassicRails/ApplicationSpawner/Error.html +98 -0
- data/doc/rdoc/classes/PhusionPassenger/ClassicRails/CGIFixed.html +200 -0
- data/doc/rdoc/classes/PhusionPassenger/ClassicRails/FrameworkSpawner.html +410 -0
- data/doc/rdoc/classes/PhusionPassenger/ClassicRails/FrameworkSpawner/Error.html +98 -0
- data/doc/rdoc/classes/PhusionPassenger/ClassicRails/RequestHandler.html +156 -0
- data/doc/rdoc/classes/PhusionPassenger/ClassicRailsExtensions.html +115 -0
- data/doc/rdoc/classes/PhusionPassenger/ClassicRailsExtensions/AnalyticsLogging.html +202 -0
- data/doc/rdoc/classes/PhusionPassenger/ConsoleTextTemplate.html +172 -0
- data/doc/rdoc/classes/PhusionPassenger/DebugLogging.html +273 -0
- data/doc/rdoc/classes/PhusionPassenger/FrameworkInitError.html +145 -0
- data/doc/rdoc/classes/PhusionPassenger/HTMLTemplate.html +162 -0
- data/doc/rdoc/classes/PhusionPassenger/InitializationError.html +141 -0
- data/doc/rdoc/classes/PhusionPassenger/InvalidPath.html +92 -0
- data/doc/rdoc/classes/PhusionPassenger/MessageChannel.html +673 -0
- data/doc/rdoc/classes/PhusionPassenger/MessageChannel/InvalidHashError.html +92 -0
- data/doc/rdoc/classes/PhusionPassenger/MessageClient.html +415 -0
- data/doc/rdoc/classes/PhusionPassenger/NativeSupportLoader.html +134 -0
- data/doc/rdoc/classes/PhusionPassenger/Packaging.html +129 -0
- data/doc/rdoc/classes/PhusionPassenger/PlatformInfo.html +1972 -0
- data/doc/rdoc/classes/PhusionPassenger/Plugin.html +237 -0
- data/doc/rdoc/classes/PhusionPassenger/Rack.html +91 -0
- data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner.html +312 -0
- data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner/Error.html +98 -0
- data/doc/rdoc/classes/PhusionPassenger/Rack/RequestHandler.html +218 -0
- data/doc/rdoc/classes/PhusionPassenger/Rails3Extensions.html +114 -0
- data/doc/rdoc/classes/PhusionPassenger/Rails3Extensions/AnalyticsLogging.html +259 -0
- data/doc/rdoc/classes/PhusionPassenger/Rails3Extensions/AnalyticsLogging/ACExtension.html +139 -0
- data/doc/rdoc/classes/PhusionPassenger/Rails3Extensions/AnalyticsLogging/ASBenchmarkableExtension.html +118 -0
- data/doc/rdoc/classes/PhusionPassenger/Rails3Extensions/AnalyticsLogging/ExceptionLogger.html +135 -0
- data/doc/rdoc/classes/PhusionPassenger/SpawnManager.html +378 -0
- data/doc/rdoc/classes/PhusionPassenger/Standalone.html +111 -0
- data/doc/rdoc/classes/PhusionPassenger/Standalone/AppFinder.html +252 -0
- data/doc/rdoc/classes/PhusionPassenger/Standalone/Command.html +161 -0
- data/doc/rdoc/classes/PhusionPassenger/Standalone/ConfigFile.html +368 -0
- data/doc/rdoc/classes/PhusionPassenger/Standalone/ConfigFile/DisallowedContextError.html +132 -0
- data/doc/rdoc/classes/PhusionPassenger/Standalone/HelpCommand.html +151 -0
- data/doc/rdoc/classes/PhusionPassenger/Standalone/Main.html +189 -0
- data/doc/rdoc/classes/PhusionPassenger/Standalone/PackageRuntimeCommand.html +177 -0
- data/doc/rdoc/classes/PhusionPassenger/Standalone/RuntimeInstaller.html +341 -0
- data/doc/rdoc/classes/PhusionPassenger/Standalone/StartCommand.html +203 -0
- data/doc/rdoc/classes/PhusionPassenger/Standalone/StatusCommand.html +156 -0
- data/doc/rdoc/classes/PhusionPassenger/Standalone/StopCommand.html +168 -0
- data/doc/rdoc/classes/PhusionPassenger/Standalone/Utils.html +86 -0
- data/doc/rdoc/classes/PhusionPassenger/Standalone/VersionCommand.html +135 -0
- data/doc/rdoc/classes/PhusionPassenger/UnknownError.html +125 -0
- data/doc/rdoc/classes/PhusionPassenger/Utils.html +1543 -0
- data/doc/rdoc/classes/PhusionPassenger/Utils/FileSystemWatcher.html +204 -0
- data/doc/rdoc/classes/PhusionPassenger/Utils/FileSystemWatcher/DirInfo.html +171 -0
- data/doc/rdoc/classes/PhusionPassenger/Utils/FileSystemWatcher/FileInfo.html +140 -0
- data/doc/rdoc/classes/PhusionPassenger/Utils/HostsFileParser.html +260 -0
- data/doc/rdoc/classes/PhusionPassenger/Utils/PseudoIO.html +169 -0
- data/doc/rdoc/classes/PhusionPassenger/Utils/RewindableInput.html +265 -0
- data/doc/rdoc/classes/PhusionPassenger/Utils/RewindableInput/Tempfile.html +120 -0
- data/doc/rdoc/classes/PhusionPassenger/Utils/UnseekableSocket.html +561 -0
- data/doc/rdoc/classes/PhusionPassenger/VersionNotFound.html +140 -0
- data/doc/rdoc/classes/PhusionPassenger/WSGI.html +89 -0
- data/doc/rdoc/classes/PhusionPassenger/WSGI/ApplicationSpawner.html +182 -0
- data/doc/rdoc/classes/Process.html +115 -0
- data/doc/rdoc/classes/Signal.html +139 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/DEVELOPERS_TXT.html +280 -0
- data/doc/rdoc/files/README.html +157 -0
- data/doc/rdoc/files/lib/phusion_passenger/abstract_installer_rb.html +130 -0
- data/doc/rdoc/files/lib/phusion_passenger/abstract_request_handler_rb.html +135 -0
- data/doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/abstract_server_rb.html +128 -0
- data/doc/rdoc/files/lib/phusion_passenger/admin_tools/memory_stats_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/admin_tools/server_instance_rb.html +132 -0
- data/doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/analytics_logger_rb.html +129 -0
- data/doc/rdoc/files/lib/phusion_passenger/app_process_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/classic_rails/application_spawner_rb.html +141 -0
- data/doc/rdoc/files/lib/phusion_passenger/classic_rails/cgi_fixed_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/classic_rails/framework_spawner_rb.html +146 -0
- data/doc/rdoc/files/lib/phusion_passenger/classic_rails/request_handler_rb.html +125 -0
- data/doc/rdoc/files/lib/phusion_passenger/classic_rails_extensions/init_rb.html +132 -0
- data/doc/rdoc/files/lib/phusion_passenger/console_text_template_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/constants_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/debug_logging_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/dependencies_rb.html +147 -0
- data/doc/rdoc/files/lib/phusion_passenger/exceptions_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/html_template_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/message_channel_rb.html +120 -0
- data/doc/rdoc/files/lib/phusion_passenger/message_client_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/native_support_rb.html +132 -0
- data/doc/rdoc/files/lib/phusion_passenger/packaging_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/platform_info/apache_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/platform_info/binary_compatibility_rb.html +129 -0
- data/doc/rdoc/files/lib/phusion_passenger/platform_info/compiler_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/platform_info/curl_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/platform_info/documentation_tools_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/platform_info/linux_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/platform_info/operating_system_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/platform_info/ruby_rb.html +128 -0
- data/doc/rdoc/files/lib/phusion_passenger/platform_info/zlib_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/platform_info_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/plugin_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/public_api_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html +137 -0
- data/doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html +125 -0
- data/doc/rdoc/files/lib/phusion_passenger/rails3_extensions/init_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/simple_benchmarking_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/spawn_manager_rb.html +160 -0
- data/doc/rdoc/files/lib/phusion_passenger/standalone/app_finder_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/standalone/command_rb.html +136 -0
- data/doc/rdoc/files/lib/phusion_passenger/standalone/config_file_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/standalone/help_command_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/standalone/main_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/standalone/package_runtime_command_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/standalone/runtime_installer_rb.html +133 -0
- data/doc/rdoc/files/lib/phusion_passenger/standalone/start_command_rb.html +136 -0
- data/doc/rdoc/files/lib/phusion_passenger/standalone/status_command_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/standalone/stop_command_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/standalone/utils_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/standalone/version_command_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/utils/file_system_watcher_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/utils/hosts_file_parser_rb.html +120 -0
- data/doc/rdoc/files/lib/phusion_passenger/utils/rewindable_input_rb.html +100 -0
- data/doc/rdoc/files/lib/phusion_passenger/utils/tmpdir_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/utils/unseekable_socket_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/utils_rb.html +179 -0
- data/doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html +132 -0
- data/doc/rdoc/fr_class_index.html +138 -0
- data/doc/rdoc/fr_file_index.html +108 -0
- data/doc/rdoc/fr_method_index.html +433 -0
- data/doc/rdoc/index.html +26 -0
- data/doc/rdoc/rdoc-style.css +187 -0
- data/doc/template/horo.rb +613 -0
- data/doc/users_guide_snippets/analysis_and_system_maintenance.txt +201 -0
- data/doc/users_guide_snippets/appendix_a_about.txt +13 -0
- data/doc/users_guide_snippets/appendix_b_terminology.txt +63 -0
- data/doc/users_guide_snippets/appendix_c_spawning_methods.txt +303 -0
- data/doc/users_guide_snippets/global_queueing_explained.txt +74 -0
- data/doc/users_guide_snippets/passenger_spawn_method.txt +49 -0
- data/doc/users_guide_snippets/rackup_specifications.txt +71 -0
- data/doc/users_guide_snippets/tips.txt +207 -0
- data/doc/users_guide_snippets/under_the_hood/page_caching_support.txt +22 -0
- data/ext/apache2/Bucket.cpp +190 -0
- data/ext/apache2/Bucket.h +87 -0
- data/ext/apache2/Configuration.cpp +717 -0
- data/ext/apache2/Configuration.h +51 -0
- data/ext/apache2/Configuration.hpp +462 -0
- data/ext/apache2/DirectoryMapper.h +280 -0
- data/ext/apache2/HelperAgent.cpp +365 -0
- data/ext/apache2/Hooks.cpp +1757 -0
- data/ext/apache2/Hooks.h +45 -0
- data/ext/apache2/mod_passenger.c +44 -0
- data/ext/boost/algorithm/string/case_conv.hpp +176 -0
- data/ext/boost/algorithm/string/compare.hpp +199 -0
- data/ext/boost/algorithm/string/concept.hpp +83 -0
- data/ext/boost/algorithm/string/config.hpp +28 -0
- data/ext/boost/algorithm/string/constants.hpp +36 -0
- data/ext/boost/algorithm/string/detail/case_conv.hpp +121 -0
- data/ext/boost/algorithm/string/detail/find_format.hpp +204 -0
- data/ext/boost/algorithm/string/detail/find_format_all.hpp +273 -0
- data/ext/boost/algorithm/string/detail/find_format_store.hpp +89 -0
- data/ext/boost/algorithm/string/detail/finder.hpp +646 -0
- data/ext/boost/algorithm/string/detail/formatter.hpp +94 -0
- data/ext/boost/algorithm/string/detail/replace_storage.hpp +159 -0
- data/ext/boost/algorithm/string/detail/sequence.hpp +200 -0
- data/ext/boost/algorithm/string/detail/util.hpp +106 -0
- data/ext/boost/algorithm/string/erase.hpp +844 -0
- data/ext/boost/algorithm/string/find_format.hpp +287 -0
- data/ext/boost/algorithm/string/finder.hpp +270 -0
- data/ext/boost/algorithm/string/formatter.hpp +103 -0
- data/ext/boost/algorithm/string/replace.hpp +928 -0
- data/ext/boost/algorithm/string/sequence_traits.hpp +193 -0
- data/ext/boost/algorithm/string/yes_no_type.hpp +33 -0
- data/ext/boost/assert.hpp +50 -0
- data/ext/boost/bind.hpp +24 -0
- data/ext/boost/bind/arg.hpp +62 -0
- data/ext/boost/bind/bind.hpp +1751 -0
- data/ext/boost/bind/bind_cc.hpp +117 -0
- data/ext/boost/bind/bind_mf2_cc.hpp +228 -0
- data/ext/boost/bind/bind_mf_cc.hpp +227 -0
- data/ext/boost/bind/bind_template.hpp +345 -0
- data/ext/boost/bind/mem_fn.hpp +389 -0
- data/ext/boost/bind/mem_fn_cc.hpp +103 -0
- data/ext/boost/bind/mem_fn_template.hpp +1047 -0
- data/ext/boost/bind/placeholders.hpp +69 -0
- data/ext/boost/bind/storage.hpp +475 -0
- data/ext/boost/call_traits.hpp +24 -0
- data/ext/boost/checked_delete.hpp +69 -0
- data/ext/boost/concept/assert.hpp +46 -0
- data/ext/boost/concept/detail/backward_compatibility.hpp +16 -0
- data/ext/boost/concept/detail/concept_def.hpp +51 -0
- data/ext/boost/concept/detail/concept_undef.hpp +5 -0
- data/ext/boost/concept/detail/general.hpp +75 -0
- data/ext/boost/concept/detail/has_constraints.hpp +50 -0
- data/ext/boost/concept/usage.hpp +44 -0
- data/ext/boost/concept_check.hpp +1007 -0
- data/ext/boost/config.hpp +70 -0
- data/ext/boost/config/abi/borland_prefix.hpp +27 -0
- data/ext/boost/config/abi/borland_suffix.hpp +12 -0
- data/ext/boost/config/abi/msvc_prefix.hpp +22 -0
- data/ext/boost/config/abi/msvc_suffix.hpp +8 -0
- data/ext/boost/config/abi_prefix.hpp +25 -0
- data/ext/boost/config/abi_suffix.hpp +27 -0
- data/ext/boost/config/auto_link.hpp +420 -0
- data/ext/boost/config/compiler/borland.hpp +275 -0
- data/ext/boost/config/compiler/clang.hpp +62 -0
- data/ext/boost/config/compiler/codegear.hpp +177 -0
- data/ext/boost/config/compiler/comeau.hpp +59 -0
- data/ext/boost/config/compiler/common_edg.hpp +99 -0
- data/ext/boost/config/compiler/compaq_cxx.hpp +19 -0
- data/ext/boost/config/compiler/digitalmars.hpp +93 -0
- data/ext/boost/config/compiler/gcc.hpp +243 -0
- data/ext/boost/config/compiler/gcc_xml.hpp +55 -0
- data/ext/boost/config/compiler/greenhills.hpp +28 -0
- data/ext/boost/config/compiler/hp_acc.hpp +127 -0
- data/ext/boost/config/compiler/intel.hpp +196 -0
- data/ext/boost/config/compiler/kai.hpp +33 -0
- data/ext/boost/config/compiler/metrowerks.hpp +139 -0
- data/ext/boost/config/compiler/mpw.hpp +81 -0
- data/ext/boost/config/compiler/nvcc.hpp +86 -0
- data/ext/boost/config/compiler/pgi.hpp +77 -0
- data/ext/boost/config/compiler/sgi_mipspro.hpp +29 -0
- data/ext/boost/config/compiler/sunpro_cc.hpp +144 -0
- data/ext/boost/config/compiler/vacpp.hpp +96 -0
- data/ext/boost/config/compiler/visualc.hpp +274 -0
- data/ext/boost/config/no_tr1/cmath.hpp +28 -0
- data/ext/boost/config/no_tr1/complex.hpp +28 -0
- data/ext/boost/config/no_tr1/functional.hpp +28 -0
- data/ext/boost/config/no_tr1/memory.hpp +28 -0
- data/ext/boost/config/no_tr1/utility.hpp +28 -0
- data/ext/boost/config/platform/aix.hpp +33 -0
- data/ext/boost/config/platform/amigaos.hpp +15 -0
- data/ext/boost/config/platform/beos.hpp +26 -0
- data/ext/boost/config/platform/bsd.hpp +86 -0
- data/ext/boost/config/platform/cygwin.hpp +48 -0
- data/ext/boost/config/platform/hpux.hpp +87 -0
- data/ext/boost/config/platform/irix.hpp +31 -0
- data/ext/boost/config/platform/linux.hpp +98 -0
- data/ext/boost/config/platform/macos.hpp +86 -0
- data/ext/boost/config/platform/qnxnto.hpp +31 -0
- data/ext/boost/config/platform/solaris.hpp +28 -0
- data/ext/boost/config/platform/symbian.hpp +94 -0
- data/ext/boost/config/platform/vxworks.hpp +31 -0
- data/ext/boost/config/platform/win32.hpp +65 -0
- data/ext/boost/config/posix_features.hpp +95 -0
- data/ext/boost/config/requires_threads.hpp +92 -0
- data/ext/boost/config/select_compiler_config.hpp +129 -0
- data/ext/boost/config/select_platform_config.hpp +98 -0
- data/ext/boost/config/select_stdlib_config.hpp +77 -0
- data/ext/boost/config/stdlib/dinkumware.hpp +148 -0
- data/ext/boost/config/stdlib/libcomo.hpp +72 -0
- data/ext/boost/config/stdlib/libstdcpp3.hpp +128 -0
- data/ext/boost/config/stdlib/modena.hpp +56 -0
- data/ext/boost/config/stdlib/msl.hpp +84 -0
- data/ext/boost/config/stdlib/roguewave.hpp +180 -0
- data/ext/boost/config/stdlib/sgi.hpp +137 -0
- data/ext/boost/config/stdlib/stlport.hpp +237 -0
- data/ext/boost/config/stdlib/vacpp.hpp +44 -0
- data/ext/boost/config/suffix.hpp +639 -0
- data/ext/boost/config/user.hpp +124 -0
- data/ext/boost/config/warning_disable.hpp +47 -0
- data/ext/boost/cstdint.hpp +504 -0
- data/ext/boost/current_function.hpp +67 -0
- data/ext/boost/date_time/adjust_functors.hpp +178 -0
- data/ext/boost/date_time/c_time.hpp +107 -0
- data/ext/boost/date_time/compiler_config.hpp +171 -0
- data/ext/boost/date_time/constrained_value.hpp +121 -0
- data/ext/boost/date_time/date.hpp +208 -0
- data/ext/boost/date_time/date_clock_device.hpp +77 -0
- data/ext/boost/date_time/date_defs.hpp +26 -0
- data/ext/boost/date_time/date_duration.hpp +146 -0
- data/ext/boost/date_time/date_duration_types.hpp +269 -0
- data/ext/boost/date_time/date_facet.hpp +764 -0
- data/ext/boost/date_time/date_format_simple.hpp +159 -0
- data/ext/boost/date_time/date_formatting.hpp +127 -0
- data/ext/boost/date_time/date_formatting_limited.hpp +121 -0
- data/ext/boost/date_time/date_formatting_locales.hpp +233 -0
- data/ext/boost/date_time/date_generator_formatter.hpp +265 -0
- data/ext/boost/date_time/date_generator_parser.hpp +330 -0
- data/ext/boost/date_time/date_generators.hpp +509 -0
- data/ext/boost/date_time/date_iterator.hpp +101 -0
- data/ext/boost/date_time/date_names_put.hpp +320 -0
- data/ext/boost/date_time/date_parsing.hpp +316 -0
- data/ext/boost/date_time/dst_rules.hpp +391 -0
- data/ext/boost/date_time/filetime_functions.hpp +170 -0
- data/ext/boost/date_time/format_date_parser.hpp +743 -0
- data/ext/boost/date_time/gregorian/conversion.hpp +68 -0
- data/ext/boost/date_time/gregorian/formatters.hpp +162 -0
- data/ext/boost/date_time/gregorian/formatters_limited.hpp +81 -0
- data/ext/boost/date_time/gregorian/greg_calendar.hpp +48 -0
- data/ext/boost/date_time/gregorian/greg_date.hpp +136 -0
- data/ext/boost/date_time/gregorian/greg_day.hpp +57 -0
- data/ext/boost/date_time/gregorian/greg_day_of_year.hpp +38 -0
- data/ext/boost/date_time/gregorian/greg_duration.hpp +134 -0
- data/ext/boost/date_time/gregorian/greg_duration_types.hpp +43 -0
- data/ext/boost/date_time/gregorian/greg_month.hpp +105 -0
- data/ext/boost/date_time/gregorian/greg_weekday.hpp +66 -0
- data/ext/boost/date_time/gregorian/greg_year.hpp +53 -0
- data/ext/boost/date_time/gregorian/greg_ymd.hpp +33 -0
- data/ext/boost/date_time/gregorian/gregorian.hpp +38 -0
- data/ext/boost/date_time/gregorian/gregorian_io.hpp +784 -0
- data/ext/boost/date_time/gregorian/gregorian_types.hpp +109 -0
- data/ext/boost/date_time/gregorian/parsers.hpp +91 -0
- data/ext/boost/date_time/gregorian_calendar.hpp +70 -0
- data/ext/boost/date_time/gregorian_calendar.ipp +219 -0
- data/ext/boost/date_time/int_adapter.hpp +509 -0
- data/ext/boost/date_time/iso_format.hpp +303 -0
- data/ext/boost/date_time/locale_config.hpp +31 -0
- data/ext/boost/date_time/microsec_time_clock.hpp +127 -0
- data/ext/boost/date_time/parse_format_base.hpp +29 -0
- data/ext/boost/date_time/period.hpp +377 -0
- data/ext/boost/date_time/period_formatter.hpp +196 -0
- data/ext/boost/date_time/period_parser.hpp +198 -0
- data/ext/boost/date_time/posix_time/conversion.hpp +94 -0
- data/ext/boost/date_time/posix_time/date_duration_operators.hpp +114 -0
- data/ext/boost/date_time/posix_time/posix_time.hpp +39 -0
- data/ext/boost/date_time/posix_time/posix_time_config.hpp +178 -0
- data/ext/boost/date_time/posix_time/posix_time_duration.hpp +82 -0
- data/ext/boost/date_time/posix_time/posix_time_io.hpp +239 -0
- data/ext/boost/date_time/posix_time/posix_time_system.hpp +68 -0
- data/ext/boost/date_time/posix_time/posix_time_types.hpp +55 -0
- data/ext/boost/date_time/posix_time/ptime.hpp +65 -0
- data/ext/boost/date_time/posix_time/time_formatters.hpp +289 -0
- data/ext/boost/date_time/posix_time/time_parsers.hpp +44 -0
- data/ext/boost/date_time/posix_time/time_period.hpp +29 -0
- data/ext/boost/date_time/special_defs.hpp +25 -0
- data/ext/boost/date_time/special_values_formatter.hpp +96 -0
- data/ext/boost/date_time/special_values_parser.hpp +159 -0
- data/ext/boost/date_time/string_convert.hpp +33 -0
- data/ext/boost/date_time/string_parse_tree.hpp +278 -0
- data/ext/boost/date_time/strings_from_facet.hpp +125 -0
- data/ext/boost/date_time/time.hpp +191 -0
- data/ext/boost/date_time/time_clock.hpp +83 -0
- data/ext/boost/date_time/time_defs.hpp +43 -0
- data/ext/boost/date_time/time_duration.hpp +282 -0
- data/ext/boost/date_time/time_facet.hpp +1367 -0
- data/ext/boost/date_time/time_formatting_streams.hpp +122 -0
- data/ext/boost/date_time/time_iterator.hpp +52 -0
- data/ext/boost/date_time/time_parsing.hpp +321 -0
- data/ext/boost/date_time/time_resolution_traits.hpp +144 -0
- data/ext/boost/date_time/time_system_counted.hpp +254 -0
- data/ext/boost/date_time/time_system_split.hpp +207 -0
- data/ext/boost/date_time/wrapping_int.hpp +169 -0
- data/ext/boost/date_time/year_month_day.hpp +45 -0
- data/ext/boost/detail/call_traits.hpp +164 -0
- data/ext/boost/detail/endian.hpp +76 -0
- data/ext/boost/detail/indirect_traits.hpp +487 -0
- data/ext/boost/detail/iterator.hpp +494 -0
- data/ext/boost/detail/lcast_precision.hpp +184 -0
- data/ext/boost/detail/limits.hpp +449 -0
- data/ext/boost/detail/no_exceptions_support.hpp +87 -0
- data/ext/boost/detail/reference_content.hpp +141 -0
- data/ext/boost/detail/sp_typeinfo.hpp +129 -0
- data/ext/boost/detail/workaround.hpp +267 -0
- data/ext/boost/enable_shared_from_this.hpp +18 -0
- data/ext/boost/exception/current_exception_cast.hpp +43 -0
- data/ext/boost/exception/detail/attribute_noreturn.hpp +17 -0
- data/ext/boost/exception/detail/error_info_impl.hpp +75 -0
- data/ext/boost/exception/detail/exception_ptr.hpp +431 -0
- data/ext/boost/exception/detail/is_output_streamable.hpp +60 -0
- data/ext/boost/exception/detail/object_hex_dump.hpp +50 -0
- data/ext/boost/exception/detail/type_info.hpp +83 -0
- data/ext/boost/exception/diagnostic_information.hpp +184 -0
- data/ext/boost/exception/exception.hpp +436 -0
- data/ext/boost/exception/get_error_info.hpp +130 -0
- data/ext/boost/exception/info.hpp +200 -0
- data/ext/boost/exception/to_string.hpp +83 -0
- data/ext/boost/exception/to_string_stub.hpp +109 -0
- data/ext/boost/exception_ptr.hpp +11 -0
- data/ext/boost/function.hpp +66 -0
- data/ext/boost/function/detail/function_iterate.hpp +16 -0
- data/ext/boost/function/detail/maybe_include.hpp +267 -0
- data/ext/boost/function/detail/prologue.hpp +26 -0
- data/ext/boost/function/function_base.hpp +904 -0
- data/ext/boost/function/function_fwd.hpp +70 -0
- data/ext/boost/function/function_template.hpp +1158 -0
- data/ext/boost/function_equal.hpp +28 -0
- data/ext/boost/get_pointer.hpp +33 -0
- data/ext/boost/implicit_cast.hpp +29 -0
- data/ext/boost/integer.hpp +257 -0
- data/ext/boost/integer_fwd.hpp +180 -0
- data/ext/boost/integer_traits.hpp +261 -0
- data/ext/boost/io/ios_state.hpp +439 -0
- data/ext/boost/io_fwd.hpp +67 -0
- data/ext/boost/is_placeholder.hpp +31 -0
- data/ext/boost/iterator.hpp +59 -0
- data/ext/boost/iterator/detail/config_def.hpp +137 -0
- data/ext/boost/iterator/detail/config_undef.hpp +25 -0
- data/ext/boost/iterator/detail/enable_if.hpp +86 -0
- data/ext/boost/iterator/detail/facade_iterator_category.hpp +200 -0
- data/ext/boost/iterator/detail/minimum_category.hpp +116 -0
- data/ext/boost/iterator/interoperable.hpp +50 -0
- data/ext/boost/iterator/iterator_adaptor.hpp +371 -0
- data/ext/boost/iterator/iterator_categories.hpp +188 -0
- data/ext/boost/iterator/iterator_concepts.hpp +284 -0
- data/ext/boost/iterator/iterator_facade.hpp +878 -0
- data/ext/boost/iterator/iterator_traits.hpp +92 -0
- data/ext/boost/iterator/reverse_iterator.hpp +69 -0
- data/ext/boost/iterator/transform_iterator.hpp +187 -0
- data/ext/boost/lexical_cast.hpp +1213 -0
- data/ext/boost/limits.hpp +146 -0
- data/ext/boost/make_shared.hpp +17 -0
- data/ext/boost/mem_fn.hpp +24 -0
- data/ext/boost/memory_order.hpp +53 -0
- data/ext/boost/mpl/always.hpp +39 -0
- data/ext/boost/mpl/and.hpp +60 -0
- data/ext/boost/mpl/apply.hpp +229 -0
- data/ext/boost/mpl/apply_fwd.hpp +107 -0
- data/ext/boost/mpl/apply_wrap.hpp +234 -0
- data/ext/boost/mpl/arg.hpp +131 -0
- data/ext/boost/mpl/arg_fwd.hpp +28 -0
- data/ext/boost/mpl/assert.hpp +370 -0
- data/ext/boost/mpl/aux_/adl_barrier.hpp +48 -0
- data/ext/boost/mpl/aux_/arg_typedef.hpp +31 -0
- data/ext/boost/mpl/aux_/arity.hpp +39 -0
- data/ext/boost/mpl/aux_/arity_spec.hpp +67 -0
- data/ext/boost/mpl/aux_/common_name_wknd.hpp +34 -0
- data/ext/boost/mpl/aux_/config/adl.hpp +40 -0
- data/ext/boost/mpl/aux_/config/arrays.hpp +30 -0
- data/ext/boost/mpl/aux_/config/bcc.hpp +28 -0
- data/ext/boost/mpl/aux_/config/bind.hpp +33 -0
- data/ext/boost/mpl/aux_/config/compiler.hpp +66 -0
- data/ext/boost/mpl/aux_/config/ctps.hpp +30 -0
- data/ext/boost/mpl/aux_/config/dtp.hpp +46 -0
- data/ext/boost/mpl/aux_/config/eti.hpp +47 -0
- data/ext/boost/mpl/aux_/config/gcc.hpp +23 -0
- data/ext/boost/mpl/aux_/config/has_apply.hpp +32 -0
- data/ext/boost/mpl/aux_/config/has_xxx.hpp +34 -0
- data/ext/boost/mpl/aux_/config/integral.hpp +38 -0
- data/ext/boost/mpl/aux_/config/intel.hpp +21 -0
- data/ext/boost/mpl/aux_/config/lambda.hpp +32 -0
- data/ext/boost/mpl/aux_/config/msvc.hpp +21 -0
- data/ext/boost/mpl/aux_/config/msvc_typename.hpp +26 -0
- data/ext/boost/mpl/aux_/config/nttp.hpp +41 -0
- data/ext/boost/mpl/aux_/config/overload_resolution.hpp +29 -0
- data/ext/boost/mpl/aux_/config/pp_counter.hpp +26 -0
- data/ext/boost/mpl/aux_/config/preprocessor.hpp +39 -0
- data/ext/boost/mpl/aux_/config/static_constant.hpp +25 -0
- data/ext/boost/mpl/aux_/config/ttp.hpp +41 -0
- data/ext/boost/mpl/aux_/config/use_preprocessed.hpp +19 -0
- data/ext/boost/mpl/aux_/config/workaround.hpp +19 -0
- data/ext/boost/mpl/aux_/full_lambda.hpp +354 -0
- data/ext/boost/mpl/aux_/has_apply.hpp +32 -0
- data/ext/boost/mpl/aux_/has_type.hpp +23 -0
- data/ext/boost/mpl/aux_/include_preprocessed.hpp +42 -0
- data/ext/boost/mpl/aux_/integral_wrapper.hpp +93 -0
- data/ext/boost/mpl/aux_/lambda_arity_param.hpp +25 -0
- data/ext/boost/mpl/aux_/lambda_support.hpp +169 -0
- data/ext/boost/mpl/aux_/msvc_never_true.hpp +34 -0
- data/ext/boost/mpl/aux_/na.hpp +95 -0
- data/ext/boost/mpl/aux_/na_assert.hpp +34 -0
- data/ext/boost/mpl/aux_/na_fwd.hpp +31 -0
- data/ext/boost/mpl/aux_/na_spec.hpp +175 -0
- data/ext/boost/mpl/aux_/nested_type_wknd.hpp +48 -0
- data/ext/boost/mpl/aux_/nttp_decl.hpp +35 -0
- data/ext/boost/mpl/aux_/preprocessed/gcc/and.hpp +69 -0
- data/ext/boost/mpl/aux_/preprocessed/gcc/apply.hpp +169 -0
- data/ext/boost/mpl/aux_/preprocessed/gcc/apply_fwd.hpp +52 -0
- data/ext/boost/mpl/aux_/preprocessed/gcc/apply_wrap.hpp +84 -0
- data/ext/boost/mpl/aux_/preprocessed/gcc/arg.hpp +123 -0
- data/ext/boost/mpl/aux_/preprocessed/gcc/bind.hpp +561 -0
- data/ext/boost/mpl/aux_/preprocessed/gcc/bind_fwd.hpp +52 -0
- data/ext/boost/mpl/aux_/preprocessed/gcc/full_lambda.hpp +558 -0
- data/ext/boost/mpl/aux_/preprocessed/gcc/or.hpp +69 -0
- data/ext/boost/mpl/aux_/preprocessed/gcc/placeholders.hpp +105 -0
- data/ext/boost/mpl/aux_/preprocessed/gcc/quote.hpp +123 -0
- data/ext/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp +97 -0
- data/ext/boost/mpl/aux_/preprocessor/def_params_tail.hpp +105 -0
- data/ext/boost/mpl/aux_/preprocessor/enum.hpp +62 -0
- data/ext/boost/mpl/aux_/preprocessor/filter_params.hpp +28 -0
- data/ext/boost/mpl/aux_/preprocessor/params.hpp +65 -0
- data/ext/boost/mpl/aux_/preprocessor/sub.hpp +65 -0
- data/ext/boost/mpl/aux_/static_cast.hpp +27 -0
- data/ext/boost/mpl/aux_/template_arity.hpp +189 -0
- data/ext/boost/mpl/aux_/template_arity_fwd.hpp +23 -0
- data/ext/boost/mpl/aux_/type_wrapper.hpp +47 -0
- data/ext/boost/mpl/aux_/value_wknd.hpp +89 -0
- data/ext/boost/mpl/aux_/yes_no.hpp +58 -0
- data/ext/boost/mpl/bind.hpp +551 -0
- data/ext/boost/mpl/bind_fwd.hpp +99 -0
- data/ext/boost/mpl/bool.hpp +39 -0
- data/ext/boost/mpl/bool_fwd.hpp +33 -0
- data/ext/boost/mpl/eval_if.hpp +71 -0
- data/ext/boost/mpl/has_xxx.hpp +640 -0
- data/ext/boost/mpl/identity.hpp +45 -0
- data/ext/boost/mpl/if.hpp +135 -0
- data/ext/boost/mpl/int.hpp +22 -0
- data/ext/boost/mpl/int_fwd.hpp +27 -0
- data/ext/boost/mpl/integral_c.hpp +51 -0
- data/ext/boost/mpl/integral_c_fwd.hpp +32 -0
- data/ext/boost/mpl/integral_c_tag.hpp +26 -0
- data/ext/boost/mpl/lambda.hpp +29 -0
- data/ext/boost/mpl/lambda_fwd.hpp +57 -0
- data/ext/boost/mpl/limits/arity.hpp +21 -0
- data/ext/boost/mpl/logical.hpp +21 -0
- data/ext/boost/mpl/next.hpp +19 -0
- data/ext/boost/mpl/next_prior.hpp +49 -0
- data/ext/boost/mpl/not.hpp +51 -0
- data/ext/boost/mpl/or.hpp +61 -0
- data/ext/boost/mpl/placeholders.hpp +100 -0
- data/ext/boost/mpl/protect.hpp +55 -0
- data/ext/boost/mpl/quote.hpp +151 -0
- data/ext/boost/mpl/size_t.hpp +25 -0
- data/ext/boost/mpl/size_t_fwd.hpp +28 -0
- data/ext/boost/mpl/void.hpp +76 -0
- data/ext/boost/mpl/void_fwd.hpp +26 -0
- data/ext/boost/next_prior.hpp +51 -0
- data/ext/boost/non_type.hpp +27 -0
- data/ext/boost/noncopyable.hpp +36 -0
- data/ext/boost/none.hpp +28 -0
- data/ext/boost/none_t.hpp +24 -0
- data/ext/boost/operators.hpp +976 -0
- data/ext/boost/optional.hpp +18 -0
- data/ext/boost/optional/optional.hpp +924 -0
- data/ext/boost/optional/optional_fwd.hpp +22 -0
- data/ext/boost/preprocessor/arithmetic/add.hpp +51 -0
- data/ext/boost/preprocessor/arithmetic/dec.hpp +288 -0
- data/ext/boost/preprocessor/arithmetic/detail/div_base.hpp +61 -0
- data/ext/boost/preprocessor/arithmetic/inc.hpp +288 -0
- data/ext/boost/preprocessor/arithmetic/mod.hpp +39 -0
- data/ext/boost/preprocessor/arithmetic/sub.hpp +50 -0
- data/ext/boost/preprocessor/array/data.hpp +28 -0
- data/ext/boost/preprocessor/array/elem.hpp +29 -0
- data/ext/boost/preprocessor/array/size.hpp +28 -0
- data/ext/boost/preprocessor/cat.hpp +35 -0
- data/ext/boost/preprocessor/comma_if.hpp +17 -0
- data/ext/boost/preprocessor/comparison/less_equal.hpp +39 -0
- data/ext/boost/preprocessor/config/config.hpp +70 -0
- data/ext/boost/preprocessor/control/deduce_d.hpp +22 -0
- data/ext/boost/preprocessor/control/detail/while.hpp +536 -0
- data/ext/boost/preprocessor/control/expr_iif.hpp +31 -0
- data/ext/boost/preprocessor/control/if.hpp +30 -0
- data/ext/boost/preprocessor/control/iif.hpp +34 -0
- data/ext/boost/preprocessor/control/while.hpp +312 -0
- data/ext/boost/preprocessor/debug/error.hpp +33 -0
- data/ext/boost/preprocessor/detail/auto_rec.hpp +293 -0
- data/ext/boost/preprocessor/detail/check.hpp +48 -0
- data/ext/boost/preprocessor/detail/is_binary.hpp +30 -0
- data/ext/boost/preprocessor/empty.hpp +17 -0
- data/ext/boost/preprocessor/enum.hpp +17 -0
- data/ext/boost/preprocessor/enum_params.hpp +17 -0
- data/ext/boost/preprocessor/facilities/empty.hpp +21 -0
- data/ext/boost/preprocessor/facilities/identity.hpp +23 -0
- data/ext/boost/preprocessor/identity.hpp +17 -0
- data/ext/boost/preprocessor/inc.hpp +17 -0
- data/ext/boost/preprocessor/iterate.hpp +17 -0
- data/ext/boost/preprocessor/iteration/detail/bounds/lower1.hpp +99 -0
- data/ext/boost/preprocessor/iteration/detail/bounds/upper1.hpp +99 -0
- data/ext/boost/preprocessor/iteration/detail/iter/forward1.hpp +1342 -0
- data/ext/boost/preprocessor/iteration/iterate.hpp +82 -0
- data/ext/boost/preprocessor/list/adt.hpp +73 -0
- data/ext/boost/preprocessor/list/append.hpp +40 -0
- data/ext/boost/preprocessor/list/detail/fold_left.hpp +279 -0
- data/ext/boost/preprocessor/list/detail/fold_right.hpp +277 -0
- data/ext/boost/preprocessor/list/fold_left.hpp +303 -0
- data/ext/boost/preprocessor/list/fold_right.hpp +40 -0
- data/ext/boost/preprocessor/list/for_each_i.hpp +65 -0
- data/ext/boost/preprocessor/list/reverse.hpp +40 -0
- data/ext/boost/preprocessor/list/transform.hpp +49 -0
- data/ext/boost/preprocessor/logical/and.hpp +30 -0
- data/ext/boost/preprocessor/logical/bitand.hpp +38 -0
- data/ext/boost/preprocessor/logical/bool.hpp +288 -0
- data/ext/boost/preprocessor/logical/compl.hpp +36 -0
- data/ext/boost/preprocessor/logical/not.hpp +30 -0
- data/ext/boost/preprocessor/punctuation/comma.hpp +21 -0
- data/ext/boost/preprocessor/punctuation/comma_if.hpp +31 -0
- data/ext/boost/preprocessor/repeat.hpp +17 -0
- data/ext/boost/preprocessor/repetition/detail/for.hpp +536 -0
- data/ext/boost/preprocessor/repetition/enum.hpp +66 -0
- data/ext/boost/preprocessor/repetition/enum_binary_params.hpp +54 -0
- data/ext/boost/preprocessor/repetition/enum_params.hpp +41 -0
- data/ext/boost/preprocessor/repetition/enum_trailing_params.hpp +38 -0
- data/ext/boost/preprocessor/repetition/for.hpp +306 -0
- data/ext/boost/preprocessor/repetition/repeat.hpp +825 -0
- data/ext/boost/preprocessor/repetition/repeat_from_to.hpp +87 -0
- data/ext/boost/preprocessor/seq/cat.hpp +48 -0
- data/ext/boost/preprocessor/seq/elem.hpp +304 -0
- data/ext/boost/preprocessor/seq/enum.hpp +288 -0
- data/ext/boost/preprocessor/seq/fold_left.hpp +1070 -0
- data/ext/boost/preprocessor/seq/for_each_i.hpp +61 -0
- data/ext/boost/preprocessor/seq/seq.hpp +44 -0
- data/ext/boost/preprocessor/seq/size.hpp +548 -0
- data/ext/boost/preprocessor/seq/transform.hpp +48 -0
- data/ext/boost/preprocessor/slot/detail/def.hpp +49 -0
- data/ext/boost/preprocessor/slot/detail/shared.hpp +247 -0
- data/ext/boost/preprocessor/slot/slot.hpp +32 -0
- data/ext/boost/preprocessor/stringize.hpp +33 -0
- data/ext/boost/preprocessor/tuple/eat.hpp +57 -0
- data/ext/boost/preprocessor/tuple/elem.hpp +385 -0
- data/ext/boost/preprocessor/tuple/rem.hpp +72 -0
- data/ext/boost/preprocessor/tuple/to_list.hpp +62 -0
- data/ext/boost/range/algorithm/equal.hpp +188 -0
- data/ext/boost/range/as_literal.hpp +127 -0
- data/ext/boost/range/begin.hpp +132 -0
- data/ext/boost/range/concepts.hpp +331 -0
- data/ext/boost/range/config.hpp +54 -0
- data/ext/boost/range/const_iterator.hpp +67 -0
- data/ext/boost/range/detail/common.hpp +117 -0
- data/ext/boost/range/detail/extract_optional_type.hpp +52 -0
- data/ext/boost/range/detail/implementation_help.hpp +103 -0
- data/ext/boost/range/detail/misc_concept.hpp +33 -0
- data/ext/boost/range/detail/sfinae.hpp +77 -0
- data/ext/boost/range/detail/str_types.hpp +38 -0
- data/ext/boost/range/difference_type.hpp +29 -0
- data/ext/boost/range/distance.hpp +34 -0
- data/ext/boost/range/empty.hpp +34 -0
- data/ext/boost/range/end.hpp +131 -0
- data/ext/boost/range/functions.hpp +27 -0
- data/ext/boost/range/iterator.hpp +72 -0
- data/ext/boost/range/iterator_range.hpp +16 -0
- data/ext/boost/range/iterator_range_core.hpp +542 -0
- data/ext/boost/range/iterator_range_io.hpp +93 -0
- data/ext/boost/range/mutable_iterator.hpp +67 -0
- data/ext/boost/range/rbegin.hpp +65 -0
- data/ext/boost/range/rend.hpp +65 -0
- data/ext/boost/range/reverse_iterator.hpp +40 -0
- data/ext/boost/range/size.hpp +36 -0
- data/ext/boost/range/size_type.hpp +79 -0
- data/ext/boost/range/value_type.hpp +34 -0
- data/ext/boost/ref.hpp +189 -0
- data/ext/boost/scoped_array.hpp +16 -0
- data/ext/boost/scoped_ptr.hpp +16 -0
- data/ext/boost/shared_array.hpp +19 -0
- data/ext/boost/shared_ptr.hpp +19 -0
- data/ext/boost/smart_ptr/bad_weak_ptr.hpp +59 -0
- data/ext/boost/smart_ptr/detail/atomic_count.hpp +119 -0
- data/ext/boost/smart_ptr/detail/atomic_count_gcc.hpp +72 -0
- data/ext/boost/smart_ptr/detail/atomic_count_gcc_x86.hpp +77 -0
- data/ext/boost/smart_ptr/detail/atomic_count_pthreads.hpp +96 -0
- data/ext/boost/smart_ptr/detail/atomic_count_solaris.hpp +59 -0
- data/ext/boost/smart_ptr/detail/atomic_count_sync.hpp +61 -0
- data/ext/boost/smart_ptr/detail/atomic_count_win32.hpp +63 -0
- data/ext/boost/smart_ptr/detail/operator_bool.hpp +56 -0
- data/ext/boost/smart_ptr/detail/shared_count.hpp +444 -0
- data/ext/boost/smart_ptr/detail/sp_convertible.hpp +76 -0
- data/ext/boost/smart_ptr/detail/sp_counted_base.hpp +70 -0
- data/ext/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp +150 -0
- data/ext/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp +170 -0
- data/ext/boost/smart_ptr/detail/sp_counted_base_cw_x86.hpp +158 -0
- data/ext/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp +157 -0
- data/ext/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp +172 -0
- data/ext/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp +181 -0
- data/ext/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp +166 -0
- data/ext/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp +173 -0
- data/ext/boost/smart_ptr/detail/sp_counted_base_nt.hpp +107 -0
- data/ext/boost/smart_ptr/detail/sp_counted_base_pt.hpp +135 -0
- data/ext/boost/smart_ptr/detail/sp_counted_base_solaris.hpp +113 -0
- data/ext/boost/smart_ptr/detail/sp_counted_base_spin.hpp +131 -0
- data/ext/boost/smart_ptr/detail/sp_counted_base_sync.hpp +155 -0
- data/ext/boost/smart_ptr/detail/sp_counted_base_w32.hpp +130 -0
- data/ext/boost/smart_ptr/detail/sp_counted_impl.hpp +231 -0
- data/ext/boost/smart_ptr/detail/sp_has_sync.hpp +49 -0
- data/ext/boost/smart_ptr/detail/spinlock.hpp +53 -0
- data/ext/boost/smart_ptr/detail/spinlock_gcc_arm.hpp +85 -0
- data/ext/boost/smart_ptr/detail/spinlock_nt.hpp +89 -0
- data/ext/boost/smart_ptr/detail/spinlock_pool.hpp +87 -0
- data/ext/boost/smart_ptr/detail/spinlock_pt.hpp +79 -0
- data/ext/boost/smart_ptr/detail/spinlock_sync.hpp +87 -0
- data/ext/boost/smart_ptr/detail/yield_k.hpp +149 -0
- data/ext/boost/smart_ptr/enable_shared_from_this.hpp +79 -0
- data/ext/boost/smart_ptr/make_shared.hpp +508 -0
- data/ext/boost/smart_ptr/scoped_array.hpp +107 -0
- data/ext/boost/smart_ptr/scoped_ptr.hpp +131 -0
- data/ext/boost/smart_ptr/shared_array.hpp +147 -0
- data/ext/boost/smart_ptr/shared_ptr.hpp +701 -0
- data/ext/boost/smart_ptr/weak_ptr.hpp +230 -0
- data/ext/boost/src/pthread/once.cpp +51 -0
- data/ext/boost/src/pthread/thread.cpp +616 -0
- data/ext/boost/src/pthread/timeconv.inl +133 -0
- data/ext/boost/src/tss_null.cpp +34 -0
- data/ext/boost/static_assert.hpp +132 -0
- data/ext/boost/thread.hpp +26 -0
- data/ext/boost/thread/barrier.hpp +64 -0
- data/ext/boost/thread/condition.hpp +16 -0
- data/ext/boost/thread/condition_variable.hpp +21 -0
- data/ext/boost/thread/detail/config.hpp +100 -0
- data/ext/boost/thread/detail/force_cast.hpp +39 -0
- data/ext/boost/thread/detail/move.hpp +60 -0
- data/ext/boost/thread/detail/platform.hpp +71 -0
- data/ext/boost/thread/detail/singleton.hpp +59 -0
- data/ext/boost/thread/detail/thread.hpp +540 -0
- data/ext/boost/thread/detail/thread_group.hpp +108 -0
- data/ext/boost/thread/detail/thread_heap_alloc.hpp +23 -0
- data/ext/boost/thread/detail/thread_interruption.hpp +35 -0
- data/ext/boost/thread/detail/tss_hooks.hpp +65 -0
- data/ext/boost/thread/exceptions.hpp +223 -0
- data/ext/boost/thread/future.hpp +1375 -0
- data/ext/boost/thread/locks.hpp +1585 -0
- data/ext/boost/thread/mutex.hpp +21 -0
- data/ext/boost/thread/once.hpp +33 -0
- data/ext/boost/thread/pthread/condition_variable.hpp +179 -0
- data/ext/boost/thread/pthread/condition_variable_fwd.hpp +102 -0
- data/ext/boost/thread/pthread/mutex.hpp +236 -0
- data/ext/boost/thread/pthread/once.hpp +95 -0
- data/ext/boost/thread/pthread/pthread_mutex_scoped_lock.hpp +54 -0
- data/ext/boost/thread/pthread/recursive_mutex.hpp +345 -0
- data/ext/boost/thread/pthread/shared_mutex.hpp +303 -0
- data/ext/boost/thread/pthread/thread_data.hpp +129 -0
- data/ext/boost/thread/pthread/thread_heap_alloc.hpp +242 -0
- data/ext/boost/thread/pthread/timespec.hpp +36 -0
- data/ext/boost/thread/recursive_mutex.hpp +21 -0
- data/ext/boost/thread/shared_mutex.hpp +21 -0
- data/ext/boost/thread/thread.hpp +27 -0
- data/ext/boost/thread/thread_time.hpp +50 -0
- data/ext/boost/thread/tss.hpp +113 -0
- data/ext/boost/thread/xtime.hpp +92 -0
- data/ext/boost/throw_exception.hpp +91 -0
- data/ext/boost/token_functions.hpp +641 -0
- data/ext/boost/token_iterator.hpp +128 -0
- data/ext/boost/tokenizer.hpp +98 -0
- data/ext/boost/type.hpp +18 -0
- data/ext/boost/type_traits/add_const.hpp +47 -0
- data/ext/boost/type_traits/add_pointer.hpp +72 -0
- data/ext/boost/type_traits/add_reference.hpp +107 -0
- data/ext/boost/type_traits/add_volatile.hpp +47 -0
- data/ext/boost/type_traits/alignment_of.hpp +128 -0
- data/ext/boost/type_traits/broken_compiler_spec.hpp +117 -0
- data/ext/boost/type_traits/composite_traits.hpp +29 -0
- data/ext/boost/type_traits/config.hpp +76 -0
- data/ext/boost/type_traits/conversion_traits.hpp +17 -0
- data/ext/boost/type_traits/detail/bool_trait_def.hpp +173 -0
- data/ext/boost/type_traits/detail/bool_trait_undef.hpp +27 -0
- data/ext/boost/type_traits/detail/cv_traits_impl.hpp +97 -0
- data/ext/boost/type_traits/detail/false_result.hpp +28 -0
- data/ext/boost/type_traits/detail/ice_and.hpp +35 -0
- data/ext/boost/type_traits/detail/ice_eq.hpp +36 -0
- data/ext/boost/type_traits/detail/ice_not.hpp +31 -0
- data/ext/boost/type_traits/detail/ice_or.hpp +34 -0
- data/ext/boost/type_traits/detail/is_function_ptr_helper.hpp +220 -0
- data/ext/boost/type_traits/detail/is_mem_fun_pointer_impl.hpp +817 -0
- data/ext/boost/type_traits/detail/size_t_trait_def.hpp +58 -0
- data/ext/boost/type_traits/detail/size_t_trait_undef.hpp +16 -0
- data/ext/boost/type_traits/detail/template_arity_spec.hpp +31 -0
- data/ext/boost/type_traits/detail/type_trait_def.hpp +61 -0
- data/ext/boost/type_traits/detail/type_trait_undef.hpp +19 -0
- data/ext/boost/type_traits/detail/yes_no_type.hpp +26 -0
- data/ext/boost/type_traits/function_traits.hpp +236 -0
- data/ext/boost/type_traits/has_nothrow_copy.hpp +39 -0
- data/ext/boost/type_traits/has_trivial_copy.hpp +49 -0
- data/ext/boost/type_traits/has_trivial_destructor.hpp +42 -0
- data/ext/boost/type_traits/ice.hpp +20 -0
- data/ext/boost/type_traits/integral_constant.hpp +53 -0
- data/ext/boost/type_traits/intrinsics.hpp +240 -0
- data/ext/boost/type_traits/is_abstract.hpp +153 -0
- data/ext/boost/type_traits/is_arithmetic.hpp +51 -0
- data/ext/boost/type_traits/is_array.hpp +91 -0
- data/ext/boost/type_traits/is_base_and_derived.hpp +254 -0
- data/ext/boost/type_traits/is_base_of.hpp +51 -0
- data/ext/boost/type_traits/is_class.hpp +140 -0
- data/ext/boost/type_traits/is_const.hpp +165 -0
- data/ext/boost/type_traits/is_convertible.hpp +430 -0
- data/ext/boost/type_traits/is_enum.hpp +189 -0
- data/ext/boost/type_traits/is_float.hpp +27 -0
- data/ext/boost/type_traits/is_function.hpp +106 -0
- data/ext/boost/type_traits/is_fundamental.hpp +45 -0
- data/ext/boost/type_traits/is_integral.hpp +78 -0
- data/ext/boost/type_traits/is_lvalue_reference.hpp +118 -0
- data/ext/boost/type_traits/is_member_function_pointer.hpp +136 -0
- data/ext/boost/type_traits/is_member_pointer.hpp +116 -0
- data/ext/boost/type_traits/is_pod.hpp +135 -0
- data/ext/boost/type_traits/is_pointer.hpp +162 -0
- data/ext/boost/type_traits/is_reference.hpp +45 -0
- data/ext/boost/type_traits/is_rvalue_reference.hpp +29 -0
- data/ext/boost/type_traits/is_same.hpp +103 -0
- data/ext/boost/type_traits/is_scalar.hpp +55 -0
- data/ext/boost/type_traits/is_signed.hpp +135 -0
- data/ext/boost/type_traits/is_union.hpp +49 -0
- data/ext/boost/type_traits/is_unsigned.hpp +130 -0
- data/ext/boost/type_traits/is_void.hpp +38 -0
- data/ext/boost/type_traits/is_volatile.hpp +152 -0
- data/ext/boost/type_traits/make_unsigned.hpp +137 -0
- data/ext/boost/type_traits/remove_const.hpp +90 -0
- data/ext/boost/type_traits/remove_cv.hpp +83 -0
- data/ext/boost/type_traits/remove_pointer.hpp +43 -0
- data/ext/boost/type_traits/remove_reference.hpp +70 -0
- data/ext/boost/type_traits/type_with_alignment.hpp +393 -0
- data/ext/boost/units/detail/utility.hpp +104 -0
- data/ext/boost/utility.hpp +20 -0
- data/ext/boost/utility/addressof.hpp +102 -0
- data/ext/boost/utility/base_from_member.hpp +87 -0
- data/ext/boost/utility/binary.hpp +708 -0
- data/ext/boost/utility/compare_pointees.hpp +68 -0
- data/ext/boost/utility/enable_if.hpp +119 -0
- data/ext/boost/visit_each.hpp +29 -0
- data/ext/boost/weak_ptr.hpp +18 -0
- data/ext/common/AbstractSpawnManager.h +110 -0
- data/ext/common/Account.h +175 -0
- data/ext/common/AccountsDatabase.cpp +81 -0
- data/ext/common/AccountsDatabase.h +130 -0
- data/ext/common/AgentBase.cpp +323 -0
- data/ext/common/AgentBase.h +39 -0
- data/ext/common/AgentsStarter.cpp +154 -0
- data/ext/common/AgentsStarter.h +81 -0
- data/ext/common/AgentsStarter.hpp +646 -0
- data/ext/common/ApplicationPool/Client.h +796 -0
- data/ext/common/ApplicationPool/Interface.h +295 -0
- data/ext/common/ApplicationPool/Pool.h +1327 -0
- data/ext/common/ApplicationPool/Server.h +475 -0
- data/ext/common/BCrypt.cpp +343 -0
- data/ext/common/BCrypt.h +73 -0
- data/ext/common/Blowfish.c +685 -0
- data/ext/common/Blowfish.h +103 -0
- data/ext/common/Constants.h +48 -0
- data/ext/common/EventedClient.h +702 -0
- data/ext/common/EventedMessageServer.h +327 -0
- data/ext/common/EventedServer.h +295 -0
- data/ext/common/Exceptions.h +348 -0
- data/ext/common/FileDescriptor.h +293 -0
- data/ext/common/HelperAgent/BacktracesServer.h +59 -0
- data/ext/common/IniFile.h +488 -0
- data/ext/common/Logging.cpp +64 -0
- data/ext/common/Logging.h +695 -0
- data/ext/common/LoggingAgent/ChangeNotifier.h +63 -0
- data/ext/common/LoggingAgent/DataStoreId.h +177 -0
- data/ext/common/LoggingAgent/LoggingServer.h +1343 -0
- data/ext/common/LoggingAgent/Main.cpp +278 -0
- data/ext/common/LoggingAgent/RemoteSender.h +468 -0
- data/ext/common/MessageChannel.h +737 -0
- data/ext/common/MessageClient.h +297 -0
- data/ext/common/MessageReadersWriters.h +508 -0
- data/ext/common/MessageServer.h +581 -0
- data/ext/common/PoolOptions.h +518 -0
- data/ext/common/Process.h +255 -0
- data/ext/common/RandomGenerator.h +160 -0
- data/ext/common/ResourceLocator.h +134 -0
- data/ext/common/SafeLibev.h +149 -0
- data/ext/common/ServerInstanceDir.h +347 -0
- data/ext/common/Session.h +470 -0
- data/ext/common/SpawnManager.h +616 -0
- data/ext/common/StaticString.h +298 -0
- data/ext/common/StringListCreator.h +83 -0
- data/ext/common/Utils.cpp +972 -0
- data/ext/common/Utils.h +428 -0
- data/ext/common/Utils/Base64.cpp +143 -0
- data/ext/common/Utils/Base64.h +83 -0
- data/ext/common/Utils/BlockingQueue.h +136 -0
- data/ext/common/Utils/BufferedIO.h +196 -0
- data/ext/common/Utils/CachedFileStat.cpp +62 -0
- data/ext/common/Utils/CachedFileStat.h +51 -0
- data/ext/common/Utils/CachedFileStat.hpp +243 -0
- data/ext/common/Utils/FileChangeChecker.h +209 -0
- data/ext/common/Utils/IOUtils.cpp +913 -0
- data/ext/common/Utils/IOUtils.h +370 -0
- data/ext/common/Utils/MD5.cpp +406 -0
- data/ext/common/Utils/MD5.h +98 -0
- data/ext/common/Utils/MemZeroGuard.h +103 -0
- data/ext/common/Utils/ProcessMetricsCollector.h +590 -0
- data/ext/common/Utils/ScopeGuard.h +72 -0
- data/ext/common/Utils/StrIntUtils.cpp +363 -0
- data/ext/common/Utils/StrIntUtils.h +231 -0
- data/ext/common/Utils/SystemTime.cpp +37 -0
- data/ext/common/Utils/SystemTime.h +201 -0
- data/ext/common/Utils/Timer.h +152 -0
- data/ext/common/Utils/VariantMap.h +363 -0
- data/ext/common/Utils/utf8.h +35 -0
- data/ext/common/Utils/utf8/checked.h +324 -0
- data/ext/common/Utils/utf8/core.h +359 -0
- data/ext/common/Utils/utf8/unchecked.h +229 -0
- data/ext/common/Watchdog.cpp +1001 -0
- data/ext/google/COPYING +28 -0
- data/ext/google/ChangeLog +167 -0
- data/ext/google/dense_hash_map +310 -0
- data/ext/google/dense_hash_set +287 -0
- data/ext/google/sparse_hash_map +294 -0
- data/ext/google/sparse_hash_set +275 -0
- data/ext/google/sparsehash/densehashtable.h +1062 -0
- data/ext/google/sparsehash/sparseconfig.h +55 -0
- data/ext/google/sparsehash/sparsehashtable.h +1015 -0
- data/ext/google/sparsetable +1468 -0
- data/ext/google/type_traits.h +250 -0
- data/ext/libev/Changes +302 -0
- data/ext/libev/LICENSE +36 -0
- data/ext/libev/Makefile.am +18 -0
- data/ext/libev/Makefile.in +685 -0
- data/ext/libev/README +58 -0
- data/ext/libev/aclocal.m4 +7549 -0
- data/ext/libev/autogen.sh +6 -0
- data/ext/libev/config.guess +1526 -0
- data/ext/libev/config.h.in +121 -0
- data/ext/libev/config.sub +1658 -0
- data/ext/libev/configure +22156 -0
- data/ext/libev/configure.ac +18 -0
- data/ext/libev/ev++.h +800 -0
- data/ext/libev/ev.c +3694 -0
- data/ext/libev/ev.h +705 -0
- data/ext/libev/ev_epoll.c +228 -0
- data/ext/libev/ev_kqueue.c +196 -0
- data/ext/libev/ev_poll.c +144 -0
- data/ext/libev/ev_port.c +165 -0
- data/ext/libev/ev_select.c +308 -0
- data/ext/libev/ev_vars.h +187 -0
- data/ext/libev/ev_win32.c +153 -0
- data/ext/libev/ev_wrap.h +178 -0
- data/ext/libev/event.c +401 -0
- data/ext/libev/event.h +158 -0
- data/ext/libev/install-sh +294 -0
- data/ext/libev/libev.m4 +38 -0
- data/ext/libev/ltmain.sh +6871 -0
- data/ext/libev/missing +336 -0
- data/ext/libev/mkinstalldirs +111 -0
- data/ext/nginx/Configuration.c +1454 -0
- data/ext/nginx/Configuration.h +94 -0
- data/ext/nginx/ContentHandler.c +1360 -0
- data/ext/nginx/ContentHandler.h +64 -0
- data/ext/nginx/HelperAgent.cpp +988 -0
- data/ext/nginx/HttpStatusExtractor.h +351 -0
- data/ext/nginx/ScgiRequestParser.h +375 -0
- data/ext/nginx/StaticContentHandler.c +256 -0
- data/ext/nginx/StaticContentHandler.h +37 -0
- data/ext/nginx/config +56 -0
- data/ext/nginx/ngx_http_passenger_module.c +499 -0
- data/ext/nginx/ngx_http_passenger_module.h +63 -0
- data/ext/oxt/backtrace.cpp +185 -0
- data/ext/oxt/backtrace.hpp +135 -0
- data/ext/oxt/detail/backtrace_disabled.hpp +39 -0
- data/ext/oxt/detail/backtrace_enabled.hpp +156 -0
- data/ext/oxt/detail/spin_lock_darwin.hpp +69 -0
- data/ext/oxt/detail/spin_lock_gcc_x86.hpp +81 -0
- data/ext/oxt/detail/spin_lock_portable.hpp +38 -0
- data/ext/oxt/detail/spin_lock_pthreads.hpp +97 -0
- data/ext/oxt/detail/tracable_exception_disabled.hpp +46 -0
- data/ext/oxt/detail/tracable_exception_enabled.hpp +48 -0
- data/ext/oxt/dynamic_thread_group.hpp +195 -0
- data/ext/oxt/macros.hpp +58 -0
- data/ext/oxt/spin_lock.hpp +57 -0
- data/ext/oxt/system_calls.cpp +477 -0
- data/ext/oxt/system_calls.hpp +260 -0
- data/ext/oxt/thread.cpp +32 -0
- data/ext/oxt/thread.hpp +370 -0
- data/ext/oxt/tracable_exception.cpp +87 -0
- data/ext/oxt/tracable_exception.hpp +35 -0
- data/ext/ruby/extconf.rb +41 -0
- data/ext/ruby/passenger_native_support.c +1037 -0
- data/helper-scripts/passenger-spawn-server +106 -0
- data/helper-scripts/prespawn +63 -0
- data/lib/phusion_passenger.rb +107 -0
- data/lib/phusion_passenger/abstract_installer.rb +234 -0
- data/lib/phusion_passenger/abstract_request_handler.rb +738 -0
- data/lib/phusion_passenger/abstract_server.rb +372 -0
- data/lib/phusion_passenger/abstract_server_collection.rb +335 -0
- data/lib/phusion_passenger/admin_tools.rb +48 -0
- data/lib/phusion_passenger/admin_tools/memory_stats.rb +299 -0
- data/lib/phusion_passenger/admin_tools/server_instance.rb +334 -0
- data/lib/phusion_passenger/analytics_logger.rb +342 -0
- data/lib/phusion_passenger/app_process.rb +162 -0
- data/lib/phusion_passenger/classic_rails/application_spawner.rb +344 -0
- data/lib/phusion_passenger/classic_rails/cgi_fixed.rb +68 -0
- data/lib/phusion_passenger/classic_rails/framework_spawner.rb +311 -0
- data/lib/phusion_passenger/classic_rails/request_handler.rb +75 -0
- data/lib/phusion_passenger/classic_rails_extensions/analytics_logging/ac_base_extension.rb +65 -0
- data/lib/phusion_passenger/classic_rails_extensions/analytics_logging/ac_benchmarking_extension.rb +48 -0
- data/lib/phusion_passenger/classic_rails_extensions/analytics_logging/ac_rescue_extension.rb +59 -0
- data/lib/phusion_passenger/classic_rails_extensions/analytics_logging/ar_abstract_adapter_extension.rb +54 -0
- data/lib/phusion_passenger/classic_rails_extensions/analytics_logging/as_cache_extension.rb +130 -0
- data/lib/phusion_passenger/classic_rails_extensions/analytics_logging/av_benchmark_helper_extension.rb +47 -0
- data/lib/phusion_passenger/classic_rails_extensions/init.rb +123 -0
- data/lib/phusion_passenger/console_text_template.rb +66 -0
- data/lib/phusion_passenger/constants.rb +35 -0
- data/lib/phusion_passenger/debug_logging.rb +104 -0
- data/lib/phusion_passenger/dependencies.rb +633 -0
- data/lib/phusion_passenger/exceptions.rb +103 -0
- data/lib/phusion_passenger/html_template.rb +107 -0
- data/lib/phusion_passenger/message_channel.rb +387 -0
- data/lib/phusion_passenger/message_client.rb +173 -0
- data/lib/phusion_passenger/native_support.rb +166 -0
- data/lib/phusion_passenger/packaging.rb +108 -0
- data/lib/phusion_passenger/platform_info.rb +248 -0
- data/lib/phusion_passenger/platform_info/apache.rb +332 -0
- data/lib/phusion_passenger/platform_info/binary_compatibility.rb +175 -0
- data/lib/phusion_passenger/platform_info/compiler.rb +183 -0
- data/lib/phusion_passenger/platform_info/curl.rb +61 -0
- data/lib/phusion_passenger/platform_info/documentation_tools.rb +35 -0
- data/lib/phusion_passenger/platform_info/linux.rb +77 -0
- data/lib/phusion_passenger/platform_info/operating_system.rb +158 -0
- data/lib/phusion_passenger/platform_info/ruby.rb +338 -0
- data/lib/phusion_passenger/platform_info/zlib.rb +38 -0
- data/lib/phusion_passenger/plugin.rb +96 -0
- data/lib/phusion_passenger/public_api.rb +112 -0
- data/lib/phusion_passenger/rack/application_spawner.rb +227 -0
- data/lib/phusion_passenger/rack/request_handler.rb +145 -0
- data/lib/phusion_passenger/rails3_extensions/init.rb +207 -0
- data/lib/phusion_passenger/simple_benchmarking.rb +52 -0
- data/lib/phusion_passenger/spawn_manager.rb +359 -0
- data/lib/phusion_passenger/standalone/app_finder.rb +153 -0
- data/lib/phusion_passenger/standalone/command.rb +241 -0
- data/lib/phusion_passenger/standalone/config_file.rb +119 -0
- data/lib/phusion_passenger/standalone/help_command.rb +57 -0
- data/lib/phusion_passenger/standalone/main.rb +101 -0
- data/lib/phusion_passenger/standalone/package_runtime_command.rb +92 -0
- data/lib/phusion_passenger/standalone/runtime_installer.rb +479 -0
- data/lib/phusion_passenger/standalone/start_command.rb +514 -0
- data/lib/phusion_passenger/standalone/status_command.rb +62 -0
- data/lib/phusion_passenger/standalone/stop_command.rb +74 -0
- data/lib/phusion_passenger/standalone/utils.rb +46 -0
- data/lib/phusion_passenger/standalone/version_command.rb +42 -0
- data/lib/phusion_passenger/templates/apache2/apache_must_be_compiled_with_compatible_mpm.txt.erb +9 -0
- data/lib/phusion_passenger/templates/apache2/config_snippets.txt.erb +13 -0
- data/lib/phusion_passenger/templates/apache2/deployment_example.txt.erb +23 -0
- data/lib/phusion_passenger/templates/apache2/no_write_permission_to_passenger_root.txt.erb +9 -0
- data/lib/phusion_passenger/templates/apache2/possible_solutions_for_compilation_and_installation_problems.txt.erb +11 -0
- data/lib/phusion_passenger/templates/apache2/run_installer_as_root.txt.erb +8 -0
- data/lib/phusion_passenger/templates/apache2/welcome.txt.erb +15 -0
- data/lib/phusion_passenger/templates/app_exited_during_initialization.html.erb +38 -0
- data/lib/phusion_passenger/templates/app_init_error.html.erb +64 -0
- data/lib/phusion_passenger/templates/database_error.html.erb +66 -0
- data/lib/phusion_passenger/templates/error_layout.css +97 -0
- data/lib/phusion_passenger/templates/error_layout.html.erb +39 -0
- data/lib/phusion_passenger/templates/framework_init_error.html.erb +39 -0
- data/lib/phusion_passenger/templates/general_error.html.erb +22 -0
- data/lib/phusion_passenger/templates/load_error.html.erb +46 -0
- data/lib/phusion_passenger/templates/nginx/ask_for_extra_configure_flags.txt.erb +8 -0
- data/lib/phusion_passenger/templates/nginx/cannot_write_to_dir.txt.erb +11 -0
- data/lib/phusion_passenger/templates/nginx/config_snippets.txt.erb +17 -0
- data/lib/phusion_passenger/templates/nginx/config_snippets_inserted.txt.erb +20 -0
- data/lib/phusion_passenger/templates/nginx/confirm_extra_configure_flags.txt.erb +5 -0
- data/lib/phusion_passenger/templates/nginx/deployment_example.txt.erb +22 -0
- data/lib/phusion_passenger/templates/nginx/pcre_could_not_be_downloaded.txt.erb +11 -0
- data/lib/phusion_passenger/templates/nginx/pcre_could_not_be_extracted.txt.erb +11 -0
- data/lib/phusion_passenger/templates/nginx/possible_solutions_for_compilation_and_installation_problems.txt.erb +11 -0
- data/lib/phusion_passenger/templates/nginx/possible_solutions_for_download_and_extraction_problems.txt.erb +20 -0
- data/lib/phusion_passenger/templates/nginx/query_download_and_install.txt.erb +21 -0
- data/lib/phusion_passenger/templates/nginx/run_installer_as_root.txt.erb +8 -0
- data/lib/phusion_passenger/templates/nginx/welcome.txt.erb +15 -0
- data/lib/phusion_passenger/templates/standalone/cannot_write_to_dir.txt.erb +11 -0
- data/lib/phusion_passenger/templates/standalone/config.erb +94 -0
- data/lib/phusion_passenger/templates/standalone/possible_solutions_for_download_and_extraction_problems.txt.erb +17 -0
- data/lib/phusion_passenger/templates/standalone/run_installer_as_root.txt.erb +8 -0
- data/lib/phusion_passenger/templates/standalone/welcome.txt.erb +8 -0
- data/lib/phusion_passenger/templates/standalone_default_root/index.html +1 -0
- data/lib/phusion_passenger/templates/version_not_found.html.erb +34 -0
- data/lib/phusion_passenger/utils.rb +1080 -0
- data/lib/phusion_passenger/utils/file_system_watcher.rb +186 -0
- data/lib/phusion_passenger/utils/hosts_file_parser.rb +130 -0
- data/lib/phusion_passenger/utils/rewindable_input.rb +125 -0
- data/lib/phusion_passenger/utils/tmpdir.rb +70 -0
- data/lib/phusion_passenger/utils/unseekable_socket.rb +196 -0
- data/lib/phusion_passenger/wsgi/application_spawner.rb +108 -0
- data/lib/phusion_passenger/wsgi/request_handler.py +199 -0
- data/man/passenger-config.1 +29 -0
- data/man/passenger-make-enterprisey.8 +23 -0
- data/man/passenger-memory-stats.8 +33 -0
- data/man/passenger-status.8 +43 -0
- data/man/passenger-stress-test.1 +43 -0
- data/resources/mime.types +73 -0
- data/resources/union_station_gateway.crt +32 -0
- data/test/config.yml.example +41 -0
- data/test/cxx/ApplicationPool_PoolTest.cpp +33 -0
- data/test/cxx/ApplicationPool_PoolTestCases.cpp +1029 -0
- data/test/cxx/ApplicationPool_ServerTest.cpp +308 -0
- data/test/cxx/ApplicationPool_Server_PoolTest.cpp +80 -0
- data/test/cxx/Base64Test.cpp +50 -0
- data/test/cxx/BufferedIOTest.cpp +364 -0
- data/test/cxx/CachedFileStatTest.cpp +402 -0
- data/test/cxx/CxxTestMain.cpp +122 -0
- data/test/cxx/EventedClientTest.cpp +523 -0
- data/test/cxx/FileChangeCheckerTest.cpp +329 -0
- data/test/cxx/FileDescriptorTest.cpp +69 -0
- data/test/cxx/HttpStatusExtractorTest.cpp +198 -0
- data/test/cxx/IOUtilsTest.cpp +796 -0
- data/test/cxx/LoggingTest.cpp +914 -0
- data/test/cxx/MessageChannelTest.cpp +557 -0
- data/test/cxx/MessageReadersWritersTest.cpp +574 -0
- data/test/cxx/MessageServerTest.cpp +383 -0
- data/test/cxx/PoolOptionsTest.cpp +116 -0
- data/test/cxx/ProcessMetricsCollectorTest.cpp +121 -0
- data/test/cxx/ScgiRequestParserTest.cpp +389 -0
- data/test/cxx/ServerInstanceDirTest.cpp +186 -0
- data/test/cxx/SpawnManagerTest.cpp +161 -0
- data/test/cxx/StaticStringTest.cpp +220 -0
- data/test/cxx/SystemTimeTest.cpp +37 -0
- data/test/cxx/TestSupport.cpp +166 -0
- data/test/cxx/TestSupport.h +254 -0
- data/test/cxx/UtilsTest.cpp +491 -0
- data/test/cxx/VariantMapTest.cpp +179 -0
- data/test/integration_tests/apache2_tests.rb +666 -0
- data/test/integration_tests/cgi_environment_spec.rb +26 -0
- data/test/integration_tests/hello_world_rack_spec.rb +36 -0
- data/test/integration_tests/hello_world_wsgi_spec.rb +41 -0
- data/test/integration_tests/mycook_spec.rb +166 -0
- data/test/integration_tests/nginx_tests.rb +260 -0
- data/test/integration_tests/spec_helper.rb +19 -0
- data/test/oxt/backtrace_test.cpp +88 -0
- data/test/oxt/counter.hpp +55 -0
- data/test/oxt/dynamic_thread_group_test.cpp +131 -0
- data/test/oxt/oxt_test_main.cpp +25 -0
- data/test/oxt/spin_lock_test.cpp +59 -0
- data/test/oxt/syscall_interruption_test.cpp +38 -0
- data/test/ruby/abstract_request_handler_spec.rb +406 -0
- data/test/ruby/abstract_server_collection_spec.rb +247 -0
- data/test/ruby/abstract_server_spec.rb +61 -0
- data/test/ruby/admin_tools_spec.rb +362 -0
- data/test/ruby/analytics_logger_spec.rb +253 -0
- data/test/ruby/app_process_spec.rb +43 -0
- data/test/ruby/classic_rails/application_spawner_spec.rb +89 -0
- data/test/ruby/classic_rails/framework_spawner_spec.rb +92 -0
- data/test/ruby/debug_logging_spec.rb +141 -0
- data/test/ruby/message_channel_spec.rb +196 -0
- data/test/ruby/rack/application_spawner_spec.rb +116 -0
- data/test/ruby/shared/abstract_server_spec.rb +23 -0
- data/test/ruby/shared/rails/analytics_logging_extensions_spec.rb +375 -0
- data/test/ruby/shared/spawners/classic_rails/framework_spawner_spec.rb +38 -0
- data/test/ruby/shared/spawners/classic_rails/lack_of_rails_gem_version_spec.rb +19 -0
- data/test/ruby/shared/spawners/classic_rails/spawner_spec.rb +15 -0
- data/test/ruby/shared/spawners/non_preloading_spawner_spec.rb +27 -0
- data/test/ruby/shared/spawners/preloading_spawner_spec.rb +29 -0
- data/test/ruby/shared/spawners/reload_all_spec.rb +36 -0
- data/test/ruby/shared/spawners/reload_single_spec.rb +52 -0
- data/test/ruby/shared/spawners/spawn_server_spec.rb +28 -0
- data/test/ruby/shared/spawners/spawner_spec.rb +273 -0
- data/test/ruby/shared/utils/pseudo_io_spec.rb +60 -0
- data/test/ruby/spawn_manager_spec.rb +134 -0
- data/test/ruby/spec_helper.rb +104 -0
- data/test/ruby/utils/file_system_watcher_spec.rb +221 -0
- data/test/ruby/utils/hosts_file_parser.rb +258 -0
- data/test/ruby/utils/unseekable_socket_spec.rb +66 -0
- data/test/ruby/utils_spec.rb +748 -0
- data/test/ruby/wsgi/application_spawner_spec.rb +50 -0
- data/test/stub/apache2/httpd.conf.erb +86 -0
- data/test/stub/apache2/mime.types +748 -0
- data/test/stub/garbage1.dat +0 -0
- data/test/stub/garbage2.dat +0 -0
- data/test/stub/garbage3.dat +0 -0
- data/test/stub/http_request.yml +23 -0
- data/test/stub/message_channel.rb +11 -0
- data/test/stub/message_channel_2.rb +12 -0
- data/test/stub/message_channel_3.rb +19 -0
- data/test/stub/nginx/koi-utf +109 -0
- data/test/stub/nginx/koi-win +103 -0
- data/test/stub/nginx/mime.types +70 -0
- data/test/stub/nginx/nginx.conf.erb +58 -0
- data/test/stub/nginx/win-utf +126 -0
- data/test/stub/rack/config.ru +4 -0
- data/test/stub/rack/public/rack.jpg +0 -0
- data/test/stub/rails_apps/1.2/empty/Rakefile +10 -0
- data/test/stub/rails_apps/1.2/empty/app/controllers/application.rb +7 -0
- data/test/stub/rails_apps/1.2/empty/app/helpers/application_helper.rb +3 -0
- data/test/stub/rails_apps/1.2/empty/config/boot.rb +108 -0
- data/test/stub/rails_apps/1.2/empty/config/database.yml +31 -0
- data/test/stub/rails_apps/1.2/empty/config/environment.rb +66 -0
- data/test/stub/rails_apps/1.2/empty/config/environments/development.rb +21 -0
- data/test/stub/rails_apps/1.2/empty/config/environments/production.rb +18 -0
- data/test/stub/rails_apps/1.2/empty/config/environments/staging.rb +18 -0
- data/test/stub/rails_apps/1.2/empty/config/environments/test.rb +19 -0
- data/test/stub/rails_apps/1.2/empty/config/routes.rb +23 -0
- data/test/stub/rails_apps/1.2/empty/doc/README_FOR_APP +2 -0
- data/test/stub/rails_apps/1.2/empty/public/404.html +30 -0
- data/test/stub/rails_apps/1.2/empty/public/500.html +30 -0
- data/test/stub/rails_apps/1.2/empty/public/dispatch.cgi +10 -0
- data/test/stub/rails_apps/1.2/empty/public/dispatch.fcgi +24 -0
- data/test/stub/rails_apps/1.2/empty/public/dispatch.rb +10 -0
- data/test/stub/rails_apps/1.2/empty/public/favicon.ico +0 -0
- data/test/stub/rails_apps/1.2/empty/public/images/rails.png +0 -0
- data/test/stub/rails_apps/1.2/empty/public/robots.txt +1 -0
- data/test/stub/rails_apps/1.2/empty/script/about +3 -0
- data/test/stub/rails_apps/1.2/empty/script/breakpointer +3 -0
- data/test/stub/rails_apps/1.2/empty/script/console +3 -0
- data/test/stub/rails_apps/1.2/empty/script/destroy +3 -0
- data/test/stub/rails_apps/1.2/empty/script/generate +3 -0
- data/test/stub/rails_apps/1.2/empty/script/performance/benchmarker +3 -0
- data/test/stub/rails_apps/1.2/empty/script/performance/profiler +3 -0
- data/test/stub/rails_apps/1.2/empty/script/plugin +3 -0
- data/test/stub/rails_apps/1.2/empty/script/process/inspector +3 -0
- data/test/stub/rails_apps/1.2/empty/script/process/reaper +3 -0
- data/test/stub/rails_apps/1.2/empty/script/process/spawner +3 -0
- data/test/stub/rails_apps/1.2/empty/script/runner +3 -0
- data/test/stub/rails_apps/1.2/empty/script/server +3 -0
- data/test/stub/rails_apps/1.2/empty/test/test_helper.rb +28 -0
- data/test/stub/rails_apps/2.0/empty/Rakefile +10 -0
- data/test/stub/rails_apps/2.0/empty/app/controllers/application.rb +10 -0
- data/test/stub/rails_apps/2.0/empty/app/helpers/application_helper.rb +3 -0
- data/test/stub/rails_apps/2.0/empty/config/boot.rb +108 -0
- data/test/stub/rails_apps/2.0/empty/config/database.yml +31 -0
- data/test/stub/rails_apps/2.0/empty/config/environment.rb +59 -0
- data/test/stub/rails_apps/2.0/empty/config/environments/development.rb +18 -0
- data/test/stub/rails_apps/2.0/empty/config/environments/production.rb +18 -0
- data/test/stub/rails_apps/2.0/empty/config/environments/staging.rb +18 -0
- data/test/stub/rails_apps/2.0/empty/config/environments/test.rb +22 -0
- data/test/stub/rails_apps/2.0/empty/config/initializers/inflections.rb +10 -0
- data/test/stub/rails_apps/2.0/empty/config/initializers/mime_types.rb +5 -0
- data/test/stub/rails_apps/2.0/empty/config/routes.rb +35 -0
- data/test/stub/rails_apps/2.0/empty/doc/README_FOR_APP +2 -0
- data/test/stub/rails_apps/2.0/empty/public/404.html +30 -0
- data/test/stub/rails_apps/2.0/empty/public/422.html +30 -0
- data/test/stub/rails_apps/2.0/empty/public/500.html +30 -0
- data/test/stub/rails_apps/2.0/empty/public/dispatch.cgi +10 -0
- data/test/stub/rails_apps/2.0/empty/public/dispatch.fcgi +24 -0
- data/test/stub/rails_apps/2.0/empty/public/dispatch.rb +10 -0
- data/test/stub/rails_apps/2.0/empty/public/favicon.ico +0 -0
- data/test/stub/rails_apps/2.0/empty/public/images/rails.png +0 -0
- data/test/stub/rails_apps/2.0/empty/public/robots.txt +5 -0
- data/test/stub/rails_apps/2.0/empty/script/about +3 -0
- data/test/stub/rails_apps/2.0/empty/script/console +3 -0
- data/test/stub/rails_apps/2.0/empty/script/destroy +3 -0
- data/test/stub/rails_apps/2.0/empty/script/generate +3 -0
- data/test/stub/rails_apps/2.0/empty/script/performance/benchmarker +3 -0
- data/test/stub/rails_apps/2.0/empty/script/performance/profiler +3 -0
- data/test/stub/rails_apps/2.0/empty/script/performance/request +3 -0
- data/test/stub/rails_apps/2.0/empty/script/plugin +3 -0
- data/test/stub/rails_apps/2.0/empty/script/process/inspector +3 -0
- data/test/stub/rails_apps/2.0/empty/script/process/reaper +3 -0
- data/test/stub/rails_apps/2.0/empty/script/process/spawner +3 -0
- data/test/stub/rails_apps/2.0/empty/script/runner +3 -0
- data/test/stub/rails_apps/2.0/empty/script/server +3 -0
- data/test/stub/rails_apps/2.0/empty/test/test_helper.rb +38 -0
- data/test/stub/rails_apps/2.2/empty/Rakefile +10 -0
- data/test/stub/rails_apps/2.2/empty/app/controllers/application.rb +15 -0
- data/test/stub/rails_apps/2.2/empty/app/helpers/application_helper.rb +3 -0
- data/test/stub/rails_apps/2.2/empty/config/boot.rb +109 -0
- data/test/stub/rails_apps/2.2/empty/config/database.yml +31 -0
- data/test/stub/rails_apps/2.2/empty/config/environment.rb +75 -0
- data/test/stub/rails_apps/2.2/empty/config/environments/development.rb +17 -0
- data/test/stub/rails_apps/2.2/empty/config/environments/production.rb +24 -0
- data/test/stub/rails_apps/2.2/empty/config/environments/staging.rb +24 -0
- data/test/stub/rails_apps/2.2/empty/config/environments/test.rb +22 -0
- data/test/stub/rails_apps/2.2/empty/config/initializers/inflections.rb +10 -0
- data/test/stub/rails_apps/2.2/empty/config/initializers/mime_types.rb +5 -0
- data/test/stub/rails_apps/2.2/empty/config/initializers/new_rails_defaults.rb +17 -0
- data/test/stub/rails_apps/2.2/empty/config/locales/en.yml +5 -0
- data/test/stub/rails_apps/2.2/empty/config/routes.rb +43 -0
- data/test/stub/rails_apps/2.2/empty/doc/README_FOR_APP +5 -0
- data/test/stub/rails_apps/2.2/empty/public/404.html +30 -0
- data/test/stub/rails_apps/2.2/empty/public/422.html +30 -0
- data/test/stub/rails_apps/2.2/empty/public/500.html +33 -0
- data/test/stub/rails_apps/2.2/empty/public/dispatch.cgi +10 -0
- data/test/stub/rails_apps/2.2/empty/public/dispatch.fcgi +24 -0
- data/test/stub/rails_apps/2.2/empty/public/dispatch.rb +10 -0
- data/test/stub/rails_apps/2.2/empty/public/favicon.ico +0 -0
- data/test/stub/rails_apps/2.2/empty/public/images/rails.png +0 -0
- data/test/stub/rails_apps/2.2/empty/public/robots.txt +5 -0
- data/test/stub/rails_apps/2.2/empty/script/about +4 -0
- data/test/stub/rails_apps/2.2/empty/script/console +3 -0
- data/test/stub/rails_apps/2.2/empty/script/dbconsole +3 -0
- data/test/stub/rails_apps/2.2/empty/script/destroy +3 -0
- data/test/stub/rails_apps/2.2/empty/script/generate +3 -0
- data/test/stub/rails_apps/2.2/empty/script/performance/benchmarker +3 -0
- data/test/stub/rails_apps/2.2/empty/script/performance/profiler +3 -0
- data/test/stub/rails_apps/2.2/empty/script/performance/request +3 -0
- data/test/stub/rails_apps/2.2/empty/script/plugin +3 -0
- data/test/stub/rails_apps/2.2/empty/script/process/inspector +3 -0
- data/test/stub/rails_apps/2.2/empty/script/process/reaper +3 -0
- data/test/stub/rails_apps/2.2/empty/script/process/spawner +3 -0
- data/test/stub/rails_apps/2.2/empty/script/runner +3 -0
- data/test/stub/rails_apps/2.2/empty/script/server +3 -0
- data/test/stub/rails_apps/2.2/empty/test/performance/browsing_test.rb +9 -0
- data/test/stub/rails_apps/2.2/empty/test/test_helper.rb +38 -0
- data/test/stub/rails_apps/2.3/empty/Rakefile +10 -0
- data/test/stub/rails_apps/2.3/empty/app/controllers/application_controller.rb +10 -0
- data/test/stub/rails_apps/2.3/empty/app/helpers/application_helper.rb +3 -0
- data/test/stub/rails_apps/2.3/empty/config/boot.rb +110 -0
- data/test/stub/rails_apps/2.3/empty/config/database.yml +31 -0
- data/test/stub/rails_apps/2.3/empty/config/environment.rb +41 -0
- data/test/stub/rails_apps/2.3/empty/config/environments/development.rb +17 -0
- data/test/stub/rails_apps/2.3/empty/config/environments/production.rb +28 -0
- data/test/stub/rails_apps/2.3/empty/config/environments/staging.rb +28 -0
- data/test/stub/rails_apps/2.3/empty/config/environments/test.rb +28 -0
- data/test/stub/rails_apps/2.3/empty/config/initializers/backtrace_silencers.rb +7 -0
- data/test/stub/rails_apps/2.3/empty/config/initializers/inflections.rb +10 -0
- data/test/stub/rails_apps/2.3/empty/config/initializers/mime_types.rb +5 -0
- data/test/stub/rails_apps/2.3/empty/config/initializers/new_rails_defaults.rb +21 -0
- data/test/stub/rails_apps/2.3/empty/config/initializers/session_store.rb +15 -0
- data/test/stub/rails_apps/2.3/empty/config/locales/en.yml +5 -0
- data/test/stub/rails_apps/2.3/empty/config/routes.rb +43 -0
- data/test/stub/rails_apps/2.3/empty/db/seeds.rb +7 -0
- data/test/stub/rails_apps/2.3/empty/doc/README_FOR_APP +2 -0
- data/test/stub/rails_apps/2.3/empty/public/404.html +30 -0
- data/test/stub/rails_apps/2.3/empty/public/422.html +30 -0
- data/test/stub/rails_apps/2.3/empty/public/500.html +30 -0
- data/test/stub/rails_apps/2.3/empty/public/favicon.ico +0 -0
- data/test/stub/rails_apps/2.3/empty/public/images/rails.png +0 -0
- data/test/stub/rails_apps/2.3/empty/public/robots.txt +5 -0
- data/test/stub/rails_apps/2.3/empty/script/about +4 -0
- data/test/stub/rails_apps/2.3/empty/script/console +3 -0
- data/test/stub/rails_apps/2.3/empty/script/dbconsole +3 -0
- data/test/stub/rails_apps/2.3/empty/script/destroy +3 -0
- data/test/stub/rails_apps/2.3/empty/script/generate +3 -0
- data/test/stub/rails_apps/2.3/empty/script/performance/benchmarker +3 -0
- data/test/stub/rails_apps/2.3/empty/script/performance/profiler +3 -0
- data/test/stub/rails_apps/2.3/empty/script/plugin +3 -0
- data/test/stub/rails_apps/2.3/empty/script/runner +3 -0
- data/test/stub/rails_apps/2.3/empty/script/server +3 -0
- data/test/stub/rails_apps/2.3/empty/test/performance/browsing_test.rb +9 -0
- data/test/stub/rails_apps/2.3/empty/test/test_helper.rb +38 -0
- data/test/stub/rails_apps/2.3/foobar/Rakefile +10 -0
- data/test/stub/rails_apps/2.3/foobar/app/controllers/application_controller.rb +12 -0
- data/test/stub/rails_apps/2.3/foobar/app/controllers/bar_controller_1.rb +5 -0
- data/test/stub/rails_apps/2.3/foobar/app/controllers/bar_controller_2.rb +5 -0
- data/test/stub/rails_apps/2.3/foobar/app/controllers/foo_controller.rb +21 -0
- data/test/stub/rails_apps/2.3/foobar/app/helpers/application_helper.rb +3 -0
- data/test/stub/rails_apps/2.3/foobar/config/boot.rb +110 -0
- data/test/stub/rails_apps/2.3/foobar/config/database.yml +19 -0
- data/test/stub/rails_apps/2.3/foobar/config/environment.rb +59 -0
- data/test/stub/rails_apps/2.3/foobar/config/environments/development.rb +17 -0
- data/test/stub/rails_apps/2.3/foobar/config/environments/production.rb +18 -0
- data/test/stub/rails_apps/2.3/foobar/config/environments/staging.rb +18 -0
- data/test/stub/rails_apps/2.3/foobar/config/initializers/inflections.rb +10 -0
- data/test/stub/rails_apps/2.3/foobar/config/initializers/mime_types.rb +5 -0
- data/test/stub/rails_apps/2.3/foobar/config/routes.rb +35 -0
- data/test/stub/rails_apps/2.3/foobar/script/about +3 -0
- data/test/stub/rails_apps/2.3/foobar/script/console +3 -0
- data/test/stub/rails_apps/2.3/foobar/script/dbconsole +3 -0
- data/test/stub/rails_apps/2.3/foobar/script/destroy +3 -0
- data/test/stub/rails_apps/2.3/foobar/script/generate +3 -0
- data/test/stub/rails_apps/2.3/foobar/script/performance/benchmarker +3 -0
- data/test/stub/rails_apps/2.3/foobar/script/performance/profiler +3 -0
- data/test/stub/rails_apps/2.3/foobar/script/performance/request +3 -0
- data/test/stub/rails_apps/2.3/foobar/script/plugin +3 -0
- data/test/stub/rails_apps/2.3/foobar/script/process/inspector +3 -0
- data/test/stub/rails_apps/2.3/foobar/script/process/reaper +3 -0
- data/test/stub/rails_apps/2.3/foobar/script/process/spawner +3 -0
- data/test/stub/rails_apps/2.3/foobar/script/runner +3 -0
- data/test/stub/rails_apps/2.3/foobar/script/server +3 -0
- data/test/stub/rails_apps/2.3/mycook/Rakefile +10 -0
- data/test/stub/rails_apps/2.3/mycook/app/controllers/application_controller.rb +12 -0
- data/test/stub/rails_apps/2.3/mycook/app/controllers/recipes_controller.rb +5 -0
- data/test/stub/rails_apps/2.3/mycook/app/controllers/uploads_controller.rb +15 -0
- data/test/stub/rails_apps/2.3/mycook/app/controllers/welcome_controller.rb +71 -0
- data/test/stub/rails_apps/2.3/mycook/app/helpers/application_helper.rb +3 -0
- data/test/stub/rails_apps/2.3/mycook/app/views/layouts/default.rhtml +26 -0
- data/test/stub/rails_apps/2.3/mycook/app/views/recipes/create.rhtml +13 -0
- data/test/stub/rails_apps/2.3/mycook/app/views/recipes/index.rhtml +3 -0
- data/test/stub/rails_apps/2.3/mycook/app/views/recipes/new.rhtml +8 -0
- data/test/stub/rails_apps/2.3/mycook/app/views/uploads/index.rhtml +1 -0
- data/test/stub/rails_apps/2.3/mycook/app/views/uploads/new.html.erb +8 -0
- data/test/stub/rails_apps/2.3/mycook/app/views/welcome/cached.rhtml +1 -0
- data/test/stub/rails_apps/2.3/mycook/app/views/welcome/index.rhtml +20 -0
- data/test/stub/rails_apps/2.3/mycook/config/boot.rb +110 -0
- data/test/stub/rails_apps/2.3/mycook/config/database.yml +19 -0
- data/test/stub/rails_apps/2.3/mycook/config/environment.rb +61 -0
- data/test/stub/rails_apps/2.3/mycook/config/environments/development.rb +18 -0
- data/test/stub/rails_apps/2.3/mycook/config/environments/production.rb +19 -0
- data/test/stub/rails_apps/2.3/mycook/config/initializers/inflections.rb +10 -0
- data/test/stub/rails_apps/2.3/mycook/config/initializers/mime_types.rb +5 -0
- data/test/stub/rails_apps/2.3/mycook/config/routes.rb +38 -0
- data/test/stub/rails_apps/2.3/mycook/log/useless.txt +1 -0
- data/test/stub/rails_apps/2.3/mycook/public/404.html +30 -0
- data/test/stub/rails_apps/2.3/mycook/public/422.html +30 -0
- data/test/stub/rails_apps/2.3/mycook/public/500.html +30 -0
- data/test/stub/rails_apps/2.3/mycook/public/dispatch.cgi +10 -0
- data/test/stub/rails_apps/2.3/mycook/public/dispatch.fcgi +24 -0
- data/test/stub/rails_apps/2.3/mycook/public/dispatch.rb +10 -0
- data/test/stub/rails_apps/2.3/mycook/public/favicon.ico +0 -0
- data/test/stub/rails_apps/2.3/mycook/public/images/angrywizard.gif +0 -0
- data/test/stub/rails_apps/2.3/mycook/public/images/cookbook.gif +0 -0
- data/test/stub/rails_apps/2.3/mycook/public/images/header.png +0 -0
- data/test/stub/rails_apps/2.3/mycook/public/images/rails.png +0 -0
- data/test/stub/rails_apps/2.3/mycook/public/javascripts/application.js +2 -0
- data/test/stub/rails_apps/2.3/mycook/public/javascripts/controls.js +963 -0
- data/test/stub/rails_apps/2.3/mycook/public/javascripts/dragdrop.js +973 -0
- data/test/stub/rails_apps/2.3/mycook/public/javascripts/effects.js +1128 -0
- data/test/stub/rails_apps/2.3/mycook/public/javascripts/prototype.js +4320 -0
- data/test/stub/rails_apps/2.3/mycook/public/robots.txt +5 -0
- data/test/stub/rails_apps/2.3/mycook/public/uploads.html +26 -0
- data/test/stub/rails_apps/2.3/mycook/public/welcome/cached.html +26 -0
- data/test/stub/rails_apps/2.3/mycook/script/about +3 -0
- data/test/stub/rails_apps/2.3/mycook/script/console +3 -0
- data/test/stub/rails_apps/2.3/mycook/script/dbconsole +3 -0
- data/test/stub/rails_apps/2.3/mycook/script/destroy +3 -0
- data/test/stub/rails_apps/2.3/mycook/script/generate +3 -0
- data/test/stub/rails_apps/2.3/mycook/script/performance/benchmarker +3 -0
- data/test/stub/rails_apps/2.3/mycook/script/performance/profiler +3 -0
- data/test/stub/rails_apps/2.3/mycook/script/performance/request +3 -0
- data/test/stub/rails_apps/2.3/mycook/script/plugin +3 -0
- data/test/stub/rails_apps/2.3/mycook/script/process/inspector +3 -0
- data/test/stub/rails_apps/2.3/mycook/script/process/reaper +3 -0
- data/test/stub/rails_apps/2.3/mycook/script/process/spawner +3 -0
- data/test/stub/rails_apps/2.3/mycook/script/runner +3 -0
- data/test/stub/rails_apps/2.3/mycook/script/server +3 -0
- data/test/stub/rails_apps/2.3/mycook/sites/some.site/public/uploads.html +26 -0
- data/test/stub/rails_apps/2.3/mycook/sites/some.site/public/welcome/cached.html +26 -0
- data/test/stub/rails_apps/2.3/mycook/tmp/cache/useless.txt +1 -0
- data/test/stub/rails_apps/2.3/mycook/tmp/pids/useless.txt +1 -0
- data/test/stub/rails_apps/2.3/mycook/tmp/sessions/useless.txt +1 -0
- data/test/stub/rails_apps/2.3/mycook/tmp/sockets/useless.txt +1 -0
- data/test/stub/rails_apps/3.0/empty/Gemfile +22 -0
- data/test/stub/rails_apps/3.0/empty/Gemfile.lock +73 -0
- data/test/stub/rails_apps/3.0/empty/Rakefile +10 -0
- data/test/stub/rails_apps/3.0/empty/app/controllers/application_controller.rb +4 -0
- data/test/stub/rails_apps/3.0/empty/app/helpers/application_helper.rb +2 -0
- data/test/stub/rails_apps/3.0/empty/app/views/layouts/application.html.erb +14 -0
- data/test/stub/rails_apps/3.0/empty/config.ru +4 -0
- data/test/stub/rails_apps/3.0/empty/config/application.rb +48 -0
- data/test/stub/rails_apps/3.0/empty/config/boot.rb +13 -0
- data/test/stub/rails_apps/3.0/empty/config/database.yml +22 -0
- data/test/stub/rails_apps/3.0/empty/config/environment.rb +5 -0
- data/test/stub/rails_apps/3.0/empty/config/environments/development.rb +19 -0
- data/test/stub/rails_apps/3.0/empty/config/environments/production.rb +48 -0
- data/test/stub/rails_apps/3.0/empty/config/environments/test.rb +32 -0
- data/test/stub/rails_apps/3.0/empty/config/initializers/backtrace_silencers.rb +7 -0
- data/test/stub/rails_apps/3.0/empty/config/initializers/inflections.rb +10 -0
- data/test/stub/rails_apps/3.0/empty/config/initializers/mime_types.rb +5 -0
- data/test/stub/rails_apps/3.0/empty/config/initializers/passenger.rb +1 -0
- data/test/stub/rails_apps/3.0/empty/config/initializers/secret_token.rb +7 -0
- data/test/stub/rails_apps/3.0/empty/config/initializers/session_store.rb +8 -0
- data/test/stub/rails_apps/3.0/empty/config/locales/en.yml +5 -0
- data/test/stub/rails_apps/3.0/empty/config/routes.rb +58 -0
- data/test/stub/rails_apps/3.0/empty/db/seeds.rb +7 -0
- data/test/stub/rails_apps/3.0/empty/doc/README_FOR_APP +2 -0
- data/test/stub/rails_apps/3.0/empty/public/404.html +26 -0
- data/test/stub/rails_apps/3.0/empty/public/422.html +26 -0
- data/test/stub/rails_apps/3.0/empty/public/500.html +26 -0
- data/test/stub/rails_apps/3.0/empty/public/favicon.ico +0 -0
- data/test/stub/rails_apps/3.0/empty/public/index.html +279 -0
- data/test/stub/rails_apps/3.0/empty/public/robots.txt +5 -0
- data/test/stub/rails_apps/3.0/empty/script/rails +9 -0
- data/test/stub/rails_apps/3.0/empty/test/performance/browsing_test.rb +9 -0
- data/test/stub/rails_apps/3.0/empty/test/test_helper.rb +13 -0
- data/test/stub/spawn_server.rb +22 -0
- data/test/stub/upload_data.txt +494 -0
- data/test/stub/vendor_rails/minimal/README +1 -0
- data/test/stub/vendor_rails/minimal/actionmailer/lib/action_mailer.rb +0 -0
- data/test/stub/vendor_rails/minimal/actionpack/lib/action_controller.rb +22 -0
- data/test/stub/vendor_rails/minimal/actionpack/lib/action_pack.rb +0 -0
- data/test/stub/vendor_rails/minimal/actionpack/lib/action_view.rb +0 -0
- data/test/stub/vendor_rails/minimal/activerecord/lib/active_record.rb +7 -0
- data/test/stub/vendor_rails/minimal/activeresource/lib/active_resource.rb +0 -0
- data/test/stub/vendor_rails/minimal/activesupport/lib/active_support.rb +17 -0
- data/test/stub/vendor_rails/minimal/activesupport/lib/active_support/whiny_nil.rb +0 -0
- data/test/stub/vendor_rails/minimal/railties/lib/dispatcher.rb +0 -0
- data/test/stub/vendor_rails/minimal/railties/lib/initializer.rb +57 -0
- data/test/stub/vendor_rails/minimal/railties/lib/ruby_version_check.rb +1 -0
- data/test/stub/wsgi/passenger_wsgi.py +3 -0
- data/test/stub/wsgi/public/wsgi-snake.jpg +0 -0
- data/test/stub/zsfa/header.png +0 -0
- data/test/stub/zsfa/index.html +14 -0
- data/test/stub/zsfa/zsfa.png +0 -0
- data/test/support/allocate_memory.c +14 -0
- data/test/support/apache2_controller.rb +258 -0
- data/test/support/multipart.rb +62 -0
- data/test/support/nginx_controller.rb +99 -0
- data/test/support/test_helper.rb +448 -0
- data/test/support/valgrind.h +2539 -0
- data/test/tut/tut.h +1240 -0
- data/test/tut/tut_reporter.h +256 -0
- metadata +1703 -0
@@ -0,0 +1,1468 @@
|
|
1
|
+
// Copyright (c) 2005, Google Inc.
|
2
|
+
// All rights reserved.
|
3
|
+
//
|
4
|
+
// Redistribution and use in source and binary forms, with or without
|
5
|
+
// modification, are permitted provided that the following conditions are
|
6
|
+
// met:
|
7
|
+
//
|
8
|
+
// * Redistributions of source code must retain the above copyright
|
9
|
+
// notice, this list of conditions and the following disclaimer.
|
10
|
+
// * Redistributions in binary form must reproduce the above
|
11
|
+
// copyright notice, this list of conditions and the following disclaimer
|
12
|
+
// in the documentation and/or other materials provided with the
|
13
|
+
// distribution.
|
14
|
+
// * Neither the name of Google Inc. nor the names of its
|
15
|
+
// contributors may be used to endorse or promote products derived from
|
16
|
+
// this software without specific prior written permission.
|
17
|
+
//
|
18
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
20
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
21
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
22
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
26
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
|
30
|
+
// ---
|
31
|
+
// Author: Craig Silverstein
|
32
|
+
//
|
33
|
+
// A sparsetable is a random container that implements a sparse array,
|
34
|
+
// that is, an array that uses very little memory to store unassigned
|
35
|
+
// indices (in this case, between 1-2 bits per unassigned index). For
|
36
|
+
// instance, if you allocate an array of size 5 and assign a[2] = <big
|
37
|
+
// struct>, then a[2] will take up a lot of memory but a[0], a[1],
|
38
|
+
// a[3], and a[4] will not. Array elements that have a value are
|
39
|
+
// called "assigned". Array elements that have no value yet, or have
|
40
|
+
// had their value cleared using erase() or clear(), are called
|
41
|
+
// "unassigned".
|
42
|
+
//
|
43
|
+
// Unassigned values seem to have the default value of T (see below).
|
44
|
+
// Nevertheless, there is a difference between an unassigned index and
|
45
|
+
// one explicitly assigned the value of T(). The latter is considered
|
46
|
+
// assigned.
|
47
|
+
//
|
48
|
+
// Access to an array element is constant time, as is insertion and
|
49
|
+
// deletion. Insertion and deletion may be fairly slow, however:
|
50
|
+
// because of this container's memory economy, each insert and delete
|
51
|
+
// causes a memory reallocation.
|
52
|
+
//
|
53
|
+
// See /usr/(local/)?doc/sparsehash-0.1/sparsetable.html
|
54
|
+
// for information about how to use this class.
|
55
|
+
|
56
|
+
#ifndef _SPARSETABLE_H_
|
57
|
+
#define _SPARSETABLE_H_
|
58
|
+
|
59
|
+
#include <google/sparsehash/sparseconfig.h>
|
60
|
+
#include <stdlib.h> // for malloc/free
|
61
|
+
#include <stdio.h> // to read/write tables
|
62
|
+
#ifdef HAVE_STDINT_H
|
63
|
+
#include <stdint.h> // the normal place uint16_t is defined
|
64
|
+
#endif
|
65
|
+
#ifdef HAVE_SYS_TYPES_H
|
66
|
+
#include <sys/types.h> // the normal place u_int16_t is defined
|
67
|
+
#endif
|
68
|
+
#ifdef HAVE_INTTYPES_H
|
69
|
+
#include <inttypes.h> // a third place for uint16_t or u_int16_t
|
70
|
+
#endif
|
71
|
+
#include <assert.h> // for bounds checking
|
72
|
+
#include <iterator> // to define reverse_iterator for me
|
73
|
+
#include <algorithm> // equal, lexicographical_compare, swap,...
|
74
|
+
#include <memory> // uninitialized_copy
|
75
|
+
#include <vector> // a sparsetable is a vector of groups
|
76
|
+
#include <google/type_traits.h> // for true_type, integral_constant, etc.
|
77
|
+
|
78
|
+
#if STDC_HEADERS
|
79
|
+
#include <string.h> // for memcpy
|
80
|
+
#else
|
81
|
+
#if !HAVE_MEMCPY
|
82
|
+
#define memcpy(d, s, n) bcopy ((s), (d), (n))
|
83
|
+
#endif
|
84
|
+
#endif
|
85
|
+
|
86
|
+
_START_GOOGLE_NAMESPACE_
|
87
|
+
|
88
|
+
#ifndef HAVE_U_INT16_T
|
89
|
+
# if defined HAVE_UINT16_T
|
90
|
+
typedef uint16_t u_int16_t; // true on solaris, possibly other C99 libc's
|
91
|
+
# elif defined HAVE___UINT16
|
92
|
+
typedef __int16 int16_t; // true on vc++7
|
93
|
+
typedef unsigned __int16 u_int16_t;
|
94
|
+
# else
|
95
|
+
// Cannot find a 16-bit integer type. Hoping for the best with "short"...
|
96
|
+
typedef short int int16_t;
|
97
|
+
typedef unsigned short int u_int16_t;
|
98
|
+
# endif
|
99
|
+
#endif
|
100
|
+
|
101
|
+
using STL_NAMESPACE::vector;
|
102
|
+
using STL_NAMESPACE::uninitialized_copy;
|
103
|
+
|
104
|
+
// The smaller this is, the faster lookup is (because the group bitmap is
|
105
|
+
// smaller) and the faster insert is, because there's less to move.
|
106
|
+
// On the other hand, there are more groups. Since group::size_type is
|
107
|
+
// a short, this number should be of the form 32*x + 16 to avoid waste.
|
108
|
+
static const u_int16_t DEFAULT_SPARSEGROUP_SIZE = 48; // fits in 1.5 words
|
109
|
+
|
110
|
+
|
111
|
+
// A NOTE ON ASSIGNING:
|
112
|
+
// A sparse table does not actually allocate memory for entries
|
113
|
+
// that are not filled. Because of this, it becomes complicated
|
114
|
+
// to have a non-const iterator: we don't know, if the iterator points
|
115
|
+
// to a not-filled bucket, whether you plan to fill it with something
|
116
|
+
// or whether you plan to read its value (in which case you'll get
|
117
|
+
// the default bucket value). Therefore, while we can define const
|
118
|
+
// operations in a pretty 'normal' way, for non-const operations, we
|
119
|
+
// define something that returns a helper object with operator= and
|
120
|
+
// operator& that allocate a bucket lazily. We use this for table[]
|
121
|
+
// and also for regular table iterators.
|
122
|
+
|
123
|
+
template <class tabletype>
|
124
|
+
class table_element_adaptor {
|
125
|
+
public:
|
126
|
+
typedef typename tabletype::value_type value_type;
|
127
|
+
typedef typename tabletype::size_type size_type;
|
128
|
+
typedef typename tabletype::reference reference;
|
129
|
+
typedef typename tabletype::pointer pointer;
|
130
|
+
|
131
|
+
table_element_adaptor(tabletype *tbl, size_type p)
|
132
|
+
: table(tbl), pos(p) { }
|
133
|
+
table_element_adaptor& operator= (const value_type &val) {
|
134
|
+
table->set(pos, val);
|
135
|
+
return *this;
|
136
|
+
}
|
137
|
+
operator value_type() { return table->get(pos); } // we look like a value
|
138
|
+
pointer operator& () { return &table->mutating_get(pos); }
|
139
|
+
|
140
|
+
private:
|
141
|
+
tabletype* table;
|
142
|
+
size_type pos;
|
143
|
+
};
|
144
|
+
|
145
|
+
// Our iterator as simple as iterators can be: basically it's just
|
146
|
+
// the index into our table. Dereference, the only complicated
|
147
|
+
// thing, we punt to the table class. This just goes to show how
|
148
|
+
// much machinery STL requires to do even the most trivial tasks.
|
149
|
+
//
|
150
|
+
// By templatizing over tabletype, we have one iterator type which
|
151
|
+
// we can use for both sparsetables and sparsebins. In fact it
|
152
|
+
// works on any class that allows size() and operator[] (eg vector),
|
153
|
+
// as long as it does the standard STL typedefs too (eg value_type).
|
154
|
+
|
155
|
+
template <class tabletype>
|
156
|
+
class table_iterator {
|
157
|
+
public:
|
158
|
+
typedef table_iterator iterator;
|
159
|
+
|
160
|
+
typedef STL_NAMESPACE::random_access_iterator_tag iterator_category;
|
161
|
+
typedef typename tabletype::value_type value_type;
|
162
|
+
typedef typename tabletype::difference_type difference_type;
|
163
|
+
typedef typename tabletype::size_type size_type;
|
164
|
+
typedef table_element_adaptor<tabletype> reference;
|
165
|
+
typedef table_element_adaptor<tabletype>* pointer;
|
166
|
+
|
167
|
+
// The "real" constructor
|
168
|
+
table_iterator(tabletype *tbl, size_type p)
|
169
|
+
: table(tbl), pos(p) { }
|
170
|
+
// The default constructor, used when I define vars of type table::iterator
|
171
|
+
table_iterator() : table(NULL), pos(0) { }
|
172
|
+
// The copy constructor, for when I say table::iterator foo = tbl.begin()
|
173
|
+
// The default destructor is fine; we don't define one
|
174
|
+
// The default operator= is fine; we don't define one
|
175
|
+
|
176
|
+
// The main thing our iterator does is dereference. If the table entry
|
177
|
+
// we point to is empty, we return the default value type.
|
178
|
+
// This is the big different function from the const iterator.
|
179
|
+
reference operator*() {
|
180
|
+
return table_element_adaptor<tabletype>(table, pos);
|
181
|
+
}
|
182
|
+
pointer operator->() { return &(operator*()); }
|
183
|
+
|
184
|
+
// Helper function to assert things are ok; eg pos is still in range
|
185
|
+
void check() const {
|
186
|
+
assert(table);
|
187
|
+
assert(pos <= table->size());
|
188
|
+
}
|
189
|
+
|
190
|
+
// Arithmetic: we just do arithmetic on pos. We don't even need to
|
191
|
+
// do bounds checking, since STL doesn't consider that it's job. :-)
|
192
|
+
iterator& operator+=(size_type t) { pos += t; check(); return *this; }
|
193
|
+
iterator& operator-=(size_type t) { pos -= t; check(); return *this; }
|
194
|
+
iterator& operator++() { ++pos; check(); return *this; }
|
195
|
+
iterator& operator--() { --pos; check(); return *this; }
|
196
|
+
iterator operator++(int) { iterator tmp(*this); // for x++
|
197
|
+
++pos; check(); return tmp; }
|
198
|
+
iterator operator--(int) { iterator tmp(*this); // for x--
|
199
|
+
--pos; check(); return tmp; }
|
200
|
+
iterator operator+(difference_type i) const { iterator tmp(*this);
|
201
|
+
tmp += i; return tmp; }
|
202
|
+
iterator operator-(difference_type i) const { iterator tmp(*this);
|
203
|
+
tmp -= i; return tmp; }
|
204
|
+
difference_type operator-(iterator it) const { // for "x = it2 - it"
|
205
|
+
assert(table == it.table);
|
206
|
+
return pos - it.pos;
|
207
|
+
}
|
208
|
+
reference operator[](difference_type n) const {
|
209
|
+
return *(*this + n); // simple though not totally efficient
|
210
|
+
}
|
211
|
+
|
212
|
+
// Comparisons.
|
213
|
+
bool operator==(const iterator& it) const {
|
214
|
+
return table == it.table && pos == it.pos;
|
215
|
+
}
|
216
|
+
bool operator<(const iterator& it) const {
|
217
|
+
assert(table == it.table); // life is bad bad bad otherwise
|
218
|
+
return pos < it.pos;
|
219
|
+
}
|
220
|
+
bool operator!=(const iterator& it) const { return !(*this == it); }
|
221
|
+
bool operator<=(const iterator& it) const { return !(it < *this); }
|
222
|
+
bool operator>(const iterator& it) const { return it < *this; }
|
223
|
+
bool operator>=(const iterator& it) const { return !(*this < it); }
|
224
|
+
|
225
|
+
// Here's the info we actually need to be an iterator
|
226
|
+
tabletype *table; // so we can dereference and bounds-check
|
227
|
+
size_type pos; // index into the table
|
228
|
+
};
|
229
|
+
|
230
|
+
// support for "3 + iterator" has to be defined outside the class, alas
|
231
|
+
template<class T>
|
232
|
+
table_iterator<T> operator+(typename table_iterator<T>::difference_type i,
|
233
|
+
table_iterator<T> it) {
|
234
|
+
return it + i; // so people can say it2 = 3 + it
|
235
|
+
}
|
236
|
+
|
237
|
+
template <class tabletype>
|
238
|
+
class const_table_iterator {
|
239
|
+
public:
|
240
|
+
typedef table_iterator<tabletype> iterator;
|
241
|
+
typedef const_table_iterator const_iterator;
|
242
|
+
|
243
|
+
typedef STL_NAMESPACE::random_access_iterator_tag iterator_category;
|
244
|
+
typedef typename tabletype::value_type value_type;
|
245
|
+
typedef typename tabletype::difference_type difference_type;
|
246
|
+
typedef typename tabletype::size_type size_type;
|
247
|
+
typedef typename tabletype::const_reference reference; // we're const-only
|
248
|
+
typedef typename tabletype::const_pointer pointer;
|
249
|
+
|
250
|
+
// The "real" constructor
|
251
|
+
const_table_iterator(const tabletype *tbl, size_type p)
|
252
|
+
: table(tbl), pos(p) { }
|
253
|
+
// The default constructor, used when I define vars of type table::iterator
|
254
|
+
const_table_iterator() : table(NULL), pos(0) { }
|
255
|
+
// The copy constructor, for when I say table::iterator foo = tbl.begin()
|
256
|
+
// Also converts normal iterators to const iterators
|
257
|
+
const_table_iterator(const iterator &from)
|
258
|
+
: table(from.table), pos(from.pos) { }
|
259
|
+
// The default destructor is fine; we don't define one
|
260
|
+
// The default operator= is fine; we don't define one
|
261
|
+
|
262
|
+
// The main thing our iterator does is dereference. If the table entry
|
263
|
+
// we point to is empty, we return the default value type.
|
264
|
+
reference operator*() const { return (*table)[pos]; }
|
265
|
+
pointer operator->() const { return &(operator*()); }
|
266
|
+
|
267
|
+
// Helper function to assert things are ok; eg pos is still in range
|
268
|
+
void check() const {
|
269
|
+
assert(table);
|
270
|
+
assert(pos <= table->size());
|
271
|
+
}
|
272
|
+
|
273
|
+
// Arithmetic: we just do arithmetic on pos. We don't even need to
|
274
|
+
// do bounds checking, since STL doesn't consider that it's job. :-)
|
275
|
+
const_iterator& operator+=(size_type t) { pos += t; check(); return *this; }
|
276
|
+
const_iterator& operator-=(size_type t) { pos -= t; check(); return *this; }
|
277
|
+
const_iterator& operator++() { ++pos; check(); return *this; }
|
278
|
+
const_iterator& operator--() { --pos; check(); return *this; }
|
279
|
+
const_iterator operator++(int) { const_iterator tmp(*this); // for x++
|
280
|
+
++pos; check(); return tmp; }
|
281
|
+
const_iterator operator--(int) { const_iterator tmp(*this); // for x--
|
282
|
+
--pos; check(); return tmp; }
|
283
|
+
const_iterator operator+(difference_type i) const { const_iterator tmp(*this);
|
284
|
+
tmp += i; return tmp; }
|
285
|
+
const_iterator operator-(difference_type i) const { const_iterator tmp(*this);
|
286
|
+
tmp -= i; return tmp; }
|
287
|
+
difference_type operator-(const_iterator it) const { // for "x = it2 - it"
|
288
|
+
assert(table == it.table);
|
289
|
+
return pos - it.pos;
|
290
|
+
}
|
291
|
+
reference operator[](difference_type n) const {
|
292
|
+
return *(*this + n); // simple though not totally efficient
|
293
|
+
}
|
294
|
+
|
295
|
+
// Comparisons.
|
296
|
+
bool operator==(const const_iterator& it) const {
|
297
|
+
return table == it.table && pos == it.pos;
|
298
|
+
}
|
299
|
+
bool operator<(const const_iterator& it) const {
|
300
|
+
assert(table == it.table); // life is bad bad bad otherwise
|
301
|
+
return pos < it.pos;
|
302
|
+
}
|
303
|
+
bool operator!=(const const_iterator& it) const { return !(*this == it); }
|
304
|
+
bool operator<=(const const_iterator& it) const { return !(it < *this); }
|
305
|
+
bool operator>(const const_iterator& it) const { return it < *this; }
|
306
|
+
bool operator>=(const const_iterator& it) const { return !(*this < it); }
|
307
|
+
|
308
|
+
// Here's the info we actually need to be an iterator
|
309
|
+
const tabletype *table; // so we can dereference and bounds-check
|
310
|
+
size_type pos; // index into the table
|
311
|
+
};
|
312
|
+
|
313
|
+
// support for "3 + iterator" has to be defined outside the class, alas
|
314
|
+
template<class T>
|
315
|
+
const_table_iterator<T> operator+(typename
|
316
|
+
const_table_iterator<T>::difference_type i,
|
317
|
+
const_table_iterator<T> it) {
|
318
|
+
return it + i; // so people can say it2 = 3 + it
|
319
|
+
}
|
320
|
+
|
321
|
+
|
322
|
+
// ---------------------------------------------------------------------------
|
323
|
+
|
324
|
+
|
325
|
+
/*
|
326
|
+
// This is a 2-D iterator. You specify a begin and end over a list
|
327
|
+
// of *containers*. We iterate over each container by iterating over
|
328
|
+
// it. It's actually simple:
|
329
|
+
// VECTOR.begin() VECTOR[0].begin() --------> VECTOR[0].end() ---,
|
330
|
+
// | ________________________________________________/
|
331
|
+
// | \_> VECTOR[1].begin() --------> VECTOR[1].end() -,
|
332
|
+
// | ___________________________________________________/
|
333
|
+
// v \_> ......
|
334
|
+
// VECTOR.end()
|
335
|
+
//
|
336
|
+
// It's impossible to do random access on one of these things in constant
|
337
|
+
// time, so it's just a bidirectional iterator.
|
338
|
+
//
|
339
|
+
// Unfortunately, because we need to use this for a non-empty iterator,
|
340
|
+
// we use nonempty_begin() and nonempty_end() instead of begin() and end()
|
341
|
+
// (though only going across, not down).
|
342
|
+
*/
|
343
|
+
|
344
|
+
#define TWOD_BEGIN_ nonempty_begin
|
345
|
+
#define TWOD_END_ nonempty_end
|
346
|
+
#define TWOD_ITER_ nonempty_iterator
|
347
|
+
#define TWOD_CONST_ITER_ const_nonempty_iterator
|
348
|
+
|
349
|
+
template <class containertype>
|
350
|
+
class two_d_iterator {
|
351
|
+
public:
|
352
|
+
typedef two_d_iterator iterator;
|
353
|
+
|
354
|
+
typedef STL_NAMESPACE::bidirectional_iterator_tag iterator_category;
|
355
|
+
// apparently some versions of VC++ have trouble with two ::'s in a typename
|
356
|
+
typedef typename containertype::value_type _tmp_vt;
|
357
|
+
typedef typename _tmp_vt::value_type value_type;
|
358
|
+
typedef typename _tmp_vt::difference_type difference_type;
|
359
|
+
typedef typename _tmp_vt::reference reference;
|
360
|
+
typedef typename _tmp_vt::pointer pointer;
|
361
|
+
|
362
|
+
// The "real" constructor. begin and end specify how many rows we have
|
363
|
+
// (in the diagram above); we always iterate over each row completely.
|
364
|
+
two_d_iterator(typename containertype::iterator begin,
|
365
|
+
typename containertype::iterator end,
|
366
|
+
typename containertype::iterator curr)
|
367
|
+
: row_begin(begin), row_end(end), row_current(curr), col_current() {
|
368
|
+
if ( row_current != row_end ) {
|
369
|
+
col_current = row_current->TWOD_BEGIN_();
|
370
|
+
advance_past_end(); // in case cur->begin() == cur->end()
|
371
|
+
}
|
372
|
+
}
|
373
|
+
// If you want to start at an arbitrary place, you can, I guess
|
374
|
+
two_d_iterator(typename containertype::iterator begin,
|
375
|
+
typename containertype::iterator end,
|
376
|
+
typename containertype::iterator curr,
|
377
|
+
typename containertype::value_type::TWOD_ITER_ col)
|
378
|
+
: row_begin(begin), row_end(end), row_current(curr), col_current(col) {
|
379
|
+
advance_past_end(); // in case cur->begin() == cur->end()
|
380
|
+
}
|
381
|
+
// The default constructor, used when I define vars of type table::iterator
|
382
|
+
two_d_iterator() : row_begin(), row_end(), row_current(), col_current() { }
|
383
|
+
// The default destructor is fine; we don't define one
|
384
|
+
// The default operator= is fine; we don't define one
|
385
|
+
|
386
|
+
// Happy dereferencer
|
387
|
+
reference operator*() const { return *col_current; }
|
388
|
+
pointer operator->() const { return &(operator*()); }
|
389
|
+
|
390
|
+
// Arithmetic: we just do arithmetic on pos. We don't even need to
|
391
|
+
// do bounds checking, since STL doesn't consider that it's job. :-)
|
392
|
+
// NOTE: this is not amortized constant time! What do we do about it?
|
393
|
+
void advance_past_end() { // used when col_current points to end()
|
394
|
+
while ( col_current == row_current->TWOD_END_() ) { // end of current row
|
395
|
+
++row_current; // go to beginning of next
|
396
|
+
if ( row_current != row_end ) // col is irrelevant at end
|
397
|
+
col_current = row_current->TWOD_BEGIN_();
|
398
|
+
else
|
399
|
+
break; // don't go past row_end
|
400
|
+
}
|
401
|
+
}
|
402
|
+
|
403
|
+
iterator& operator++() {
|
404
|
+
assert(row_current != row_end); // how to ++ from there?
|
405
|
+
++col_current;
|
406
|
+
advance_past_end(); // in case col_current is at end()
|
407
|
+
return *this;
|
408
|
+
}
|
409
|
+
iterator& operator--() {
|
410
|
+
while ( row_current == row_end ||
|
411
|
+
col_current == row_current->TWOD_BEGIN_() ) {
|
412
|
+
assert(row_current != row_begin);
|
413
|
+
--row_current;
|
414
|
+
col_current = row_current->TWOD_END_(); // this is 1 too far
|
415
|
+
}
|
416
|
+
--col_current;
|
417
|
+
return *this;
|
418
|
+
}
|
419
|
+
iterator operator++(int) { iterator tmp(*this); ++*this; return tmp; }
|
420
|
+
iterator operator--(int) { iterator tmp(*this); --*this; return tmp; }
|
421
|
+
|
422
|
+
|
423
|
+
// Comparisons.
|
424
|
+
bool operator==(const iterator& it) const {
|
425
|
+
return ( row_begin == it.row_begin &&
|
426
|
+
row_end == it.row_end &&
|
427
|
+
row_current == it.row_current &&
|
428
|
+
(row_current == row_end || col_current == it.col_current) );
|
429
|
+
}
|
430
|
+
bool operator!=(const iterator& it) const { return !(*this == it); }
|
431
|
+
|
432
|
+
|
433
|
+
// Here's the info we actually need to be an iterator
|
434
|
+
// These need to be public so we convert from iterator to const_iterator
|
435
|
+
typename containertype::iterator row_begin, row_end, row_current;
|
436
|
+
typename containertype::value_type::TWOD_ITER_ col_current;
|
437
|
+
};
|
438
|
+
|
439
|
+
// The same thing again, but this time const. :-(
|
440
|
+
template <class containertype>
|
441
|
+
class const_two_d_iterator {
|
442
|
+
public:
|
443
|
+
typedef const_two_d_iterator iterator;
|
444
|
+
|
445
|
+
typedef STL_NAMESPACE::bidirectional_iterator_tag iterator_category;
|
446
|
+
// apparently some versions of VC++ have trouble with two ::'s in a typename
|
447
|
+
typedef typename containertype::value_type _tmp_vt;
|
448
|
+
typedef typename _tmp_vt::value_type value_type;
|
449
|
+
typedef typename _tmp_vt::difference_type difference_type;
|
450
|
+
typedef typename _tmp_vt::const_reference reference;
|
451
|
+
typedef typename _tmp_vt::const_pointer pointer;
|
452
|
+
|
453
|
+
const_two_d_iterator(typename containertype::const_iterator begin,
|
454
|
+
typename containertype::const_iterator end,
|
455
|
+
typename containertype::const_iterator curr)
|
456
|
+
: row_begin(begin), row_end(end), row_current(curr), col_current() {
|
457
|
+
if ( curr != end ) {
|
458
|
+
col_current = curr->TWOD_BEGIN_();
|
459
|
+
advance_past_end(); // in case cur->begin() == cur->end()
|
460
|
+
}
|
461
|
+
}
|
462
|
+
const_two_d_iterator(typename containertype::const_iterator begin,
|
463
|
+
typename containertype::const_iterator end,
|
464
|
+
typename containertype::const_iterator curr,
|
465
|
+
typename containertype::value_type::TWOD_CONST_ITER_ col)
|
466
|
+
: row_begin(begin), row_end(end), row_current(curr), col_current(col) {
|
467
|
+
advance_past_end(); // in case cur->begin() == cur->end()
|
468
|
+
}
|
469
|
+
const_two_d_iterator()
|
470
|
+
: row_begin(), row_end(), row_current(), col_current() {
|
471
|
+
}
|
472
|
+
// Need this explicitly so we can convert normal iterators to const iterators
|
473
|
+
const_two_d_iterator(const two_d_iterator<containertype>& it) :
|
474
|
+
row_begin(it.row_begin), row_end(it.row_end), row_current(it.row_current),
|
475
|
+
col_current(it.col_current) { }
|
476
|
+
|
477
|
+
typename containertype::const_iterator row_begin, row_end, row_current;
|
478
|
+
typename containertype::value_type::TWOD_CONST_ITER_ col_current;
|
479
|
+
|
480
|
+
|
481
|
+
// EVERYTHING FROM HERE DOWN IS THE SAME AS THE NON-CONST ITERATOR
|
482
|
+
reference operator*() const { return *col_current; }
|
483
|
+
pointer operator->() const { return &(operator*()); }
|
484
|
+
|
485
|
+
void advance_past_end() { // used when col_current points to end()
|
486
|
+
while ( col_current == row_current->TWOD_END_() ) { // end of current row
|
487
|
+
++row_current; // go to beginning of next
|
488
|
+
if ( row_current != row_end ) // col is irrelevant at end
|
489
|
+
col_current = row_current->TWOD_BEGIN_();
|
490
|
+
else
|
491
|
+
break; // don't go past row_end
|
492
|
+
}
|
493
|
+
}
|
494
|
+
iterator& operator++() {
|
495
|
+
assert(row_current != row_end); // how to ++ from there?
|
496
|
+
++col_current;
|
497
|
+
advance_past_end(); // in case col_current is at end()
|
498
|
+
return *this;
|
499
|
+
}
|
500
|
+
iterator& operator--() {
|
501
|
+
while ( row_current == row_end ||
|
502
|
+
col_current == row_current->TWOD_BEGIN_() ) {
|
503
|
+
assert(row_current != row_begin);
|
504
|
+
--row_current;
|
505
|
+
col_current = row_current->TWOD_END_(); // this is 1 too far
|
506
|
+
}
|
507
|
+
--col_current;
|
508
|
+
return *this;
|
509
|
+
}
|
510
|
+
iterator operator++(int) { iterator tmp(*this); ++*this; return tmp; }
|
511
|
+
iterator operator--(int) { iterator tmp(*this); --*this; return tmp; }
|
512
|
+
|
513
|
+
bool operator==(const iterator& it) const {
|
514
|
+
return ( row_begin == it.row_begin &&
|
515
|
+
row_end == it.row_end &&
|
516
|
+
row_current == it.row_current &&
|
517
|
+
(row_current == row_end || col_current == it.col_current) );
|
518
|
+
}
|
519
|
+
bool operator!=(const iterator& it) const { return !(*this == it); }
|
520
|
+
};
|
521
|
+
|
522
|
+
// We provide yet another version, to be as frugal with memory as
|
523
|
+
// possible. This one frees each block of memory as it finishes
|
524
|
+
// iterating over it. By the end, the entire table is freed.
|
525
|
+
// For understandable reasons, you can only iterate over it once,
|
526
|
+
// which is why it's an input iterator
|
527
|
+
template <class containertype>
|
528
|
+
class destructive_two_d_iterator {
|
529
|
+
public:
|
530
|
+
typedef destructive_two_d_iterator iterator;
|
531
|
+
|
532
|
+
typedef STL_NAMESPACE::input_iterator_tag iterator_category;
|
533
|
+
// apparently some versions of VC++ have trouble with two ::'s in a typename
|
534
|
+
typedef typename containertype::value_type _tmp_vt;
|
535
|
+
typedef typename _tmp_vt::value_type value_type;
|
536
|
+
typedef typename _tmp_vt::difference_type difference_type;
|
537
|
+
typedef typename _tmp_vt::reference reference;
|
538
|
+
typedef typename _tmp_vt::pointer pointer;
|
539
|
+
|
540
|
+
destructive_two_d_iterator(typename containertype::iterator begin,
|
541
|
+
typename containertype::iterator end,
|
542
|
+
typename containertype::iterator curr)
|
543
|
+
: row_begin(begin), row_end(end), row_current(curr), col_current() {
|
544
|
+
if ( curr != end ) {
|
545
|
+
col_current = curr->TWOD_BEGIN_();
|
546
|
+
advance_past_end(); // in case cur->begin() == cur->end()
|
547
|
+
}
|
548
|
+
}
|
549
|
+
destructive_two_d_iterator(typename containertype::iterator begin,
|
550
|
+
typename containertype::iterator end,
|
551
|
+
typename containertype::iterator curr,
|
552
|
+
typename containertype::value_type::TWOD_ITER_ col)
|
553
|
+
: row_begin(begin), row_end(end), row_current(curr), col_current(col) {
|
554
|
+
advance_past_end(); // in case cur->begin() == cur->end()
|
555
|
+
}
|
556
|
+
destructive_two_d_iterator()
|
557
|
+
: row_begin(), row_end(), row_current(), col_current() {
|
558
|
+
}
|
559
|
+
|
560
|
+
typename containertype::iterator row_begin, row_end, row_current;
|
561
|
+
typename containertype::value_type::TWOD_ITER_ col_current;
|
562
|
+
|
563
|
+
// This is the part that destroys
|
564
|
+
void advance_past_end() { // used when col_current points to end()
|
565
|
+
while ( col_current == row_current->TWOD_END_() ) { // end of current row
|
566
|
+
row_current->clear(); // the destructive part
|
567
|
+
// It would be nice if we could decrement sparsetable->num_buckets here
|
568
|
+
++row_current; // go to beginning of next
|
569
|
+
if ( row_current != row_end ) // col is irrelevant at end
|
570
|
+
col_current = row_current->TWOD_BEGIN_();
|
571
|
+
else
|
572
|
+
break; // don't go past row_end
|
573
|
+
}
|
574
|
+
}
|
575
|
+
|
576
|
+
// EVERYTHING FROM HERE DOWN IS THE SAME AS THE REGULAR ITERATOR
|
577
|
+
reference operator*() const { return *col_current; }
|
578
|
+
pointer operator->() const { return &(operator*()); }
|
579
|
+
|
580
|
+
iterator& operator++() {
|
581
|
+
assert(row_current != row_end); // how to ++ from there?
|
582
|
+
++col_current;
|
583
|
+
advance_past_end(); // in case col_current is at end()
|
584
|
+
return *this;
|
585
|
+
}
|
586
|
+
iterator operator++(int) { iterator tmp(*this); ++*this; return tmp; }
|
587
|
+
|
588
|
+
bool operator==(const iterator& it) const {
|
589
|
+
return ( row_begin == it.row_begin &&
|
590
|
+
row_end == it.row_end &&
|
591
|
+
row_current == it.row_current &&
|
592
|
+
(row_current == row_end || col_current == it.col_current) );
|
593
|
+
}
|
594
|
+
bool operator!=(const iterator& it) const { return !(*this == it); }
|
595
|
+
};
|
596
|
+
|
597
|
+
#undef TWOD_BEGIN_
|
598
|
+
#undef TWOD_END_
|
599
|
+
#undef TWOD_ITER_
|
600
|
+
#undef TWOD_CONST_ITER_
|
601
|
+
|
602
|
+
|
603
|
+
|
604
|
+
|
605
|
+
// SPARSE-TABLE
|
606
|
+
// ------------
|
607
|
+
// The idea is that a table with (logically) t buckets is divided
|
608
|
+
// into t/M *groups* of M buckets each. (M is a constant set in
|
609
|
+
// GROUP_SIZE for efficiency.) Each group is stored sparsely.
|
610
|
+
// Thus, inserting into the table causes some array to grow, which is
|
611
|
+
// slow but still constant time. Lookup involves doing a
|
612
|
+
// logical-position-to-sparse-position lookup, which is also slow but
|
613
|
+
// constant time. The larger M is, the slower these operations are
|
614
|
+
// but the less overhead (slightly).
|
615
|
+
//
|
616
|
+
// To store the sparse array, we store a bitmap B, where B[i] = 1 iff
|
617
|
+
// bucket i is non-empty. Then to look up bucket i we really look up
|
618
|
+
// array[# of 1s before i in B]. This is constant time for fixed M.
|
619
|
+
//
|
620
|
+
// Terminology: the position of an item in the overall table (from
|
621
|
+
// 1 .. t) is called its "location." The logical position in a group
|
622
|
+
// (from 1 .. M ) is called its "position." The actual location in
|
623
|
+
// the array (from 1 .. # of non-empty buckets in the group) is
|
624
|
+
// called its "offset."
|
625
|
+
|
626
|
+
// The weird mod in the offset is entirely to quiet compiler warnings
|
627
|
+
// as is the cast to int after doing the "x mod 256"
|
628
|
+
#define PUT_(take_from, offset) do { \
|
629
|
+
if (putc(static_cast<int>(((take_from) >> ((offset) % (sizeof(take_from)*8)))\
|
630
|
+
% 256), fp) \
|
631
|
+
== EOF) \
|
632
|
+
return false; \
|
633
|
+
} while (0)
|
634
|
+
|
635
|
+
#define GET_(add_to, offset) do { \
|
636
|
+
if ((x=getc(fp)) == EOF) \
|
637
|
+
return false; \
|
638
|
+
else \
|
639
|
+
add_to |= (static_cast<size_type>(x) << ((offset) % (sizeof(add_to)*8))); \
|
640
|
+
} while (0)
|
641
|
+
|
642
|
+
template <class T, u_int16_t GROUP_SIZE>
|
643
|
+
class sparsegroup {
|
644
|
+
public:
|
645
|
+
// Basic types
|
646
|
+
typedef T value_type;
|
647
|
+
typedef value_type* pointer;
|
648
|
+
typedef const value_type* const_pointer;
|
649
|
+
typedef table_iterator<sparsegroup<T, GROUP_SIZE> > iterator;
|
650
|
+
typedef const_table_iterator<sparsegroup<T, GROUP_SIZE> > const_iterator;
|
651
|
+
typedef table_element_adaptor<sparsegroup<T, GROUP_SIZE> > element_adaptor;
|
652
|
+
typedef value_type &reference;
|
653
|
+
typedef const value_type &const_reference;
|
654
|
+
typedef u_int16_t size_type; // max # of buckets
|
655
|
+
typedef int16_t difference_type;
|
656
|
+
typedef STL_NAMESPACE::reverse_iterator<const_iterator> const_reverse_iterator;
|
657
|
+
typedef STL_NAMESPACE::reverse_iterator<iterator> reverse_iterator;
|
658
|
+
|
659
|
+
// These are our special iterators, that go over non-empty buckets in a
|
660
|
+
// group. These aren't const-only because you can change non-empty bcks.
|
661
|
+
typedef pointer nonempty_iterator;
|
662
|
+
typedef const_pointer const_nonempty_iterator;
|
663
|
+
typedef STL_NAMESPACE::reverse_iterator<nonempty_iterator> reverse_nonempty_iterator;
|
664
|
+
typedef STL_NAMESPACE::reverse_iterator<const_nonempty_iterator> const_reverse_nonempty_iterator;
|
665
|
+
|
666
|
+
// Iterator functions
|
667
|
+
iterator begin() { return iterator(this, 0); }
|
668
|
+
const_iterator begin() const { return const_iterator(this, 0); }
|
669
|
+
iterator end() { return iterator(this, size()); }
|
670
|
+
const_iterator end() const { return const_iterator(this, size()); }
|
671
|
+
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
672
|
+
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
|
673
|
+
reverse_iterator rend() { return reverse_iterator(begin()); }
|
674
|
+
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
|
675
|
+
|
676
|
+
// We'll have versions for our special non-empty iterator too
|
677
|
+
nonempty_iterator nonempty_begin() { return group; }
|
678
|
+
const_nonempty_iterator nonempty_begin() const { return group; }
|
679
|
+
nonempty_iterator nonempty_end() { return group + num_buckets; }
|
680
|
+
const_nonempty_iterator nonempty_end() const { return group + num_buckets; }
|
681
|
+
reverse_nonempty_iterator nonempty_rbegin() {
|
682
|
+
return reverse_nonempty_iterator(nonempty_end());
|
683
|
+
}
|
684
|
+
const_reverse_nonempty_iterator nonempty_rbegin() const {
|
685
|
+
return const_reverse_nonempty_iterator(nonempty_end());
|
686
|
+
}
|
687
|
+
reverse_nonempty_iterator nonempty_rend() {
|
688
|
+
return reverse_nonempty_iterator(nonempty_begin());
|
689
|
+
}
|
690
|
+
const_reverse_nonempty_iterator nonempty_rend() const {
|
691
|
+
return const_reverse_nonempty_iterator(nonempty_begin());
|
692
|
+
}
|
693
|
+
|
694
|
+
|
695
|
+
// This gives us the "default" value to return for an empty bucket.
|
696
|
+
// We just use the default constructor on T, the template type
|
697
|
+
const_reference default_value() const {
|
698
|
+
static value_type defaultval = value_type();
|
699
|
+
return defaultval;
|
700
|
+
}
|
701
|
+
|
702
|
+
|
703
|
+
private:
|
704
|
+
// We need to do all this bit manipulation, of course. ick
|
705
|
+
static size_type charbit(size_type i) { return i >> 3; }
|
706
|
+
static size_type modbit(size_type i) { return 1 << (i&7); }
|
707
|
+
int bmtest(size_type i) const { return bitmap[charbit(i)] & modbit(i); }
|
708
|
+
void bmset(size_type i) { bitmap[charbit(i)] |= modbit(i); }
|
709
|
+
void bmclear(size_type i) { bitmap[charbit(i)] &= ~modbit(i); }
|
710
|
+
|
711
|
+
void* realloc_or_die(void* ptr, size_t num_bytes) {
|
712
|
+
void* retval = realloc(ptr, num_bytes);
|
713
|
+
if (retval == NULL) {
|
714
|
+
// We really should use PRIuS here, but I don't want to have to add
|
715
|
+
// a whole new configure option, with concomitant macro namespace
|
716
|
+
// pollution, just to print this (unlikely) error message. So I cast.
|
717
|
+
fprintf(stderr, "FATAL ERROR: failed to allocate %lu bytes for ptr %p",
|
718
|
+
static_cast<unsigned long>(num_bytes), ptr);
|
719
|
+
exit(1);
|
720
|
+
}
|
721
|
+
return retval;
|
722
|
+
}
|
723
|
+
|
724
|
+
value_type* allocate_group(size_t n) {
|
725
|
+
return static_cast<value_type*>(realloc_or_die(NULL,
|
726
|
+
n * sizeof(value_type)));
|
727
|
+
}
|
728
|
+
|
729
|
+
void free_group() {
|
730
|
+
// Valid even for empty group, because NULL+0 is defined to be NULL
|
731
|
+
value_type* end_it = group + num_buckets;
|
732
|
+
for (value_type* p = group; p != end_it; ++p)
|
733
|
+
p->~value_type();
|
734
|
+
free(group);
|
735
|
+
group = NULL;
|
736
|
+
}
|
737
|
+
|
738
|
+
public: // get_iter() in sparsetable needs it
|
739
|
+
// We need a small function that tells us how many set bits there are
|
740
|
+
// in positions 0..i-1 of the bitmap. It uses a big table.
|
741
|
+
// We make it static so templates don't allocate lots of these tables
|
742
|
+
static size_type pos_to_offset(const unsigned char *bm, size_type pos) {
|
743
|
+
// We could make these ints. The tradeoff is size (eg does it overwhelm
|
744
|
+
// the cache?) vs efficiency in referencing sub-word-sized array elements
|
745
|
+
static const char bits_in[256] = { // # of bits set in one char
|
746
|
+
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
|
747
|
+
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
748
|
+
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
749
|
+
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
750
|
+
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
751
|
+
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
752
|
+
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
753
|
+
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
754
|
+
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
755
|
+
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
756
|
+
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
757
|
+
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
758
|
+
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
759
|
+
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
760
|
+
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
761
|
+
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
|
762
|
+
};
|
763
|
+
size_type retval = 0;
|
764
|
+
|
765
|
+
// [Note: condition pos > 8 is an optimization; convince yourself we
|
766
|
+
// give exactly the same result as if we had pos >= 8 here instead.]
|
767
|
+
for ( ; pos > 8; pos -= 8 ) // bm[0..pos/8-1]
|
768
|
+
retval += bits_in[*bm++]; // chars we want *all* bits in
|
769
|
+
return retval + bits_in[*bm & ((1 << pos)-1)]; // the char that includes pos
|
770
|
+
}
|
771
|
+
|
772
|
+
size_type pos_to_offset(size_type pos) const { // not static but still const
|
773
|
+
return pos_to_offset(bitmap, pos);
|
774
|
+
}
|
775
|
+
|
776
|
+
|
777
|
+
public:
|
778
|
+
// Constructors -- default and copy -- and destructor
|
779
|
+
sparsegroup() : group(0), num_buckets(0) { memset(bitmap, 0, sizeof(bitmap)); }
|
780
|
+
sparsegroup(const sparsegroup& x) : group(0), num_buckets(x.num_buckets) {
|
781
|
+
if ( num_buckets ) {
|
782
|
+
group = allocate_group(x.num_buckets);
|
783
|
+
uninitialized_copy(x.group, x.group + x.num_buckets, group);
|
784
|
+
}
|
785
|
+
memcpy(bitmap, x.bitmap, sizeof(bitmap));
|
786
|
+
}
|
787
|
+
~sparsegroup() { free_group(); }
|
788
|
+
|
789
|
+
// Operator= is just like the copy constructor, I guess
|
790
|
+
// TODO(austern): Make this exception safe. Handle exceptions in value_type's
|
791
|
+
// copy constructor.
|
792
|
+
sparsegroup &operator=(const sparsegroup& x) {
|
793
|
+
if ( &x == this ) return *this; // x = x
|
794
|
+
if ( x.num_buckets == 0 ) {
|
795
|
+
free_group();
|
796
|
+
} else {
|
797
|
+
value_type* p = allocate_group(x.num_buckets);
|
798
|
+
uninitialized_copy(x.group, x.group + x.num_buckets, p);
|
799
|
+
free_group();
|
800
|
+
group = p;
|
801
|
+
}
|
802
|
+
memcpy(bitmap, x.bitmap, sizeof(bitmap));
|
803
|
+
num_buckets = x.num_buckets;
|
804
|
+
return *this;
|
805
|
+
}
|
806
|
+
|
807
|
+
// Many STL algorithms use swap instead of copy constructors
|
808
|
+
void swap(sparsegroup& x) {
|
809
|
+
STL_NAMESPACE::swap(group, x.group);
|
810
|
+
for ( int i = 0; i < sizeof(bitmap) / sizeof(*bitmap); ++i )
|
811
|
+
STL_NAMESPACE::swap(bitmap[i], x.bitmap[i]); // swap not defined on arrays
|
812
|
+
STL_NAMESPACE::swap(num_buckets, x.num_buckets);
|
813
|
+
}
|
814
|
+
|
815
|
+
// It's always nice to be able to clear a table without deallocating it
|
816
|
+
void clear() {
|
817
|
+
free_group();
|
818
|
+
memset(bitmap, 0, sizeof(bitmap));
|
819
|
+
num_buckets = 0;
|
820
|
+
}
|
821
|
+
|
822
|
+
// Functions that tell you about size. Alas, these aren't so useful
|
823
|
+
// because our table is always fixed size.
|
824
|
+
size_type size() const { return GROUP_SIZE; }
|
825
|
+
size_type max_size() const { return GROUP_SIZE; }
|
826
|
+
bool empty() const { return false; }
|
827
|
+
// We also may want to know how many *used* buckets there are
|
828
|
+
size_type num_nonempty() const { return num_buckets; }
|
829
|
+
|
830
|
+
|
831
|
+
// get()/set() are explicitly const/non-const. You can use [] if
|
832
|
+
// you want something that can be either (potentially more expensive).
|
833
|
+
const_reference get(size_type i) const {
|
834
|
+
if ( bmtest(i) ) // bucket i is occupied
|
835
|
+
return group[pos_to_offset(bitmap, i)];
|
836
|
+
else
|
837
|
+
return default_value(); // return the default reference
|
838
|
+
}
|
839
|
+
|
840
|
+
// TODO(csilvers): make protected + friend
|
841
|
+
// This is used by sparse_hashtable to get an element from the table
|
842
|
+
// when we know it exists.
|
843
|
+
const_reference unsafe_get(size_type i) const {
|
844
|
+
assert(bmtest(i));
|
845
|
+
return group[pos_to_offset(bitmap, i)];
|
846
|
+
}
|
847
|
+
|
848
|
+
// TODO(csilvers): make protected + friend
|
849
|
+
reference mutating_get(size_type i) { // fills bucket i before getting
|
850
|
+
if ( !bmtest(i) )
|
851
|
+
set(i, default_value());
|
852
|
+
return group[pos_to_offset(bitmap, i)];
|
853
|
+
}
|
854
|
+
|
855
|
+
// Syntactic sugar. It's easy to return a const reference. To
|
856
|
+
// return a non-const reference, we need to use the assigner adaptor.
|
857
|
+
const_reference operator[](size_type i) const {
|
858
|
+
return get(i);
|
859
|
+
}
|
860
|
+
|
861
|
+
element_adaptor operator[](size_type i) {
|
862
|
+
return element_adaptor(this, i);
|
863
|
+
}
|
864
|
+
|
865
|
+
private:
|
866
|
+
// Create space at group[offset], assuming value_type has trivial
|
867
|
+
// copy constructor and destructor. (Really, we want it to have
|
868
|
+
// "trivial move", because that's what realloc and memmove both do.
|
869
|
+
// But there's no way to capture that using type_traits, so we
|
870
|
+
// pretend that move(x, y) is equivalent to "x.~T(); new(x) T(y);"
|
871
|
+
// which is pretty much correct, if a bit conservative.)
|
872
|
+
void set_aux(size_type offset, true_type) {
|
873
|
+
group = (value_type *)
|
874
|
+
realloc_or_die(group, sizeof(*group) * (num_buckets+1));
|
875
|
+
// This is equivalent to memmove(), but faster on my Intel P4,
|
876
|
+
// at least with gcc4.1 -O2 / glibc 2.3.6.
|
877
|
+
for (size_type i = num_buckets; i > offset; --i)
|
878
|
+
memcpy(group + i, group + i-1, sizeof(*group));
|
879
|
+
}
|
880
|
+
|
881
|
+
// Create space at group[offset], without special assumptions about value_type
|
882
|
+
void set_aux(size_type offset, false_type) {
|
883
|
+
// This is valid because 0 <= offset <= num_buckets
|
884
|
+
value_type* p = allocate_group(num_buckets + 1);
|
885
|
+
uninitialized_copy(group, group + offset, p);
|
886
|
+
uninitialized_copy(group + offset, group + num_buckets, p + offset + 1);
|
887
|
+
free_group();
|
888
|
+
group = p;
|
889
|
+
}
|
890
|
+
|
891
|
+
public:
|
892
|
+
// This returns a reference to the inserted item (which is a copy of val).
|
893
|
+
// TODO(austern): Make this exception safe: handle exceptions from
|
894
|
+
// value_type's copy constructor.
|
895
|
+
reference set(size_type i, const_reference val) {
|
896
|
+
size_type offset = pos_to_offset(bitmap, i); // where we'll find (or insert)
|
897
|
+
if ( bmtest(i) ) {
|
898
|
+
// Delete the old value, which we're replacing with the new one
|
899
|
+
group[offset].~value_type();
|
900
|
+
} else {
|
901
|
+
typedef integral_constant<bool,
|
902
|
+
(has_trivial_copy<value_type>::value &&
|
903
|
+
has_trivial_destructor<value_type>::value)>
|
904
|
+
realloc_and_memmove_ok; // we pretend mv(x,y) == "x.~T(); new(x) T(y)"
|
905
|
+
set_aux(offset, realloc_and_memmove_ok());
|
906
|
+
++num_buckets;
|
907
|
+
bmset(i);
|
908
|
+
}
|
909
|
+
// This does the actual inserting. Since we made the array using
|
910
|
+
// malloc, we use "placement new" to just call the constructor.
|
911
|
+
new(&group[offset]) value_type(val);
|
912
|
+
return group[offset];
|
913
|
+
}
|
914
|
+
|
915
|
+
// We let you see if a bucket is non-empty without retrieving it
|
916
|
+
bool test(size_type i) const {
|
917
|
+
return bmtest(i) ? true : false; // cast an int to a bool
|
918
|
+
}
|
919
|
+
bool test(iterator pos) const {
|
920
|
+
return bmtest(pos.pos) ? true : false;
|
921
|
+
}
|
922
|
+
|
923
|
+
private:
|
924
|
+
// Shrink the array, assuming value_type has trivial copy
|
925
|
+
// constructor and destructor. (Really, we want it to have "trivial
|
926
|
+
// move", because that's what realloc and memmove both do. But
|
927
|
+
// there's no way to capture that using type_traits, so we pretend
|
928
|
+
// that move(x, y) is equivalent to ""x.~T(); new(x) T(y);"
|
929
|
+
// which is pretty much correct, if a bit conservative.)
|
930
|
+
void erase_aux(size_type offset, true_type) {
|
931
|
+
// This isn't technically necessary, since we know we have a
|
932
|
+
// trivial destructor, but is a cheap way to get a bit more safety.
|
933
|
+
group[offset].~value_type();
|
934
|
+
// This is equivalent to memmove(), but faster on my Intel P4,
|
935
|
+
// at lesat with gcc4.1 -O2 / glibc 2.3.6.
|
936
|
+
assert(num_buckets > 0);
|
937
|
+
for (size_type i = offset; i < num_buckets-1; ++i)
|
938
|
+
memcpy(group + i, group + i+1, sizeof(*group)); // hopefully inlined!
|
939
|
+
group = (value_type *)
|
940
|
+
realloc_or_die(group, sizeof(*group) * (num_buckets-1));
|
941
|
+
}
|
942
|
+
|
943
|
+
// Shrink the array, without any special assumptions about value_type.
|
944
|
+
void erase_aux(size_type offset, false_type) {
|
945
|
+
// This is valid because 0 <= offset < num_buckets. Note the inequality.
|
946
|
+
value_type* p = allocate_group(num_buckets - 1);
|
947
|
+
uninitialized_copy(group, group + offset, p);
|
948
|
+
uninitialized_copy(group + offset + 1, group + num_buckets, p + offset);
|
949
|
+
free_group();
|
950
|
+
group = p;
|
951
|
+
}
|
952
|
+
|
953
|
+
public:
|
954
|
+
// This takes the specified elements out of the group. This is
|
955
|
+
// "undefining", rather than "clearing".
|
956
|
+
// TODO(austern): Make this exception safe: handle exceptions from
|
957
|
+
// value_type's copy constructor.
|
958
|
+
void erase(size_type i) {
|
959
|
+
if ( bmtest(i) ) { // trivial to erase empty bucket
|
960
|
+
size_type offset = pos_to_offset(bitmap,i); // where we'll find (or insert)
|
961
|
+
if ( num_buckets == 1 ) {
|
962
|
+
free_group();
|
963
|
+
group = NULL;
|
964
|
+
} else {
|
965
|
+
typedef integral_constant<bool,
|
966
|
+
(has_trivial_copy<value_type>::value &&
|
967
|
+
has_trivial_destructor<value_type>::value)>
|
968
|
+
realloc_and_memmove_ok; // pretend mv(x,y) == "x.~T(); new(x) T(y)"
|
969
|
+
erase_aux(offset, realloc_and_memmove_ok());
|
970
|
+
}
|
971
|
+
--num_buckets;
|
972
|
+
bmclear(i);
|
973
|
+
}
|
974
|
+
}
|
975
|
+
|
976
|
+
void erase(iterator pos) {
|
977
|
+
erase(pos.pos);
|
978
|
+
}
|
979
|
+
|
980
|
+
void erase(iterator start_it, iterator end_it) {
|
981
|
+
// This could be more efficient, but to do so we'd need to make
|
982
|
+
// bmclear() clear a range of indices. Doesn't seem worth it.
|
983
|
+
for ( ; start_it != end_it; ++start_it )
|
984
|
+
erase(start_it);
|
985
|
+
}
|
986
|
+
|
987
|
+
|
988
|
+
// I/O
|
989
|
+
// We support reading and writing groups to disk. We don't store
|
990
|
+
// the actual array contents (which we don't know how to store),
|
991
|
+
// just the bitmap and size. Meant to be used with table I/O.
|
992
|
+
// Returns true if all was ok
|
993
|
+
bool write_metadata(FILE *fp) const {
|
994
|
+
assert(sizeof(num_buckets) == 2); // we explicitly set to u_int16_t
|
995
|
+
PUT_(num_buckets, 8);
|
996
|
+
PUT_(num_buckets, 0);
|
997
|
+
if ( !fwrite(bitmap, sizeof(bitmap), 1, fp) ) return false;
|
998
|
+
return true;
|
999
|
+
}
|
1000
|
+
|
1001
|
+
// Reading destroys the old group contents! Returns true if all was ok
|
1002
|
+
bool read_metadata(FILE *fp) {
|
1003
|
+
clear();
|
1004
|
+
|
1005
|
+
int x; // the GET_ macro requires an 'int x' to be defined
|
1006
|
+
GET_(num_buckets, 8);
|
1007
|
+
GET_(num_buckets, 0);
|
1008
|
+
|
1009
|
+
if ( !fread(bitmap, sizeof(bitmap), 1, fp) ) return false;
|
1010
|
+
|
1011
|
+
// We'll allocate the space, but we won't fill it: it will be
|
1012
|
+
// left as uninitialized raw memory.
|
1013
|
+
group = allocate_group(num_buckets);
|
1014
|
+
return true;
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
// If your keys and values are simple enough, we can write them
|
1018
|
+
// to disk for you. "simple enough" means POD and no pointers.
|
1019
|
+
// However, we don't try to normalize endianness
|
1020
|
+
bool write_nopointer_data(FILE *fp) const {
|
1021
|
+
for ( const_nonempty_iterator it = nonempty_begin();
|
1022
|
+
it != nonempty_end(); ++it ) {
|
1023
|
+
if ( !fwrite(&*it, sizeof(*it), 1, fp) ) return false;
|
1024
|
+
}
|
1025
|
+
return true;
|
1026
|
+
}
|
1027
|
+
|
1028
|
+
// When reading, we have to override the potential const-ness of *it.
|
1029
|
+
// Again, only meaningful if value_type is a POD.
|
1030
|
+
bool read_nopointer_data(FILE *fp) {
|
1031
|
+
for ( nonempty_iterator it = nonempty_begin();
|
1032
|
+
it != nonempty_end(); ++it ) {
|
1033
|
+
if ( !fread(reinterpret_cast<void*>(&(*it)), sizeof(*it), 1, fp) )
|
1034
|
+
return false;
|
1035
|
+
}
|
1036
|
+
return true;
|
1037
|
+
}
|
1038
|
+
|
1039
|
+
// Comparisons. Note the comparisons are pretty arbitrary: we
|
1040
|
+
// compare values of the first index that isn't equal (using default
|
1041
|
+
// value for empty buckets).
|
1042
|
+
bool operator==(const sparsegroup& x) const {
|
1043
|
+
return ( num_buckets == x.num_buckets &&
|
1044
|
+
memcmp(bitmap, x.bitmap, sizeof(bitmap)) == 0 &&
|
1045
|
+
STL_NAMESPACE::equal(begin(), end(), x.begin()) ); // from algorithm
|
1046
|
+
}
|
1047
|
+
bool operator<(const sparsegroup& x) const { // also from algorithm
|
1048
|
+
return STL_NAMESPACE::lexicographical_compare(begin(), end(),
|
1049
|
+
x.begin(), x.end());
|
1050
|
+
}
|
1051
|
+
bool operator!=(const sparsegroup& x) const { return !(*this == x); }
|
1052
|
+
bool operator<=(const sparsegroup& x) const { return !(x < *this); }
|
1053
|
+
bool operator>(const sparsegroup& x) const { return x < *this; }
|
1054
|
+
bool operator>=(const sparsegroup& x) const { return !(*this < x); }
|
1055
|
+
|
1056
|
+
private:
|
1057
|
+
// The actual data
|
1058
|
+
value_type *group; // (small) array of T's
|
1059
|
+
unsigned char bitmap[(GROUP_SIZE-1)/8 + 1]; // fancy math is so we round up
|
1060
|
+
size_type num_buckets; // limits GROUP_SIZE to 64K
|
1061
|
+
};
|
1062
|
+
|
1063
|
+
// We need a global swap as well
|
1064
|
+
template <class T, u_int16_t GROUP_SIZE>
|
1065
|
+
inline void swap(sparsegroup<T,GROUP_SIZE> &x, sparsegroup<T,GROUP_SIZE> &y) {
|
1066
|
+
x.swap(y);
|
1067
|
+
}
|
1068
|
+
|
1069
|
+
// ---------------------------------------------------------------------------
|
1070
|
+
|
1071
|
+
|
1072
|
+
template <class T, u_int16_t GROUP_SIZE = DEFAULT_SPARSEGROUP_SIZE>
|
1073
|
+
class sparsetable {
|
1074
|
+
public:
|
1075
|
+
// Basic types
|
1076
|
+
typedef T value_type; // stolen from stl_vector.h
|
1077
|
+
typedef value_type* pointer;
|
1078
|
+
typedef const value_type* const_pointer;
|
1079
|
+
typedef table_iterator<sparsetable<T, GROUP_SIZE> > iterator;
|
1080
|
+
typedef const_table_iterator<sparsetable<T, GROUP_SIZE> > const_iterator;
|
1081
|
+
typedef table_element_adaptor<sparsetable<T, GROUP_SIZE> > element_adaptor;
|
1082
|
+
typedef value_type &reference;
|
1083
|
+
typedef const value_type &const_reference;
|
1084
|
+
typedef size_t size_type;
|
1085
|
+
typedef ptrdiff_t difference_type;
|
1086
|
+
typedef STL_NAMESPACE::reverse_iterator<const_iterator> const_reverse_iterator;
|
1087
|
+
typedef STL_NAMESPACE::reverse_iterator<iterator> reverse_iterator;
|
1088
|
+
|
1089
|
+
// These are our special iterators, that go over non-empty buckets in a
|
1090
|
+
// table. These aren't const only because you can change non-empty bcks.
|
1091
|
+
typedef two_d_iterator< vector< sparsegroup<value_type, GROUP_SIZE> > >
|
1092
|
+
nonempty_iterator;
|
1093
|
+
typedef const_two_d_iterator< vector< sparsegroup<value_type, GROUP_SIZE> > >
|
1094
|
+
const_nonempty_iterator;
|
1095
|
+
typedef STL_NAMESPACE::reverse_iterator<nonempty_iterator> reverse_nonempty_iterator;
|
1096
|
+
typedef STL_NAMESPACE::reverse_iterator<const_nonempty_iterator> const_reverse_nonempty_iterator;
|
1097
|
+
// Another special iterator: it frees memory as it iterates (used to resize)
|
1098
|
+
typedef destructive_two_d_iterator< vector< sparsegroup<value_type, GROUP_SIZE> > >
|
1099
|
+
destructive_iterator;
|
1100
|
+
|
1101
|
+
// Iterator functions
|
1102
|
+
iterator begin() { return iterator(this, 0); }
|
1103
|
+
const_iterator begin() const { return const_iterator(this, 0); }
|
1104
|
+
iterator end() { return iterator(this, size()); }
|
1105
|
+
const_iterator end() const { return const_iterator(this, size()); }
|
1106
|
+
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
1107
|
+
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
|
1108
|
+
reverse_iterator rend() { return reverse_iterator(begin()); }
|
1109
|
+
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
|
1110
|
+
|
1111
|
+
// Versions for our special non-empty iterator
|
1112
|
+
nonempty_iterator nonempty_begin() {
|
1113
|
+
return nonempty_iterator(groups.begin(), groups.end(), groups.begin());
|
1114
|
+
}
|
1115
|
+
const_nonempty_iterator nonempty_begin() const {
|
1116
|
+
return const_nonempty_iterator(groups.begin(),groups.end(), groups.begin());
|
1117
|
+
}
|
1118
|
+
nonempty_iterator nonempty_end() {
|
1119
|
+
return nonempty_iterator(groups.begin(), groups.end(), groups.end());
|
1120
|
+
}
|
1121
|
+
const_nonempty_iterator nonempty_end() const {
|
1122
|
+
return const_nonempty_iterator(groups.begin(), groups.end(), groups.end());
|
1123
|
+
}
|
1124
|
+
reverse_nonempty_iterator nonempty_rbegin() {
|
1125
|
+
return reverse_nonempty_iterator(nonempty_end());
|
1126
|
+
}
|
1127
|
+
const_reverse_nonempty_iterator nonempty_rbegin() const {
|
1128
|
+
return const_reverse_nonempty_iterator(nonempty_end());
|
1129
|
+
}
|
1130
|
+
reverse_nonempty_iterator nonempty_rend() {
|
1131
|
+
return reverse_nonempty_iterator(nonempty_begin());
|
1132
|
+
}
|
1133
|
+
const_reverse_nonempty_iterator nonempty_rend() const {
|
1134
|
+
return const_reverse_nonempty_iterator(nonempty_begin());
|
1135
|
+
}
|
1136
|
+
destructive_iterator destructive_begin() {
|
1137
|
+
return destructive_iterator(groups.begin(), groups.end(), groups.begin());
|
1138
|
+
}
|
1139
|
+
destructive_iterator destructive_end() {
|
1140
|
+
return destructive_iterator(groups.begin(), groups.end(), groups.end());
|
1141
|
+
}
|
1142
|
+
|
1143
|
+
private:
|
1144
|
+
typedef typename vector< sparsegroup<value_type, GROUP_SIZE> >::reference
|
1145
|
+
GroupsReference;
|
1146
|
+
typedef typename
|
1147
|
+
vector< sparsegroup<value_type, GROUP_SIZE> >::const_reference
|
1148
|
+
GroupsConstReference;
|
1149
|
+
typedef typename vector< sparsegroup<value_type, GROUP_SIZE> >::iterator
|
1150
|
+
GroupsIterator;
|
1151
|
+
typedef typename vector< sparsegroup<value_type, GROUP_SIZE> >::const_iterator
|
1152
|
+
GroupsConstIterator;
|
1153
|
+
|
1154
|
+
// How to deal with the proper group
|
1155
|
+
static size_type num_groups(size_type num) { // how many to hold num buckets
|
1156
|
+
return num == 0 ? 0 : ((num-1) / GROUP_SIZE) + 1;
|
1157
|
+
}
|
1158
|
+
|
1159
|
+
u_int16_t pos_in_group(size_type i) const {
|
1160
|
+
return static_cast<u_int16_t>(i % GROUP_SIZE);
|
1161
|
+
}
|
1162
|
+
size_type group_num(size_type i) const {
|
1163
|
+
return i / GROUP_SIZE;
|
1164
|
+
}
|
1165
|
+
GroupsReference which_group(size_type i) {
|
1166
|
+
return groups[group_num(i)];
|
1167
|
+
}
|
1168
|
+
GroupsConstReference which_group(size_type i) const {
|
1169
|
+
return groups[group_num(i)];
|
1170
|
+
}
|
1171
|
+
|
1172
|
+
public:
|
1173
|
+
// Constructors -- default, normal (when you specify size), and copy
|
1174
|
+
sparsetable(size_type sz = 0)
|
1175
|
+
: groups(num_groups(sz)), table_size(sz), num_buckets(0) { }
|
1176
|
+
// We'll can get away with using the default copy constructor,
|
1177
|
+
// and default destructor, and hence the default operator=. Huzzah!
|
1178
|
+
|
1179
|
+
// Many STL algorithms use swap instead of copy constructors
|
1180
|
+
void swap(sparsetable& x) {
|
1181
|
+
STL_NAMESPACE::swap(groups, x.groups);
|
1182
|
+
STL_NAMESPACE::swap(table_size, x.table_size);
|
1183
|
+
STL_NAMESPACE::swap(num_buckets, x.num_buckets);
|
1184
|
+
}
|
1185
|
+
|
1186
|
+
// It's always nice to be able to clear a table without deallocating it
|
1187
|
+
void clear() {
|
1188
|
+
GroupsIterator group;
|
1189
|
+
for ( group = groups.begin(); group != groups.end(); ++group ) {
|
1190
|
+
group->clear();
|
1191
|
+
}
|
1192
|
+
num_buckets = 0;
|
1193
|
+
}
|
1194
|
+
|
1195
|
+
// Functions that tell you about size.
|
1196
|
+
// NOTE: empty() is non-intuitive! It does not tell you the number
|
1197
|
+
// of not-empty buckets (use num_nonempty() for that). Instead
|
1198
|
+
// it says whether you've allocated any buckets or not.
|
1199
|
+
size_type size() const { return table_size; }
|
1200
|
+
size_type max_size() const { return size_type(-1); }
|
1201
|
+
bool empty() const { return table_size == 0; }
|
1202
|
+
// We also may want to know how many *used* buckets there are
|
1203
|
+
size_type num_nonempty() const { return num_buckets; }
|
1204
|
+
|
1205
|
+
// OK, we'll let you resize one of these puppies
|
1206
|
+
void resize(size_type new_size) {
|
1207
|
+
groups.resize(num_groups(new_size));
|
1208
|
+
if ( new_size < table_size) { // lower num_buckets, clear last group
|
1209
|
+
if ( pos_in_group(new_size) > 0 ) // need to clear inside last group
|
1210
|
+
groups.back().erase(groups.back().begin() + pos_in_group(new_size),
|
1211
|
+
groups.back().end());
|
1212
|
+
num_buckets = 0; // refigure # of used buckets
|
1213
|
+
GroupsConstIterator group;
|
1214
|
+
for ( group = groups.begin(); group != groups.end(); ++group )
|
1215
|
+
num_buckets += group->num_nonempty();
|
1216
|
+
}
|
1217
|
+
table_size = new_size;
|
1218
|
+
}
|
1219
|
+
|
1220
|
+
|
1221
|
+
// We let you see if a bucket is non-empty without retrieving it
|
1222
|
+
bool test(size_type i) const {
|
1223
|
+
return which_group(i).test(pos_in_group(i));
|
1224
|
+
}
|
1225
|
+
bool test(iterator pos) const {
|
1226
|
+
return which_group(pos.pos).test(pos_in_group(pos.pos));
|
1227
|
+
}
|
1228
|
+
bool test(const_iterator pos) const {
|
1229
|
+
return which_group(pos.pos).test(pos_in_group(pos.pos));
|
1230
|
+
}
|
1231
|
+
|
1232
|
+
// We only return const_references because it's really hard to
|
1233
|
+
// return something settable for empty buckets. Use set() instead.
|
1234
|
+
const_reference get(size_type i) const {
|
1235
|
+
assert(i < table_size);
|
1236
|
+
return which_group(i).get(pos_in_group(i));
|
1237
|
+
}
|
1238
|
+
|
1239
|
+
// TODO(csilvers): make protected + friend
|
1240
|
+
// This is used by sparse_hashtable to get an element from the table
|
1241
|
+
// when we know it exists (because the caller has called test(i)).
|
1242
|
+
const_reference unsafe_get(size_type i) const {
|
1243
|
+
assert(i < table_size);
|
1244
|
+
assert(test(i));
|
1245
|
+
return which_group(i).unsafe_get(pos_in_group(i));
|
1246
|
+
}
|
1247
|
+
|
1248
|
+
// TODO(csilvers): make protected + friend element_adaptor
|
1249
|
+
reference mutating_get(size_type i) { // fills bucket i before getting
|
1250
|
+
assert(i < table_size);
|
1251
|
+
size_type old_numbuckets = which_group(i).num_nonempty();
|
1252
|
+
reference retval = which_group(i).mutating_get(pos_in_group(i));
|
1253
|
+
num_buckets += which_group(i).num_nonempty() - old_numbuckets;
|
1254
|
+
return retval;
|
1255
|
+
}
|
1256
|
+
|
1257
|
+
// Syntactic sugar. As in sparsegroup, the non-const version is harder
|
1258
|
+
const_reference operator[](size_type i) const {
|
1259
|
+
return get(i);
|
1260
|
+
}
|
1261
|
+
|
1262
|
+
element_adaptor operator[](size_type i) {
|
1263
|
+
return element_adaptor(this, i);
|
1264
|
+
}
|
1265
|
+
|
1266
|
+
// Needed for hashtables, gets as a nonempty_iterator. Crashes for empty bcks
|
1267
|
+
const_nonempty_iterator get_iter(size_type i) const {
|
1268
|
+
assert(test(i)); // how can a nonempty_iterator point to an empty bucket?
|
1269
|
+
return const_nonempty_iterator(
|
1270
|
+
groups.begin(), groups.end(),
|
1271
|
+
groups.begin() + group_num(i),
|
1272
|
+
(groups[group_num(i)].nonempty_begin() +
|
1273
|
+
groups[group_num(i)].pos_to_offset(pos_in_group(i))));
|
1274
|
+
}
|
1275
|
+
// For nonempty we can return a non-const version
|
1276
|
+
nonempty_iterator get_iter(size_type i) {
|
1277
|
+
assert(test(i)); // how can a nonempty_iterator point to an empty bucket?
|
1278
|
+
return nonempty_iterator(
|
1279
|
+
groups.begin(), groups.end(),
|
1280
|
+
groups.begin() + group_num(i),
|
1281
|
+
(groups[group_num(i)].nonempty_begin() +
|
1282
|
+
groups[group_num(i)].pos_to_offset(pos_in_group(i))));
|
1283
|
+
}
|
1284
|
+
|
1285
|
+
|
1286
|
+
// This returns a reference to the inserted item (which is a copy of val)
|
1287
|
+
// The trick is to figure out whether we're replacing or inserting anew
|
1288
|
+
reference set(size_type i, const_reference val) {
|
1289
|
+
assert(i < table_size);
|
1290
|
+
size_type old_numbuckets = which_group(i).num_nonempty();
|
1291
|
+
reference retval = which_group(i).set(pos_in_group(i), val);
|
1292
|
+
num_buckets += which_group(i).num_nonempty() - old_numbuckets;
|
1293
|
+
return retval;
|
1294
|
+
}
|
1295
|
+
|
1296
|
+
// This takes the specified elements out of the table. This is
|
1297
|
+
// "undefining", rather than "clearing".
|
1298
|
+
void erase(size_type i) {
|
1299
|
+
assert(i < table_size);
|
1300
|
+
size_type old_numbuckets = which_group(i).num_nonempty();
|
1301
|
+
which_group(i).erase(pos_in_group(i));
|
1302
|
+
num_buckets += which_group(i).num_nonempty() - old_numbuckets;
|
1303
|
+
}
|
1304
|
+
|
1305
|
+
void erase(iterator pos) {
|
1306
|
+
erase(pos.pos);
|
1307
|
+
}
|
1308
|
+
|
1309
|
+
void erase(iterator start_it, iterator end_it) {
|
1310
|
+
// This could be more efficient, but then we'd need to figure
|
1311
|
+
// out if we spanned groups or not. Doesn't seem worth it.
|
1312
|
+
for ( ; start_it != end_it; ++start_it )
|
1313
|
+
erase(start_it);
|
1314
|
+
}
|
1315
|
+
|
1316
|
+
|
1317
|
+
// We support reading and writing tables to disk. We don't store
|
1318
|
+
// the actual array contents (which we don't know how to store),
|
1319
|
+
// just the groups and sizes. Returns true if all went ok.
|
1320
|
+
|
1321
|
+
private:
|
1322
|
+
// Every time the disk format changes, this should probably change too
|
1323
|
+
static const unsigned long MAGIC_NUMBER = 0x24687531;
|
1324
|
+
|
1325
|
+
// Old versions of this code write all data in 32 bits. We need to
|
1326
|
+
// support these files as well as having support for 64-bit systems.
|
1327
|
+
// So we use the following encoding scheme: for values < 2^32-1, we
|
1328
|
+
// store in 4 bytes in big-endian order. For values > 2^32, we
|
1329
|
+
// store 0xFFFFFFF followed by 8 bytes in big-endian order. This
|
1330
|
+
// causes us to mis-read old-version code that stores exactly
|
1331
|
+
// 0xFFFFFFF, but I don't think that is likely to have happened for
|
1332
|
+
// these particular values.
|
1333
|
+
static bool write_32_or_64(FILE* fp, size_type value) {
|
1334
|
+
if ( value < 0xFFFFFFFFULL ) { // fits in 4 bytes
|
1335
|
+
PUT_(value, 24);
|
1336
|
+
PUT_(value, 16);
|
1337
|
+
PUT_(value, 8);
|
1338
|
+
PUT_(value, 0);
|
1339
|
+
} else if ( value == 0xFFFFFFFFUL ) { // special case in 32bit systems
|
1340
|
+
PUT_(0xFF, 0); PUT_(0xFF, 0); PUT_(0xFF, 0); PUT_(0xFF, 0); // marker
|
1341
|
+
PUT_(0, 0); PUT_(0, 0); PUT_(0, 0); PUT_(0, 0);
|
1342
|
+
PUT_(0xFF, 0); PUT_(0xFF, 0); PUT_(0xFF, 0); PUT_(0xFF, 0);
|
1343
|
+
} else {
|
1344
|
+
PUT_(0xFF, 0); PUT_(0xFF, 0); PUT_(0xFF, 0); PUT_(0xFF, 0); // marker
|
1345
|
+
PUT_(value, 56);
|
1346
|
+
PUT_(value, 48);
|
1347
|
+
PUT_(value, 40);
|
1348
|
+
PUT_(value, 32);
|
1349
|
+
PUT_(value, 24);
|
1350
|
+
PUT_(value, 16);
|
1351
|
+
PUT_(value, 8);
|
1352
|
+
PUT_(value, 0);
|
1353
|
+
}
|
1354
|
+
return true;
|
1355
|
+
}
|
1356
|
+
|
1357
|
+
static bool read_32_or_64(FILE* fp, size_type *value) { // reads into value
|
1358
|
+
size_type first4 = 0;
|
1359
|
+
int x;
|
1360
|
+
GET_(first4, 24);
|
1361
|
+
GET_(first4, 16);
|
1362
|
+
GET_(first4, 8);
|
1363
|
+
GET_(first4, 0);
|
1364
|
+
if ( first4 < 0xFFFFFFFFULL ) {
|
1365
|
+
*value = first4;
|
1366
|
+
} else {
|
1367
|
+
GET_(*value, 56);
|
1368
|
+
GET_(*value, 48);
|
1369
|
+
GET_(*value, 40);
|
1370
|
+
GET_(*value, 32);
|
1371
|
+
GET_(*value, 24);
|
1372
|
+
GET_(*value, 16);
|
1373
|
+
GET_(*value, 8);
|
1374
|
+
GET_(*value, 0);
|
1375
|
+
}
|
1376
|
+
return true;
|
1377
|
+
}
|
1378
|
+
|
1379
|
+
public:
|
1380
|
+
bool write_metadata(FILE *fp) const {
|
1381
|
+
if ( !write_32_or_64(fp, MAGIC_NUMBER) ) return false;
|
1382
|
+
if ( !write_32_or_64(fp, table_size) ) return false;
|
1383
|
+
if ( !write_32_or_64(fp, num_buckets) ) return false;
|
1384
|
+
|
1385
|
+
GroupsConstIterator group;
|
1386
|
+
for ( group = groups.begin(); group != groups.end(); ++group )
|
1387
|
+
if ( group->write_metadata(fp) == false ) return false;
|
1388
|
+
return true;
|
1389
|
+
}
|
1390
|
+
|
1391
|
+
// Reading destroys the old table contents! Returns true if read ok.
|
1392
|
+
bool read_metadata(FILE *fp) {
|
1393
|
+
size_type magic_read = 0;
|
1394
|
+
if ( !read_32_or_64(fp, &magic_read) ) return false;
|
1395
|
+
if ( magic_read != MAGIC_NUMBER ) {
|
1396
|
+
clear(); // just to be consistent
|
1397
|
+
return false;
|
1398
|
+
}
|
1399
|
+
|
1400
|
+
if ( !read_32_or_64(fp, &table_size) ) return false;
|
1401
|
+
if ( !read_32_or_64(fp, &num_buckets) ) return false;
|
1402
|
+
|
1403
|
+
resize(table_size); // so the vector's sized ok
|
1404
|
+
GroupsIterator group;
|
1405
|
+
for ( group = groups.begin(); group != groups.end(); ++group )
|
1406
|
+
if ( group->read_metadata(fp) == false ) return false;
|
1407
|
+
return true;
|
1408
|
+
}
|
1409
|
+
|
1410
|
+
// This code is identical to that for SparseGroup
|
1411
|
+
// If your keys and values are simple enough, we can write them
|
1412
|
+
// to disk for you. "simple enough" means no pointers.
|
1413
|
+
// However, we don't try to normalize endianness
|
1414
|
+
bool write_nopointer_data(FILE *fp) const {
|
1415
|
+
for ( const_nonempty_iterator it = nonempty_begin();
|
1416
|
+
it != nonempty_end(); ++it ) {
|
1417
|
+
if ( !fwrite(&*it, sizeof(*it), 1, fp) ) return false;
|
1418
|
+
}
|
1419
|
+
return true;
|
1420
|
+
}
|
1421
|
+
|
1422
|
+
// When reading, we have to override the potential const-ness of *it
|
1423
|
+
bool read_nopointer_data(FILE *fp) {
|
1424
|
+
for ( nonempty_iterator it = nonempty_begin();
|
1425
|
+
it != nonempty_end(); ++it ) {
|
1426
|
+
if ( !fread(reinterpret_cast<void*>(&(*it)), sizeof(*it), 1, fp) )
|
1427
|
+
return false;
|
1428
|
+
}
|
1429
|
+
return true;
|
1430
|
+
}
|
1431
|
+
|
1432
|
+
// Comparisons. Note the comparisons are pretty arbitrary: we
|
1433
|
+
// compare values of the first index that isn't equal (using default
|
1434
|
+
// value for empty buckets).
|
1435
|
+
bool operator==(const sparsetable& x) const {
|
1436
|
+
return ( table_size == x.table_size &&
|
1437
|
+
num_buckets == x.num_buckets &&
|
1438
|
+
groups == x.groups );
|
1439
|
+
}
|
1440
|
+
bool operator<(const sparsetable& x) const { // also from algobase.h
|
1441
|
+
return STL_NAMESPACE::lexicographical_compare(begin(), end(),
|
1442
|
+
x.begin(), x.end());
|
1443
|
+
}
|
1444
|
+
bool operator!=(const sparsetable& x) const { return !(*this == x); }
|
1445
|
+
bool operator<=(const sparsetable& x) const { return !(x < *this); }
|
1446
|
+
bool operator>(const sparsetable& x) const { return x < *this; }
|
1447
|
+
bool operator>=(const sparsetable& x) const { return !(*this < x); }
|
1448
|
+
|
1449
|
+
|
1450
|
+
private:
|
1451
|
+
// The actual data
|
1452
|
+
vector< sparsegroup<value_type, GROUP_SIZE> > groups; // our list of groups
|
1453
|
+
size_type table_size; // how many buckets they want
|
1454
|
+
size_type num_buckets; // number of non-empty buckets
|
1455
|
+
};
|
1456
|
+
|
1457
|
+
// We need a global swap as well
|
1458
|
+
template <class T, u_int16_t GROUP_SIZE>
|
1459
|
+
inline void swap(sparsetable<T,GROUP_SIZE> &x, sparsetable<T,GROUP_SIZE> &y) {
|
1460
|
+
x.swap(y);
|
1461
|
+
}
|
1462
|
+
|
1463
|
+
#undef GET_
|
1464
|
+
#undef PUT_
|
1465
|
+
|
1466
|
+
_END_GOOGLE_NAMESPACE_
|
1467
|
+
|
1468
|
+
#endif
|