亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? stringset.cpp

?? 基于MFC和STL平臺的字符串類
?? CPP
字號:
// StringSet.Cpp: implementation of the CIVStringSet class.
//
// Written 12 June 2002 by Scot T Brennecke
// Thanks to Moishe Halibard and Moshe Rubin for their article,
//    "A Multiple Substring Search Algorithm" in the June 2002
//    edition of C/C++ Users Journal.  This class is based on
//    the algorthim therein described, but extended to return
//    all strings and use MFC classes.


#include "StdAfx.H"
#include "StringSet.H"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__ ;
#define new DEBUG_NEW
#endif

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                       C I V S t r i n g S e t
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CIVStringSet
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CIVStringSet::CIVStringSet( WORD wInitialWidth /*= 64*/ )
    : m_apnFSM( new DWORD[wInitialWidth][128] ),
      m_nCurDim( wInitialWidth ),
      m_nUsedCols( 0 ),
      m_wMaxUsedState( 0 ),
      m_nCurTextChar( 0 )
{
    // Initialize all FSM entries to zero
    ZeroMemory( m_apnFSM, sizeof(DWORD) * 128 * wInitialWidth ) ;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~CIVStringSet
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CIVStringSet::~CIVStringSet()
{
    delete [] m_apnFSM ;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Add
//    several variations, the first being the most basic
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool CIVStringSet::Add( LPCTSTR pszWord )
{
    bool bRetVal = false ;

    // Insert the word into the FSM, then add it to the array
    if ( ( pszWord != NULL )
      && InsertWord( pszWord, (WORD)(size() + 1) )
       )
    {
        std::string strWord(pszWord) ;
        push_back( strWord ) ;
        bRetVal = true ;
    }

    return bRetVal ;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Add a string
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool CIVStringSet::Add( const std::string & rstrWord )
{
    bool bRetVal = false ;

    // Insert the word into the FSM, then add it to the array
    if ( InsertWord( rstrWord.c_str(), (WORD)(size() + 1) ) )
    {
        push_back( rstrWord ) ;
        bRetVal = true ;
    }

    return bRetVal ;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Add multiple words, delimited with chars from pszDelims
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int CIVStringSet::Add( LPCTSTR pszWords, LPCTSTR pszDelims )
{
    int nCount = 0 ;

    // Start with the entire string
    std::string strUnparsed( pszWords ),
                strToken ;

    // stop iterating when we find no more words following delimiters
    while ( ! strUnparsed.empty() )
    {
        // Extract the first token
        size_t nTokSize = _tcscspn( strUnparsed.c_str(), pszDelims ) ;
        strToken = strUnparsed.substr( 0, nTokSize ) ;
        if ( ! strToken.empty() )
        {
            if ( Add( strToken ) )  // add it to the FSM and the array
                nCount++ ;
            else
                break ;
        }

        // Now, move beyond the token just extracted and the delimiters
        int nTokenLen = strToken.length() ;
        if ( nTokenLen < strUnparsed.length() )
        {
            int nDelimLen = _tcsspn( &strUnparsed[nTokenLen], pszDelims ) ;
            nTokenLen += nDelimLen ;
            if ( nTokenLen < strUnparsed.length() )
                strUnparsed = strUnparsed.substr( nTokenLen ) ;
            else
                break ;
        }
        else
            break ;
    }

    return nCount ;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// add nWords words, each \0 term'd, with extra \0 at end
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int CIVStringSet::Add( LPCTSTR pszzWords, int nWords )
{
    int nCount = 0 ;

    // Start with the first word in the multi-string
    LPCTSTR pszCurWord = pszzWords ;
    if ( pszCurWord != NULL )
    {
        // stop iterating when we find a "word" beginning with null (the extra \0)
        while ( pszCurWord[0] != '\0' )
        {
            if ( Add( pszCurWord ) )  // add it to the FSM and the array
            {
                nCount++ ;

                // Position to the next word, one beyond the null terminator
                size_t nLen = _tcslen( pszCurWord ) ;
                // If this fails, the extra \0 was probably not there, as required
                pszCurWord = &pszzWords[nLen+1] ;
            }
            else
                break ;
        }
    }

#ifdef _DEBUG
    if ( ( nWords != nCount )
      && ( nWords > 0 )
       )
        TRACE("Expected %d words, but found %d!\n", nWords, nCount);
#else
    UNUSED(nWords);
#endif

    return nCount ;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// add all the elements of an array of strings
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int CIVStringSet::Add( std::vector<std::string> astrWords )
{
    size_t nCount = astrWords.size() ;
    reserve( size() + nCount ) ;

    for ( UINT nWord = 0 ; nWord < nCount ; nWord++ )
    {
        if ( ! Add( astrWords[nWord] ) )  // add it to the FSM and the array
            break ;
    }

    return nWord ;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// add all the elements of a list of strings
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int CIVStringSet::Add( std::list<std::string> lstrWords )
{
    size_t nCount = lstrWords.size() ;
    reserve( size() + nCount ) ;

    // Iterate the string list
    std::list<std::string>::iterator it = lstrWords.begin() ;
    while ( it != lstrWords.end() )
    {
        if ( ! Add( *it++ ) )  // add it to the FSM and the array
            break ;
    }

    return nCount ;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// InsertWord
//          put the new word into the FSM
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool CIVStringSet::InsertWord( LPCTSTR pszWord, WORD wIndex )
{
    bool bRetVal = false ;

    size_t nLen = _tcslen( pszWord ) ;
    if ( ( m_wMaxUsedState < MAXWORD )    // if we've got 65,535 states, something's wrong
      && SetColDim( m_nUsedCols + nLen )  // make sure enough columns are allocated
       )
    {
        WORD wCurState = 0 ;
        for ( UINT nChar = 0 ; nChar < nLen ; nChar++ )
        {
            int nIdxChar = (pszWord[nChar] & 0x7F) ;  // mask out char values above 127
            DWORD dwEntry = m_apnFSM[wCurState][nIdxChar] ;  // the state, and possibly also an index
            WORD wState = LOWORD(dwEntry) ;  // extract only the state portion
            bool bNew = (wState == 0) ;      // no previous words have been here

            if ( bNew )
                wState = ++m_wMaxUsedState ;  // use a new state number

            // special case - last character of substring
            if ( nChar == ( nLen-1 ) )
            {
                // Put both the state number and the word index in the entry
                m_apnFSM[wCurState][nIdxChar] = (DWORD)MAKELONG(wState, wIndex) ;
                break ;
            }
            else if ( bNew ) // if current entry for this char value and state is still zero, add to FSM
                m_apnFSM[wCurState][nIdxChar] = wState ;

            wCurState = wState ;  // prepare for next iteration
        }

        m_nUsedCols += nLen ;
        bRetVal = true ;
    }

    return bRetVal ;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// SetColDim
//          set the current width to at least nNewDim columns
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool CIVStringSet::SetColDim( size_t nNewDim )
{
    bool bRetVal = false ;

    // Determine if we don't yet have enough columns for the newest word 
    if ( m_nCurDim < nNewDim )
    {
        int nNewSize = ((nNewDim + 63) & 0xFFC0) ;  // set to next higher multiple of 64
        if ( nNewSize < MAXWORD )  // we're "limited" to 65,535 columns
        {
            // reallocate the FSM with the increased column width
            DWORD (* apnTemp)[128] = new DWORD[nNewSize][128] ;
            ASSERT((int)m_nUsedCols < nNewSize);
            // Copy the portion already used, and zero out the rest
            CopyMemory( &apnTemp[0], &m_apnFSM[0], sizeof(DWORD) * 128 * m_nUsedCols ) ;
            ZeroMemory( &apnTemp[m_nUsedCols], sizeof(DWORD) * 128 * (nNewSize - m_nUsedCols) ) ;
            delete [] m_apnFSM ; // Get rid of old FSM buffer,
            m_apnFSM = apnTemp ; // and point to new one
            m_nCurDim = (WORD)nNewSize ;

            bRetVal = true ;
        }
    }
    else
        bRetVal = true ;

    return bRetVal ;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// FindFirstIn
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
UINT CIVStringSet::FindFirstIn( std::string strText, int & rnFirst )
{
    // The real work is done by FindNext, but we must initialize the starting
    //    character index and string buffer first
    m_nCurTextChar = 0 ;
    m_strSearch = strText ;

    return FindNext( rnFirst ) ;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// FindNext
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
UINT CIVStringSet::FindNext( int & rnNext )
{
    WORD wCurState = 0 ; // start in state 0
    UINT nIdx ;
    UINT nStartChar = 0xFFFFFFFF ;
    size_t nLen = m_strSearch.length() ;

    // Start with the character following the last one examined
    for ( nIdx = m_nCurTextChar ; nIdx < nLen ; nIdx++ )
    {
        WORD wPrevState = wCurState ;

        // if we are in state 0, save the index of the starting character,
        //   in case we must backtrack or for the return value
        if ( wCurState == 0 )
            nStartChar = nIdx ;

        // follow up the table states
        int nIdxChar = (m_strSearch[(int)nIdx] & 0x7F) ;  // mask out char values above 127
        DWORD dwEntry = m_apnFSM[wCurState][nIdxChar] ;

        // if we reach an entry with a high word (an index), we have found a full match
        //    return the word we found
        if ( dwEntry > MAXWORD )
        {
            int nIndex = HIWORD(dwEntry) - 1 ;
            ASSERT(nIndex < size());
            rnNext = nIndex ;
            m_nCurTextChar = nIdx + 1 ;  // set the index for the next time
            break ;
        }
        else
            wCurState = LOWORD(dwEntry) ;

        // have we followed a false lead?
        // if so, backtrack nIdx to position to continue search, with state reset to zero
        // set nIdx to nStartChar, and it will be incremented as the loop re-enters
        if ( ( wPrevState != 0 )
          && ( wCurState == 0 )
           )
        {
            nIdx = nStartChar ;
            nStartChar = 0xFFFFFFFF ;  // in case we're about to terminate the loop
        }
    }

    // return the index of the start of the word, or -1 if no word found
    return (( nIdx < nLen ) ? nStartChar : 0xFFFFFFFF) ;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// FindAllIn
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
size_t CIVStringSet::FindAllIn( std::string strText, CWordPosPairList & rlstrWords )
{
    rlstrWords.clear() ;

    // Iterate through all words, and put them in the list
    int  nWord = -1 ;
    UINT nPos = FindFirstIn( strText, nWord ) ;
    if ( nPos != 0xFFFFFFFF )
    {
        do
        {
            CWordPosPair posWord( nWord, nPos ) ;
            rlstrWords.push_back( posWord ) ;
            nPos = FindNext( nWord ) ;
        } while ( nPos != 0xFFFFFFFF ) ;
    }

    return rlstrWords.size() ;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一区在线播放| www成人在线观看| youjizz久久| 成人免费va视频| 成人国产精品免费网站| 国产成人综合亚洲网站| 国产精品白丝jk白祙喷水网站| 婷婷综合在线观看| 日本不卡不码高清免费观看| 免费久久精品视频| 韩国一区二区三区| 国产福利精品导航| 99re在线视频这里只有精品| 91麻豆福利精品推荐| 在线影视一区二区三区| 欧美日韩亚洲另类| 日韩精品一区二区在线观看| 日韩免费电影网站| 国产精品素人视频| 一区二区三区在线免费视频| 亚洲香肠在线观看| 久久精品国产99国产精品| 精品一区二区免费视频| 波多野结衣视频一区| 欧美主播一区二区三区| 欧美一级xxx| 国产精品天天看| 亚洲午夜电影在线| 国产综合色在线| 91蜜桃在线免费视频| 欧美一区二区三区在线视频| 国产调教视频一区| 亚洲1区2区3区4区| 成人av网在线| 日韩精品一区二区三区蜜臀| 国产精品久久久久影院色老大| 亚洲成年人影院| 国产精品主播直播| 欧美日本一道本在线视频| 久久久精品免费网站| 亚洲综合精品久久| 成人丝袜高跟foot| 日韩精品自拍偷拍| 亚洲一区免费在线观看| 国产一区二区三区四| 欧美影院一区二区| 国产精品福利av| 美女网站视频久久| 欧美亚洲国产bt| 日本一二三不卡| 国产在线一区二区| 欧美日韩亚洲综合| 亚洲黄色尤物视频| 成人激情视频网站| 久久天天做天天爱综合色| 亚洲一区二区综合| 丁香婷婷综合网| 欧美一区二区三区系列电影| 亚洲色图视频网| 国产一区二区在线观看视频| 欧美精品乱人伦久久久久久| 一区二区三区精品在线观看| 成人综合婷婷国产精品久久免费| 91精品国产福利在线观看| 亚洲一区在线观看免费 | 欧美系列在线观看| 欧美国产激情二区三区| 精品一区二区三区影院在线午夜 | 欧美主播一区二区三区| 国产精品不卡在线观看| 国产精品一二三在| 久久精品男人的天堂| 国产精品自拍av| 久久亚洲精品小早川怜子| 蜜臀av国产精品久久久久| 欧美精品日韩综合在线| 三级亚洲高清视频| 91精品国产综合久久久久久| 日韩精品一区第一页| 欧美久久久一区| 日韩精品亚洲一区| 日韩欧美视频在线| 久久99日本精品| 精品精品欲导航| 国产乱码精品一区二区三 | 福利电影一区二区三区| 久久久久久久久99精品| 国产成人av一区二区三区在线| 久久夜色精品国产欧美乱极品| 麻豆91在线观看| 久久久电影一区二区三区| 成人精品视频一区| 亚洲精品一二三| 91精品国产乱| 国产精品夜夜爽| 中文字幕一区二区三区色视频| 色综合中文字幕国产 | 欧美性猛交一区二区三区精品| 亚洲一区二区视频在线| 日韩欧美在线综合网| 成人一级黄色片| 一区二区日韩电影| 精品久久国产老人久久综合| 不卡高清视频专区| 青青草原综合久久大伊人精品优势| 日韩欧美另类在线| 成人视屏免费看| 五月激情综合色| 日本一二三不卡| 欧美日韩1区2区| 成人精品一区二区三区四区| 亚洲18女电影在线观看| 国产欧美一区二区精品久导航| 色久优优欧美色久优优| 国产做a爰片久久毛片 | 91精品办公室少妇高潮对白| 美女视频网站久久| 亚洲免费观看高清完整版在线观看| 欧美日韩一区二区电影| 色婷婷av一区二区三区之一色屋| 秋霞影院一区二区| 亚洲欧美另类综合偷拍| 久久久九九九九| 欧美精三区欧美精三区| 91老师片黄在线观看| 国产一区二区伦理| 日韩福利视频导航| 一区二区三区欧美日| 亚洲国产精品精华液2区45| 欧美一区二区精美| 欧美天堂一区二区三区| 成人国产精品免费观看动漫| 久久成人免费网| 日韩av在线发布| 亚洲欧美激情小说另类| 日本一区二区动态图| 26uuu成人网一区二区三区| 欧美高清性hdvideosex| 欧美综合色免费| 色悠悠亚洲一区二区| www.久久久久久久久| 国产·精品毛片| 国产成人精品影院| 久久国产精品99精品国产| 日本视频一区二区三区| 日韩专区在线视频| 午夜欧美2019年伦理| 一区二区三区国产| 一区二区欧美精品| 亚洲最色的网站| 亚洲国产日韩精品| 亚洲一区二区视频| 午夜成人免费电影| 亚洲成人综合在线| 五月天婷婷综合| 美女在线观看视频一区二区| 免费在线观看视频一区| 美女尤物国产一区| 国内精品国产成人国产三级粉色| 久久成人久久爱| 国产成人免费xxxxxxxx| 成人午夜电影小说| 色婷婷综合中文久久一本| 在线中文字幕不卡| 欧美一区二区成人| www国产亚洲精品久久麻豆| 国产亚洲欧美日韩日本| 国产精品福利一区二区| 国产在线看一区| 成人性生交大片免费看在线播放| 成人午夜视频在线观看| 不卡av在线网| 欧美三级日本三级少妇99| 欧美一级一级性生活免费录像| 欧美成人bangbros| 国产精品护士白丝一区av| 一区二区三区免费| 另类小说图片综合网| 丁香五精品蜜臀久久久久99网站| 91久久精品一区二区三区| 欧美一区二区三区视频在线| 久久久久久久久久久久久女国产乱| 国产精品黄色在线观看| 日韩av电影天堂| 成人黄色在线看| 69成人精品免费视频| 国产精品三级电影| 日韩中文字幕av电影| 成人毛片视频在线观看| 在线观看91av| 国产人久久人人人人爽| 婷婷综合久久一区二区三区| 国产盗摄一区二区三区| 欧美日韩国产成人在线91| 欧美精品一区二区三区一线天视频| 亚洲欧美激情插| 国产乱国产乱300精品| 欧美精品久久久久久久久老牛影院| 久久久一区二区| 蜜桃av一区二区三区|