⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 map.h

📁 Windows CE .Net 下面 DIRECT SOUND编程的经典实例。对于初学Windows 平台下DIRECT SOUND编程技术的程序员颇具借鉴意义!
💻 H
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//

//==========================================================================;
//
//  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
//  PURPOSE.
//
//
//--------------------------------------------------------------------------;

#ifndef __MAP_H__
#define __MAP_H__

// class static_map<>
// ==================
template <class TKey, class Ty>
class static_map 
{
public:
    class _elem
    {
    public:
        TKey first;
        Ty second;

        _elem(TKey _first, Ty _second) 
            : first(_first), second(_second) 
        {}
    };

    typedef TKey key_type;
    typedef _elem value_type;
    typedef const value_type* const_iterator;
    typedef static_map<TKey,Ty> this_type;

    static_map(const_iterator _begin, const_iterator _end)
        : m_pBegin(_begin), m_pEnd(_end) { ASSERT(_end>=_begin); }

    static_map(const this_type& sm)
        : m_pBegin(sm.m_pBegin), m_pEnd(sm.m_pEnd) {}

    const_iterator begin() const { return m_pBegin; }
    const_iterator end() const { return m_pEnd; }

    const Ty operator[](key_type key) const
    {
        for(const_iterator itr=begin();
            itr!=end();
            itr++)
            if (itr->first==key)
                return itr->second;        
        return (Ty) NULL;
    }
protected:
    const_iterator m_pBegin, m_pEnd;
};


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -