listex.h

来自「信使小精灵,是一个简易的聊天工具。主要是演示了网络编程的主要步骤。本程序使用封装」· C头文件 代码 · 共 68 行

H
68
字号
//ListEx.h
#ifndef _LIST_EX_H_
#define _LIST_EX_H_
///////////////////////////////////////////////////////////////////////////////
/*///////////////////////////////////////////////////////////////////////////* /
#if defined(__cplusplus)
extern "C" {
#endif
/*///////////////////////////////////////////////////////////////////////////*/
///////////////////////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
/////////////////////////////////////////////
/////////////////////////////////////////////
#pragma warning(disable: 4786)

#include <map>
#include <list>
#include <string>
using namespace std;
////////////////////////////////////////////
#define nil 0
////////////////////////////////////////////
////////////////////////////////////////////
//template
//Key(char*)	-- You can use a data type such as char* as a Key
//Value(class)	-- You can use a self-define type such as class as a Value
template< typename Key, typename Value >
class CListEx {

public:
	CListEx(long size=0);
	virtual ~CListEx();

public:
	virtual void insert(Key key,Value value);
	virtual void push(Key key,Value value);
	virtual void remove(Key key);
	virtual void remove_all();
	virtual void clear();
	virtual void erase(Key key);
	virtual bool find(Key key, Value& value);
	virtual long count();
	virtual Value operator[](long index);

private:
	virtual bool get(Key &key,Value &value,long index);


private:
	map<Key,Value> m_map;
};


///////////////////////////////////////////////////////////////////////////////
typedef long Key;
typedef void * Value;
typedef CListEx<Key, Value>		LongVoidLists;
///////////////////////////////////////////////////////////////////////////////
/*///////////////////////////////////////////////////////////////////////////* /
#if defined(__cplusplus)
}
#endif
/*///////////////////////////////////////////////////////////////////////////*/
///////////////////////////////////////////////////////////////////////////////
#endif //_LIST_EX_H_

⌨️ 快捷键说明

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