DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
/////////////////////////////////////////////////////////////////////////////// /// \file boyer_moore.hpp /// Contains the boyer-moore implementation. Note: this is *not* a general- /// purpose boyer-moore implementation. It truncates the search string at /// 256 characters, but it is sufficient for the needs of xpressive. // // Copyright 2007 Eric Niebler. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_XPRESSIVE_DETAIL_BOYER_MOORE_HPP_EAN_10_04_2005 #define BOOST_XPRESSIVE_DETAIL_BOYER_MOORE_HPP_EAN_10_04_2005 // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once # pragma warning(push) # pragma warning(disable : 4100) // unreferenced formal parameter #endif #include
// for UCHAR_MAX #include
// for std::ptrdiff_t #include
// for std::max #include
#include
#include
#include
#include
#include
namespace boost { namespace xpressive { namespace detail { /////////////////////////////////////////////////////////////////////////////// // boyer_moore // template
struct boyer_moore : noncopyable { typedef typename iterator_value
::type char_type; typedef Traits traits_type; typedef has_fold_case
case_fold; typedef typename Traits::string_type string_type; // initialize the Boyer-Moore search data structure, using the // search sub-sequence to prime the pump. boyer_moore(char_type const *begin, char_type const *end, Traits const &traits, bool icase) : begin_(begin) , last_(begin) , fold_() , find_fun_( icase ? (case_fold() ? &boyer_moore::find_nocase_fold_ : &boyer_moore::find_nocase_) : &boyer_moore::find_ ) { std::ptrdiff_t const uchar_max = UCHAR_MAX; std::ptrdiff_t diff = std::distance(begin, end); this->length_ = static_cast
((std::min)(diff, uchar_max)); std::fill_n(static_cast
(this->offsets_), uchar_max + 1, this->length_); --this->length_; icase ? this->init_(traits, case_fold()) : this->init_(traits, mpl::false_()); } BidiIter find(BidiIter begin, BidiIter end, Traits const &traits) const { return (this->*this->find_fun_)(begin, end, traits); } private: void init_(Traits const &traits, mpl::false_) { for(unsigned char offset = this->length_; offset; --offset, ++this->last_) { this->offsets_[traits.hash(*this->last_)] = offset; } } void init_(Traits const &traits, mpl::true_) { this->fold_.reserve(this->length_ + 1); for(unsigned char offset = this->length_; offset; --offset, ++this->last_) { this->fold_.push_back(traits.fold_case(*this->last_)); for(typename string_type::const_iterator beg = this->fold_.back().begin(), end = this->fold_.back().end(); beg != end; ++beg) { this->offsets_[traits.hash(*beg)] = offset; } } this->fold_.push_back(traits.fold_case(*this->last_)); } // case-sensitive Boyer-Moore search BidiIter find_(BidiIter begin, BidiIter end, Traits const &traits) const { typedef typename boost::iterator_difference
::type diff_type; diff_type const endpos = std::distance(begin, end); diff_type offset = static_cast
(this->length_); for(diff_type curpos = offset; curpos < endpos; curpos += offset) { std::advance(begin, offset); char_type const *pat_tmp = this->last_; BidiIter str_tmp = begin; for(; traits.translate(*str_tmp) == *pat_tmp; --pat_tmp, --str_tmp) { if(pat_tmp == this->begin_) { return str_tmp; } } offset = this->offsets_[traits.hash(traits.translate(*begin))]; } return end; } // case-insensitive Boyer-Moore search BidiIter find_nocase_(BidiIter begin, BidiIter end, Traits const &traits) const { typedef typename boost::iterator_difference
::type diff_type; diff_type const endpos = std::distance(begin, end); diff_type offset = static_cast
(this->length_); for(diff_type curpos = offset; curpos < endpos; curpos += offset) { std::advance(begin, offset); char_type const *pat_tmp = this->last_; BidiIter str_tmp = begin; for(; traits.translate_nocase(*str_tmp) == *pat_tmp; --pat_tmp, --str_tmp) { if(pat_tmp == this->begin_) { return str_tmp; } } offset = this->offsets_[traits.hash(traits.translate_nocase(*begin))]; } return end; } // case-insensitive Boyer-Moore search with case-folding BidiIter find_nocase_fold_(BidiIter begin, BidiIter end, Traits const &traits) const { typedef typename boost::iterator_difference
::type diff_type; diff_type const endpos = std::distance(begin, end); diff_type offset = static_cast
(this->length_); for(diff_type curpos = offset; curpos < endpos; curpos += offset) { std::advance(begin, offset); string_type const *pat_tmp = &this->fold_.back(); BidiIter str_tmp = begin; for(; pat_tmp->end() != std::find(pat_tmp->begin(), pat_tmp->end(), *str_tmp); --pat_tmp, --str_tmp) { if(pat_tmp == &this->fold_.front()) { return str_tmp; } } offset = this->offsets_[traits.hash(*begin)]; } return end; } private: char_type const *begin_; char_type const *last_; std::vector
fold_; BidiIter (boyer_moore::*const find_fun_)(BidiIter, BidiIter, Traits const &) const; unsigned char length_; unsigned char offsets_[UCHAR_MAX + 1]; }; }}} // namespace boost::xpressive::detail #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma warning(pop) #endif #endif
boyer_moore.hpp
Page URL
File URL
Prev
3/16
Next
Download
( 6 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.