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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? stringset.cpp

?? 基于MFC和STL平臺(tái)的字符串類
?? CPP
字號(hào):
// 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)(m_nSize + 1) )
       )
        bRetVal = (CStringArray::Add( pszWord ) >= 0) ;

    return bRetVal ;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// add a single word from a CString (preserves reference counting)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool CIVStringSet::Add( const CString & rstrWord )
{
    bool bRetVal = false ;

    // Insert the word into the FSM, then add it to the array
    if ( InsertWord( (LPCTSTR)rstrWord, (WORD)(m_nSize + 1) ) )
        bRetVal = (CStringArray::Add( rstrWord ) >= 0) ;

    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
    CString strUnparsed( pszWords ),
            strToken ;

    // stop iterating when we find no more words following delimiters
    while ( ! strUnparsed.IsEmpty() )
    {
        // Extract the first token
        strToken = strUnparsed.SpanExcluding( pszDelims ) ;
        if ( ! strToken.IsEmpty() )
        {
            if ( Add( strToken ) )  // add it to the FSM and the array
                nCount++ ;
            else
                break ;
        }

        // Now, move beyond the token just extracted
        int nTokenLen = strToken.GetLength() ;
        if ( nTokenLen < strUnparsed.GetLength() )
            strUnparsed = strUnparsed.Mid( nTokenLen ) ;
        else
            break ;

        // Remove the delimiters
        strUnparsed.TrimLeft( pszDelims ) ;
    }

    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 a CStringArray
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int CIVStringSet::Add( CStringArray astrWords )
{
    int nCount = astrWords.GetSize() ;
    SetSize( m_nSize + nCount ) ;

    for ( int 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 CStringList
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int CIVStringSet::Add( CStringList lstrWords )
{
    int nCount = lstrWords.GetCount() ;
    SetSize( m_nSize + nCount ) ;

    // Iterate the string list
    POSITION pos = lstrWords.GetHeadPosition() ;
    while ( pos != NULL )
    {
        if ( ! Add( lstrWords.GetNext( pos ) ) )  // 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( CString 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 nStartChar = 0xFFFFFFFF ;
    size_t nLen = m_strSearch.GetLength() ;

    // Start with the character following the last one examined
    for ( UINT 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 < GetSize());
            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( CString 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() ;
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99免费精品视频| 欧美v日韩v国产v| 国产 日韩 欧美大片| 久久精品国产99国产| 秋霞电影一区二区| 日韩电影一二三区| 秋霞影院一区二区| 久久精品国内一区二区三区| 麻豆成人91精品二区三区| 喷水一区二区三区| 欧美一级在线视频| 日韩欧美色电影| 成人性生交大片免费| 日欧美一区二区| 一区二区三区在线观看动漫| 综合久久一区二区三区| 综合激情网...| 亚洲精品综合在线| 亚洲小少妇裸体bbw| 天天影视色香欲综合网老头| 亚洲第一电影网| 蜜臀久久99精品久久久久久9 | 91视频在线看| 色94色欧美sute亚洲13| 欧美性受xxxx黑人xyx性爽| 精品视频1区2区| 欧美一区二区三区男人的天堂| 日韩你懂的在线观看| 久久精品一区二区三区不卡| 欧美韩国日本不卡| 亚洲欧美一区二区不卡| 亚洲第一主播视频| 丝袜美腿高跟呻吟高潮一区| www.av亚洲| 国产精品一区二区久久不卡 | 日韩一区二区电影在线| 日韩欧美在线影院| 欧美变态口味重另类| 国产精品午夜电影| 亚洲欧美日韩中文播放| 日韩主播视频在线| 国产最新精品免费| 94-欧美-setu| 欧美一区二区三区色| 久久精品视频网| 亚洲黄色在线视频| 久久www免费人成看片高清| 成人午夜视频网站| 久久久久久9999| 一区二区三区四区蜜桃| 久久国产综合精品| 97久久超碰国产精品电影| 337p亚洲精品色噜噜| 国产偷国产偷精品高清尤物| 国产精品日韩成人| 国产成人在线影院| 久久99久久99| 一本久久综合亚洲鲁鲁五月天| 91精品国产入口在线| 国产蜜臀97一区二区三区| 亚洲一级电影视频| 国产福利视频一区二区三区| 在线观看欧美黄色| 国产婷婷一区二区| 五月天国产精品| 97久久精品人人做人人爽| 日韩小视频在线观看专区| 亚洲欧洲成人精品av97| 美女一区二区三区| 色偷偷久久一区二区三区| 精品裸体舞一区二区三区| 一区二区久久久| 成人激情小说乱人伦| 欧美一级欧美一级在线播放| 一区在线观看视频| 久久疯狂做爰流白浆xx| 欧美曰成人黄网| 国产精品毛片大码女人| 九九久久精品视频| 在线免费观看日本一区| 国产精品午夜久久| 美女视频一区二区三区| 欧美亚洲精品一区| 国产精品日韩精品欧美在线| 精品在线你懂的| 欧美日本高清视频在线观看| 1024精品合集| 风流少妇一区二区| 欧美mv和日韩mv国产网站| 亚洲v日本v欧美v久久精品| 99热在这里有精品免费| 久久久久久久久久电影| 国产精品一区二区x88av| 日韩视频一区二区在线观看| 一区免费观看视频| 精品伊人久久久久7777人| 欧美日韩高清一区二区不卡| 亚洲色图丝袜美腿| 成人一级片在线观看| 久久综合久色欧美综合狠狠| 日本欧美加勒比视频| 欧美日韩在线一区二区| 一区二区三区在线高清| 91网址在线看| 精品一区二区三区免费观看| 欧美一区二区三区公司| 午夜欧美在线一二页| 欧美三区免费完整视频在线观看| 亚洲另类色综合网站| 91丨porny丨中文| 亚洲日韩欧美一区二区在线| 99精品久久免费看蜜臀剧情介绍| 国产精品久久二区二区| 99久久99久久久精品齐齐| 中文字幕一区二区日韩精品绯色| 成人免费视频网站在线观看| 国产精品日韩成人| 99久久精品国产精品久久| 亚洲视频在线观看一区| 色老汉一区二区三区| 亚洲一区二区精品久久av| 欧美视频精品在线观看| 日本三级亚洲精品| 中文av一区二区| 成人动漫中文字幕| 中文字幕一区二区三区在线观看| www.亚洲在线| 亚洲激情六月丁香| 欧美日韩在线精品一区二区三区激情 | 亚洲电影你懂得| 欧美一区二区在线视频| 精品夜夜嗨av一区二区三区| 久久久久久久久久久久久女国产乱 | 日韩激情一区二区| 日韩一区二区电影| 国产成人午夜电影网| 国产精品国产三级国产普通话蜜臀 | 一区二区三区中文在线观看| 欧美日韩一区二区不卡| 蜜桃久久久久久| 中文字幕乱码一区二区免费| 色婷婷久久久久swag精品 | 93久久精品日日躁夜夜躁欧美| 亚洲国产cao| 亚洲午夜av在线| 婷婷一区二区三区| www.亚洲免费av| 日韩欧美在线不卡| 日韩午夜电影av| 欧美中文字幕一区| 国产亚洲精品7777| 99久久免费视频.com| 一区二区在线电影| 精品国产乱码久久久久久1区2区| av午夜一区麻豆| 爽好多水快深点欧美视频| 精品成a人在线观看| 91偷拍与自偷拍精品| 午夜精品久久久久久久久久久| 精品国产乱码久久久久久1区2区| 一本到高清视频免费精品| 美腿丝袜在线亚洲一区| 国产精品国产三级国产专播品爱网 | 972aa.com艺术欧美| 免费一级片91| 亚洲图片欧美激情| 欧美mv日韩mv国产网站app| 国产成人亚洲综合a∨猫咪| 一二三四区精品视频| 日韩高清不卡一区二区三区| 国产欧美日本一区视频| 精品视频一区 二区 三区| 国产精品一区二区三区99| 午夜久久福利影院| 国产精品久久久久毛片软件| 欧美一级淫片007| 91福利国产精品| 国产福利一区二区三区| 日韩黄色一级片| 亚洲激情图片qvod| 欧美激情一区三区| 日韩美女在线视频 | 日韩一区二区在线看| 92精品国产成人观看免费| 国产一区二区免费视频| 丝袜a∨在线一区二区三区不卡| 一区精品在线播放| 久久久亚洲高清| 日韩一区二区在线观看视频播放| 在线亚洲高清视频| av成人老司机| 国产成人免费高清| 久久99国产精品久久| 亚洲成人福利片| 一区二区三区色| 亚洲三级免费观看| 亚洲欧洲99久久| 亚洲少妇中出一区| 国产精品入口麻豆原神| 欧美高清在线一区二区|