Public Member Functions | Public Attributes | Protected Attributes

cmn_FastZeroSearch Class Reference
[G_new_group]

This is a class for fast search of zeroes through buffer. More...

#include <cmn_FastSearch.h>

Inheritance diagram for cmn_FastZeroSearch:
Inheritance graph
[legend]
Collaboration diagram for cmn_FastZeroSearch:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 cmn_FastZeroSearch (int a_numberOfZeroes)
 cmn_FastZeroSearch (const char *const a_buffer_p, const int a_bufLen, int a_numberOfZeroes)
virtual ~cmn_FastZeroSearch ()
void SetPattern (const string &a_pattern)
 set new search pattern, just to implement virtual method
void SetNumberOfZeroes (const int a_num)
Int32_t Find ()
 NOTE! if return value is grater than buffer then string was not found the return value is willing handled in this way, because of using same algorithem with merging buffers.

Public Attributes

 log_CLASSID_m
 Macro to add class name member s_className.

Protected Attributes

UInt32_t m_numberOfZeroes
 number of sequenced zeroes to find

Detailed Description

This is a class for fast search of zeroes through buffer.

Definition at line 188 of file cmn_FastSearch.h.


Constructor & Destructor Documentation

cmn_FastZeroSearch::cmn_FastZeroSearch ( int  a_numberOfZeroes  ) 

Definition at line 262 of file cmn_FastSearch.cpp.

References log_FUNC_m.

cmn_FastZeroSearch::cmn_FastZeroSearch ( const char *const   a_buffer_p,
const int  a_bufLen,
int  a_numberOfZeroes 
)

Definition at line 274 of file cmn_FastSearch.cpp.

References log_FUNC_m.

            :
            cmn_FastSearch(a_buffer_p, a_bufLen),
            m_numberOfZeroes(a_numberOfZeroes)
{
    log_FUNC_m(cmn_FastZeroSearch);
    //Empty
}

virtual cmn_FastZeroSearch::~cmn_FastZeroSearch (  )  [inline, virtual]

Definition at line 199 of file cmn_FastSearch.h.

{};


Member Function Documentation

Int32_t cmn_FastZeroSearch::Find (  )  [virtual]

NOTE! if return value is grater than buffer then string was not found the return value is willing handled in this way, because of using same algorithem with merging buffers.

It's known how much buffer is need to be merged at front of next buffer.

Implements cmn_FastSearch.

Reimplemented in cmn_FastZeroRecSearch.

Definition at line 288 of file cmn_FastSearch.cpp.

References log_FUNC_m, cmn_FastSearch::m_buffer_p, cmn_FastSearch::m_bufLen, m_numberOfZeroes, and zero.

                                 {
    log_FUNC_m(Find);

    UInt32_t    patLen   = m_numberOfZeroes;
    UInt32_t    patLen_1 = patLen - 1;

    register const char *p    = m_buffer_p + patLen_1;
    register const char *s    = m_buffer_p;

    register char    zero = 0;

    const char          *buff = m_buffer_p;

    const char *limit = buff + m_bufLen;
    while (p < limit) {   // this is optimized not readable code  it si 14% faster
                           // see below in comment for original code 
//       register const char *r = p;
       while (*p == zero) {
           if (p == s) {
              return static_cast<Int32_t>(p - buff);
           }
           p--;
       };
       s  = p + 1;
       p += patLen;
    }
    return static_cast<Int32_t>( (p - buff - m_bufLen) - patLen );  // NOTE! if return value is negative then string was not found

}

void cmn_FastZeroSearch::SetNumberOfZeroes ( const int  a_num  )  [inline]

Reimplemented in cmn_FastZeroRecSearch.

Definition at line 216 of file cmn_FastSearch.h.

{m_numberOfZeroes = a_num;};

void cmn_FastZeroSearch::SetPattern ( const string &  a_pattern  )  [inline, virtual]

set new search pattern, just to implement virtual method

Implements cmn_FastSearch.

Reimplemented in cmn_FastZeroRecSearch.

Definition at line 212 of file cmn_FastSearch.h.

                                                     {
        m_numberOfZeroes = static_cast<UInt32_t>(a_pattern.length());
    };


Member Data Documentation

Macro to add class name member s_className.

Reimplemented from cmn_FastSearch.

Reimplemented in cmn_FastZeroRecSearch.

Definition at line 207 of file cmn_FastSearch.h.

number of sequenced zeroes to find

Definition at line 199 of file cmn_FastSearch.h.

Referenced by cmn_FastZeroRecSearch::Find(), and Find().


The documentation for this class was generated from the following files: