mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-19 04:12:13 +00:00
Changes for official inclusion in the regression tests
[SVN r37591]
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztañaga 2004-2005. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztañaga 2004-2007. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
@@ -9,12 +9,11 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/interprocess/detail/config_begin.hpp>
|
||||
#include <boost/interprocess/detail/workaround.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <boost/interprocess/file_mapping.hpp>
|
||||
#include <boost/interprocess/mapped_region.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
@@ -120,156 +119,12 @@ int main ()
|
||||
}
|
||||
}
|
||||
catch(std::exception &exc){
|
||||
std::remove("my_file");
|
||||
std::cout << "Unhandled exception: " << exc.what() << std::endl;
|
||||
throw;
|
||||
}
|
||||
|
||||
std::remove("my_file");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <boost/interprocess/detail/config_end.hpp>
|
||||
|
||||
/*
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
#include <boost/unordered_set.hpp>
|
||||
#include <boost/pool/pool_alloc.hpp>
|
||||
|
||||
char allchars [] = "abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
struct DictionaryValue
|
||||
{
|
||||
std::string str;
|
||||
std::size_t count;
|
||||
bool operator == (const DictionaryValue &other) const
|
||||
{ return str == other.str; }
|
||||
};
|
||||
|
||||
struct DictionaryHasher
|
||||
: std::unary_function<DictionaryValue, std::size_t>
|
||||
{
|
||||
std::size_t operator()(const DictionaryValue &val) const
|
||||
{
|
||||
const char *str = val.str.data();
|
||||
std::size_t len = val.str.size();
|
||||
std::size_t hash = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
switch (len)
|
||||
{
|
||||
case 0:
|
||||
return hash;
|
||||
|
||||
case 1:
|
||||
hash *= 37;
|
||||
hash += *(unsigned char *)str;
|
||||
return hash;
|
||||
|
||||
case 2:
|
||||
hash *= 37;
|
||||
hash += *(unsigned short *)str;
|
||||
return hash;
|
||||
|
||||
case 3:
|
||||
hash *= 37;
|
||||
hash += (*(unsigned short *)str << 8) +
|
||||
((unsigned char *)str)[2];
|
||||
return hash;
|
||||
|
||||
default:
|
||||
hash *= 37;
|
||||
hash += *(long *)str;
|
||||
str += 4;
|
||||
len -= 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
std::size_t w_total = 0;
|
||||
std::size_t l_total = 0;
|
||||
std::size_t c_total = 0;
|
||||
|
||||
typedef boost::unordered_set<DictionaryValue
|
||||
,DictionaryHasher
|
||||
,std::equal_to<DictionaryValue>
|
||||
,boost::fast_pool_allocator<DictionaryValue>
|
||||
> Dictionary;
|
||||
|
||||
Dictionary dictionary;
|
||||
typedef Dictionary::iterator iterator;
|
||||
DictionaryValue dict_value;
|
||||
|
||||
std::ifstream input_file(argv[1], std::ios_base::in | std::ios_base::binary );
|
||||
input_file.seekg(0, std::ios::end);
|
||||
|
||||
std::vector<char> data(static_cast<std::size_t>(input_file.tellg()));
|
||||
input_file.seekg(0, std::ios::beg);
|
||||
input_file.read(&data[0], static_cast<std::streamsize>(data.size()));
|
||||
input_file.close();
|
||||
|
||||
std::size_t w_count = 0;
|
||||
std::size_t w_diff = 'z'-'a';
|
||||
|
||||
for ( int a = 0; a < 100; ++a )
|
||||
{
|
||||
std::string &word = dict_value.str;
|
||||
word.reserve(64);
|
||||
dict_value.count = 0;
|
||||
|
||||
std::size_t w_cnt = 0;
|
||||
std::size_t l_cnt = 0;
|
||||
std::size_t c_cnt = 0;
|
||||
bool inword = false;
|
||||
std::size_t wstart = 0;
|
||||
for ( std::size_t j = 0, size = data.size(); j < size; j++ )
|
||||
{
|
||||
char c = data[j];
|
||||
if (c == '\n')
|
||||
++l_cnt;
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
}
|
||||
else if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
|
||||
{
|
||||
if (!inword)
|
||||
{
|
||||
wstart = j;
|
||||
inword = true;
|
||||
++w_cnt;
|
||||
}
|
||||
}
|
||||
else if (inword)
|
||||
{
|
||||
word.assign(&data[wstart], &data[j]);
|
||||
++w_count;
|
||||
std::size_t num = w_count%25;
|
||||
word.insert(1, 1, allchars[num]);
|
||||
// dictionary.insert(dict_value).first->count++;
|
||||
inword = false;
|
||||
}
|
||||
++c_cnt;
|
||||
}
|
||||
|
||||
if (inword)
|
||||
{
|
||||
word.assign(&data[wstart], &data[data.size()]);
|
||||
++w_count;
|
||||
std::size_t num = w_count%25;
|
||||
word.insert(1, 1, allchars[num]);
|
||||
// dictionary.insert(dict_value).first->count++;
|
||||
}
|
||||
l_total += l_cnt;
|
||||
w_total += w_cnt;
|
||||
c_total += c_cnt;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user