下面是本人使用C++封装的一个针对任意基础类型以及用户自定义类型指针的通用类型。目的是为方便常用类型使用统一化及便利化。该类型的使用就与平时使用基础类型基本没什么差别。具体可参看以下代码及测试代码。

 /******************************************************************************

                              I'm jacc.kim

     CreateDate: 2017-05-21 14:20:56
FileName : JKMsgDefine.h
Version : 1.00
Author : jacc.kim
Summary : 消息数据定义 ******************************************************************************/
#pragma once enum class eJKMsgDataValueType
{
eUndefined = , // 未定义类型
eChar = , // = char
eShort = , // = short
eInt = , // = int
eLong = , // = long
eInt64 = , // = long long eUChar = , // = unsigned char
eUShort = , // = unsigned short
eUInt = , // = unsigned int
eULong = , // = unsigned long
eUInt64 = , // = unsigned long long eFloat = , // = float
eDouble = , // = double eString = , // = string eCustom = , // = 用户自定义类型 };//enum class eJKMsgDataValueType
 /******************************************************************************

                              I'm jacc.kim

     CreateDate: 2017-05-22 09:30:36
FileName : JKMsgData.h
Version : 1.00
Author : jacc.kim
Summary : 消息数据类型定义 ******************************************************************************/
#pragma once #include <string>
#include <map> #include "JKMsgDefine.h" /******************************************************************************
* create : (jacc.kim) [05-21-2017]
* summary : class JKMsgDataValue.消息数据值类型
******************************************************************************/
class JKMsgDataValue
{
public:
JKMsgDataValue(const char v);
JKMsgDataValue(const short v);
JKMsgDataValue(const int v);
JKMsgDataValue(const long v);
JKMsgDataValue(const long long v); JKMsgDataValue(const unsigned char v);
JKMsgDataValue(const unsigned short v);
JKMsgDataValue(const unsigned int v);
JKMsgDataValue(const unsigned long v);
JKMsgDataValue(const unsigned long long v); JKMsgDataValue(const float v);
JKMsgDataValue(const double v); //JKMsgDataValue(const char* v);
JKMsgDataValue(const std::string& v); template<typename Tx>
JKMsgDataValue(Tx* pCustomPtr); template<typename Tx>
JKMsgDataValue(const Tx* pCustomPtr); template<>
JKMsgDataValue(char* pCustomPtr); template<>
JKMsgDataValue(const char* pCustomPtr); JKMsgDataValue(const JKMsgDataValue& v);
JKMsgDataValue& operator=(const JKMsgDataValue& v); ~JKMsgDataValue(); public:
char valueChar() const;
short valueShort() const;
int valueInt() const;
long valueLong() const;
long long valueLongLong() const; unsigned char valueUChar() const;
unsigned short valueUShort() const;
unsigned int valueUInt() const;
unsigned long valueULong() const;
unsigned long long valueULongLong() const; float valueFloat() const;
double valueDouble() const;
const std::string& valueString() const; template<typename Tx>
bool valueCustom(Tx*& pCustomPtr) const;
template<typename Tx>
Tx* valueCustom() const; template<typename Tx>
bool valueCustomConst(const Tx*& pCustomPtr) const;
template<typename Tx>
const Tx* valueCustomConst() const; //
// !!!note : 该版本不建议使用.功能上是可以强转为char*,但实际上,出于语言语义上的考虑,强行将一个const char*脱掉const特性
// ,在逻辑上是不合理的.因此,该版本的实现内部将直接返回空指针!!!
template<>
bool valueCustom(char*& pCustomPtr) const;
template<>
char* valueCustom() const; template<>
bool valueCustomConst(const char*& pCustomPtr) const;
template<>
const char* valueCustomConst() const; public:
operator char() const;
operator short() const;
operator int() const;
operator long() const;
operator long long() const; operator unsigned char() const;
operator unsigned short() const;
operator unsigned int() const;
operator unsigned long() const;
operator unsigned long long() const; operator float() const;
operator double() const;
operator const std::string&() const; template<typename Tx>
operator Tx*() const;
template<typename Tx>
operator const Tx*() const; //template<>
//operator char*() const;
//template<>
//operator const char*() const; public:
// 转换为字符串
bool toString(std::string& strOut) const;
bool toString(std::string& strOut, const unsigned int nDigits) const;
std::string toString() const;
std::string toString(const unsigned int nDigits) const; private:
void resetData(); private:
int m_eType;
union
{
char charData;
short shortData;
int intData;
long longData;
long long longlongData; unsigned char ucharData;
unsigned short ushortData;
unsigned int uintData;
unsigned long ulongData;
unsigned long long ulonglongData; float floatData;
double doubleData; std::string* stringData; // will be delete in destructor void* customData; // only reference.
const void* const_customData; // only reference.
} m_Data; };//class JKMsgDataValue
 #include <sstream>

 #include "src/GameCore/MsgDispatcher/JKMsgData.h"
#include "src/Common/GlobalDefine.h" ///////////////////////////////////////////////////////////////////////////////
// class JKMsgDataValue
JKMsgDataValue::JKMsgDataValue(const char v) {
this->resetData();
m_eType = static_cast<int>(eJKMsgDataValueType::eChar);
m_Data.charData = v;
} JKMsgDataValue::JKMsgDataValue(const short v) {
this->resetData();
m_eType = static_cast<int>(eJKMsgDataValueType::eShort);
m_Data.shortData = v;
} JKMsgDataValue::JKMsgDataValue(const int v) {
this->resetData();
m_eType = static_cast<int>(eJKMsgDataValueType::eInt);
m_Data.intData = v;
} JKMsgDataValue::JKMsgDataValue(const long v) {
this->resetData();
m_eType = static_cast<int>(eJKMsgDataValueType::eLong);
m_Data.longData = v;
} JKMsgDataValue::JKMsgDataValue(const long long v) {
this->resetData();
m_eType = static_cast<int>(eJKMsgDataValueType::eInt64);
m_Data.longlongData = v;
} JKMsgDataValue::JKMsgDataValue(const unsigned char v) {
this->resetData();
m_eType = static_cast<int>(eJKMsgDataValueType::eUChar);
m_Data.ucharData = v;
} JKMsgDataValue::JKMsgDataValue(const unsigned short v) {
this->resetData();
m_eType = static_cast<int>(eJKMsgDataValueType::eUShort);
m_Data.ushortData = v;
} JKMsgDataValue::JKMsgDataValue(const unsigned int v) {
this->resetData();
m_eType = static_cast<int>(eJKMsgDataValueType::eUInt);
m_Data.uintData = v;
} JKMsgDataValue::JKMsgDataValue(const unsigned long v) {
this->resetData();
m_eType = static_cast<int>(eJKMsgDataValueType::eULong);
m_Data.ulongData = v;
} JKMsgDataValue::JKMsgDataValue(const unsigned long long v) {
this->resetData();
m_eType = static_cast<int>(eJKMsgDataValueType::eUInt64);
m_Data.ulonglongData = v;
} JKMsgDataValue::JKMsgDataValue(const float v) {
this->resetData();
m_eType = static_cast<int>(eJKMsgDataValueType::eFloat);
m_Data.floatData = v;
} JKMsgDataValue::JKMsgDataValue(const double v) {
this->resetData();
m_eType = static_cast<int>(eJKMsgDataValueType::eDouble);
m_Data.doubleData = v;
} //JKMsgDataValue::JKMsgDataValue(const char* v) {
// this->resetData();
// if (nullptr == v) {
// m_eType = static_cast<int>(eJKMsgDataValueType::eUndefined);
// return;
// }
// m_eType = static_cast<int>(eJKMsgDataValueType::eString);
// m_Data.stringData = new std::string(v);
//} JKMsgDataValue::JKMsgDataValue(const std::string& v) {
this->resetData();
m_eType = static_cast<int>(eJKMsgDataValueType::eString);
m_Data.stringData = new std::string(v);
} JKMsgDataValue::JKMsgDataValue(const JKMsgDataValue& v) {
*this = v;
} JKMsgDataValue& JKMsgDataValue::operator=(const JKMsgDataValue& v) {
if (&v != this) {
m_eType = v.m_eType;
m_Data = v.m_Data;
if (static_cast<eJKMsgDataValueType>(m_eType) == eJKMsgDataValueType::eString) {
m_Data.stringData = new std::string(*v.m_Data.stringData);
}
}
return *this;
} JKMsgDataValue::~JKMsgDataValue() {
this->resetData();
} void JKMsgDataValue::resetData() {
if (static_cast<int>(eJKMsgDataValueType::eString) == m_eType) {
delete m_Data.stringData;
m_Data.stringData = nullptr;
}
} char JKMsgDataValue::valueChar() const {
return m_Data.charData;
} short JKMsgDataValue::valueShort() const {
return m_Data.shortData;
} int JKMsgDataValue::valueInt() const {
return m_Data.intData;
} long JKMsgDataValue::valueLong() const {
return m_Data.longData;
} long long JKMsgDataValue::valueLongLong() const {
return m_Data.longlongData;
} unsigned char JKMsgDataValue::valueUChar() const {
return m_Data.ucharData;
} unsigned short JKMsgDataValue::valueUShort() const {
return m_Data.ushortData;
} unsigned int JKMsgDataValue::valueUInt() const {
return m_Data.uintData;
} unsigned long JKMsgDataValue::valueULong() const {
return m_Data.ulongData;
} unsigned long long JKMsgDataValue::valueULongLong() const {
return m_Data.ulonglongData;
} float JKMsgDataValue::valueFloat() const {
return m_Data.floatData;
} double JKMsgDataValue::valueDouble() const {
return m_Data.doubleData;
} const std::string& JKMsgDataValue::valueString() const {
return *m_Data.stringData;
} JKMsgDataValue::operator char() const {
return this->valueChar();
} JKMsgDataValue::operator short() const {
return this->valueShort();
} JKMsgDataValue::operator int() const {
return this->valueInt();
} JKMsgDataValue::operator long()const {
return this->valueLongLong();
} JKMsgDataValue::operator long long() const {
return this->valueLongLong();
} JKMsgDataValue::operator unsigned char() const {
return this->valueUChar();
} JKMsgDataValue::operator unsigned short() const {
return this->valueUShort();
} JKMsgDataValue::operator unsigned int() const {
return this->valueUInt();
} JKMsgDataValue::operator unsigned long()const {
return this->valueULong();
} JKMsgDataValue::operator unsigned long long() const {
return this->valueULongLong();
} JKMsgDataValue::operator float() const {
return this->valueFloat();
} JKMsgDataValue::operator double() const {
return this->valueDouble();
} JKMsgDataValue::operator const std::string&() const {
return valueString();
} bool JKMsgDataValue::toString(std::string& strOut) const {
return this->toString(strOut, );
} bool JKMsgDataValue::toString(std::string& strOut, const unsigned int nDigits) const {
auto bIsSuccess = true; auto doubleToString = [](const double v, const int nDigits, std::stringstream& strOutOS) {
const auto nFormatSize = ;
char szFormatBuff[nFormatSize];
memset((void*)szFormatBuff, 0x0L, nFormatSize);
sprintf(szFormatBuff, "%%.%df", nDigits); const auto nSizeDouble = sizeof(double);
char szBuff[nSizeDouble];
memset((void*)szBuff, 0x0L, nSizeDouble);
sprintf(szBuff, szFormatBuff, v); strOutOS << szBuff;
}; std::stringstream os;
switch (static_cast<eJKMsgDataValueType>(m_eType)) {
case eJKMsgDataValueType::eChar : os << m_Data.charData; break; // = char
case eJKMsgDataValueType::eShort : os << m_Data.shortData; break; // = short
case eJKMsgDataValueType::eInt : os << m_Data.intData; break; // = int
case eJKMsgDataValueType::eLong : os << m_Data.longData; break; // = long
case eJKMsgDataValueType::eInt64 : os << m_Data.longlongData; break; // = long long case eJKMsgDataValueType::eUChar : os << m_Data.ucharData; break; // = unsigned char
case eJKMsgDataValueType::eUShort : os << m_Data.ushortData; break; // = unsigned short
case eJKMsgDataValueType::eUInt : os << m_Data.uintData; break; // = unsigned int
case eJKMsgDataValueType::eULong : os << m_Data.ulongData; break; // = unsigned long
case eJKMsgDataValueType::eUInt64 : os << m_Data.ulonglongData; break; // = unsigned long long case eJKMsgDataValueType::eFloat : doubleToString(m_Data.floatData, nDigits, os); break; // = float
case eJKMsgDataValueType::eDouble : doubleToString(m_Data.doubleData, nDigits, os); break; // = double case eJKMsgDataValueType::eString : os << m_Data.stringData->c_str(); break; // = string default : DDZAssert(false, "Convert error!"); bIsSuccess = false; break;
} if (bIsSuccess) {
os >> strOut;
} return bIsSuccess;
} std::string JKMsgDataValue::toString() const {
std::string strOut;
if (!this->toString(strOut)) {
strOut = "";
}
return strOut;
} std::string JKMsgDataValue::toString(const unsigned int nDigits) const {
std::string strOut;
if (!this->toString(strOut, nDigits)) {
strOut = "";
}
return strOut;
}
 #include "JKMsgDefine.h"

 ///////////////////////////////////////////////////////////////////////////////
// class JKMsgDataValue
template<typename Tx>
JKMsgDataValue::JKMsgDataValue(Tx* pCustomPtr) {
this->resetData();
m_eType = static_cast<int>(eJKMsgDataValueType::eUndefined);
if (nullptr != pCustomPtr) {
m_eType = static_cast<int>(eJKMsgDataValueType::eCustom);
m_Data.customData = static_cast<void*>(pCustomPtr);
}
} template<typename Tx>
JKMsgDataValue::JKMsgDataValue(const Tx* pCustomPtr) {
this->resetData();
m_eType = static_cast<int>(eJKMsgDataValueType::eUndefined);
if (nullptr != pCustomPtr) {
m_eType = static_cast<int>(eJKMsgDataValueType::eCustom);
m_Data.const_customData = static_cast<const void*>(pCustomPtr);
}
} template<>
JKMsgDataValue::JKMsgDataValue(char* pCustomPtr) {
this->resetData();
if (nullptr == pCustomPtr) {
m_eType = static_cast<int>(eJKMsgDataValueType::eUndefined);
return;
}
m_eType = static_cast<int>(eJKMsgDataValueType::eString);
m_Data.stringData = new std::string(pCustomPtr);
} template<>
JKMsgDataValue::JKMsgDataValue(const char* pCustomPtr) {
this->resetData();
if (nullptr == pCustomPtr) {
m_eType = static_cast<int>(eJKMsgDataValueType::eUndefined);
return;
}
m_eType = static_cast<int>(eJKMsgDataValueType::eString);
m_Data.stringData = new std::string(pCustomPtr);
} template<typename Tx>
bool JKMsgDataValue::valueCustom(Tx*& pCustomPtr) const {
auto bIsSuccess = false;
pCustomPtr = nullptr;
if (static_cast<eJKMsgDataValueType>(m_eType) == eJKMsgDataValueType::eCustom) {
pCustomPtr = static_cast<Tx*>(m_Data.customData);
bIsSuccess = true;
}
return bIsSuccess;
} template<typename Tx>
typename Tx* JKMsgDataValue::valueCustom() const {
Tx* pCustomPtr = nullptr;
if (!this->valueCustom(pCustomPtr)) {
pCustomPtr = nullptr;
}
return pCustomPtr;
} template<typename Tx>
bool JKMsgDataValue::valueCustomConst(const Tx*& pCustomPtr) const {
auto bIsSuccess = false;
pCustomPtr = nullptr;
if (static_cast<eJKMsgDataValueType>(m_eType) == eJKMsgDataValueType::eCustom) {
pCustomPtr = static_cast<const Tx*>(m_Data.const_customData);
bIsSuccess = true;
}
return bIsSuccess;
}
template<typename Tx>
typename const Tx* JKMsgDataValue::valueCustomConst() const {
const Tx* pCustomPtr = nullptr;
if (!this->valueCustomConst(pCustomPtr)) {
pCustomPtr = nullptr;
}
return pCustomPtr;
} template<>
bool JKMsgDataValue::valueCustom(char*& pCustomPtr) const {
auto bIsSuccess = false;
pCustomPtr = nullptr;
//if (static_cast<eJKMsgDataValueType>(m_eType) == eJKMsgDataValueType::eString) {
// const char* pConstCharPtr = m_Data.stringData->c_str();
// pCustomPtr = const_cast<char*>(pConstCharPtr);
// bIsSuccess = true;
//}
return bIsSuccess;
} template<>
char* JKMsgDataValue::valueCustom() const {
char* pCustomPtr = nullptr;
//if (!this->valueCustom(pCustomPtr)) {
// pCustomPtr = nullptr;
//}
return pCustomPtr;
} template<>
bool JKMsgDataValue::valueCustomConst(const char*& pCustomPtr) const {
auto bIsSuccess = false;
pCustomPtr = nullptr;
if (static_cast<eJKMsgDataValueType>(m_eType) == eJKMsgDataValueType::eString) {
pCustomPtr = m_Data.stringData->c_str();
bIsSuccess = true;
}
return bIsSuccess;
} template<>
const char* JKMsgDataValue::valueCustomConst() const {
const char* pCustomPtr = nullptr;
if (!this->valueCustomConst(pCustomPtr)) {
pCustomPtr = nullptr;
}
return pCustomPtr;
} template<typename Tx>
JKMsgDataValue::operator Tx*() const {
return this->valueCustom<Tx>();
} template<typename Tx>
JKMsgDataValue::operator const Tx*() const {
return this->valueCustomConst<Tx>();
} //template<>
//JKMsgDataValue::operator char*() const {
// auto pConstCharPtr = static_cast<const char*>(*this);
// return const_cast<char*>(pConstCharPtr);
//}
//
//template<>
//JKMsgDataValue::operator const char*() const {
// return this->valueCustomConst<char>();
//}

以下是测试代码。目前在 VS2013 中测试 Ok。

     std::list<JKMsgDataValue> listTest;

     JKMsgDataValue vChar                    = 'c';                                  // test ok.
listTest.emplace_back(vChar); // test ok.
JKMsgDataValue vShort = static_cast<short>(); // test ok.
listTest.emplace_back(vShort); // test ok.
JKMsgDataValue vInt = static_cast<int>(); // test ok.
listTest.emplace_back(vInt); // test ok.
JKMsgDataValue vLong = static_cast<long>(); // test ok.
listTest.emplace_back(vLong); // test ok.
JKMsgDataValue vLongLong = static_cast<long long>(); // test ok.
listTest.emplace_back(vLongLong); // test ok. JKMsgDataValue vUChar = static_cast<unsigned char>('b'); // test ok.
listTest.emplace_back(vUChar); // test ok.
JKMsgDataValue vUShort = static_cast<unsigned short>(); // test ok.
listTest.emplace_back(vUShort); // test ok.
JKMsgDataValue vUInt = static_cast<unsigned int>(); // test ok.
listTest.emplace_back(vUInt); // test ok.
JKMsgDataValue vULong = static_cast<unsigned long>(); // test ok.
listTest.emplace_back(vULong); // test ok.
JKMsgDataValue vULongLong = static_cast<unsigned long long>(); // test ok.
listTest.emplace_back(vULongLong); JKMsgDataValue fFloat = 10.1f; // test ok.
listTest.emplace_back(fFloat); // test ok.
JKMsgDataValue vDouble = 11.2; // test ok.
listTest.emplace_back(vDouble); // test ok. const double ddddddd1 = vDouble; // test ok.
const double ddddddd2 = (double)vDouble; // test ok.
const double ddddddd3 = double(vDouble); // test ok.
const double ddddddd4 = (double)(vDouble); // test ok. JKMsgDataValue vString_1 = "this is a string char*"; // test ok.
listTest.emplace_back(vString_1); // test ok.
JKMsgDataValue vString_2 = std::string("abc"); // test ok.
listTest.emplace_back(vString_2); // test ok. const std::string strTTTTTTTT1 = vString_2; // test ok.
const auto strTTTTTTTT2 = std::string(vString_2); // test ok.
const auto strTTTTTTTT3 = (std::string)vString_2; // test ok.
const auto strTTTTTTTT4 = (std::string)(vString_2); // test ok. JKMsgDataValue vv = 'm'; // test ok.
listTest.emplace_back(vv); // test ok.
vv = ; // test ok.
listTest.emplace_back(vv); // test ok.
vv = "jacc.kim"; // test ok.
listTest.emplace_back(vv); // test ok.
vv = 666.66; // test ok.
listTest.emplace_back(vv); // test ok. std::for_each(listTest.begin(),
listTest.end(),
[](const JKMsgDataValue& v){
std::string strOut;
const bool bIsSuccess = v.toString(strOut, ); // test ok.
CCLOG("-------- %s --------", strOut.c_str()); // test ok.
if (!bIsSuccess) {
int asdfasdf = ;
}
}); JKMsgDataValue vv2_0 = this; // test ok.
JKMsgDataValue vv2(this); // test ok.
HelloWorld* pThisObj = nullptr; // test ok.
if (vv2.valueCustom(pThisObj)) { // test ok.
int asfdasf = ; // test ok.
} // test ok. HelloWorld* pMyPtr = vv2; // test ok. const HelloWorld* pTestHelloWorld = this; // test ok.
JKMsgDataValue vv4 = pTestHelloWorld; // test ok.
auto pVV4 = static_cast<const HelloWorld*>(vv4); // test ok. char* pCharTest = "ak47"; // test ok.
JKMsgDataValue vv5 = pCharTest; // test ok.
auto pVV5 = static_cast<char*>(vv5); // test ok.
auto pVV5_2 = static_cast<const char*>(vv5); // test ok. char* pVV5_3 = nullptr;
vv5.valueCustom(pVV5_3); // test ok. const char* pVV5_4 = nullptr;
vv5.valueCustomConst(pVV5_4); // test ok. const char* pCharTestConst = "ak47";
JKMsgDataValue vv6 = pCharTestConst; // test ok.
auto pVV6 = static_cast<const char*>(vv6); // test ok.

以上如果有什么问题,欢迎大家指正、交流、共同探讨!

C++ Any 任意基础类型封装的更多相关文章

  1. salesforce 零基础学习(五十八)通过sObject的field返回其对应的基础类型

    项目中有时候会要求通过sObject的Field的type类型返回其对应的基本类型,然后对其进行相关的处理,创建sObject的field可以选择的type类型是固定多的. 上述类型可以转换成几种基本 ...

  2. TypeScript 素描-基础类型

    博文读自 TypeScript 官方文档而来,不具有学习性,仅是本人学习时记录以供日后翻阅 ,有学习TypeScript的朋友还请去看更为详细的官方文档 TypeScript官网文档中的基础类型, T ...

  3. Typescript基础类型

    1.布尔值__boolean 2.数字__number----除了支持十进制和十六进制字面量,Typescript还支持ECMAScript 2015中引入的二进制和八进制字面量. 3.字符串__st ...

  4. java基础-基础类型包装类型

    想要对基本类型数据进行更多的操作,最方便的方式就是将其封装成对象. 为啥呢?因为在对象描述中就可以定义更多的属性和行为对该基本数据类型进行操作. [八种基本数据类型的包装类] byte --Byte ...

  5. Java基础类型自动装箱(autoboxing)

    Java SE 1.5 版本及之后,开始提供自动装箱功能. 自动装箱,将基础类型“包装”成一种类型: 基本类型 -->  包装器类 如下过程可触发自动装箱过程: Integer count = ...

  6. TypeScript学习笔记之基础类型

    从今天开始学习typescript了,记录ts学习点滴,最后,使用ts结合nodejs开发后端应用,一起共勉吧: typescript最新版本2.6,所有演示代码均基于此版本 开始之前确定安装了如下n ...

  7. TypeScript基础类型,类实例和函数类型声明

    TypeScript(TS)是微软研发的编程语言,是JavaScript的超集,也就是在JavaScript的基础上添加了一些特性.其中之一就是类型声明. 一.基础类型 TS的基础类型有 Boolea ...

  8. Typescript学习笔记(一)基础类型

    为了面向ng2和前端未来,开始搞向ts,ts是微软出的一枚语言,作为es6的超集,他出的一些特性还是蛮好用的(略坑).对于我等纯前端(从开始就接触javascript)的人来说,真想说,这特么什么鬼. ...

  9. Java第三次作业——面向对象基础(封装)

    Java第三次作业--面向对象基础(封装) (一)学习总结 1.什么是面向对象的封装性,Java中是如何实现封装性的?试举例说明. 封装性 封装性是面向对象的方法所应遵循的一个重要原则,它有两个含义: ...

随机推荐

  1. GNU Readline 库及编程简介【转】

    转自:https://www.cnblogs.com/hazir/p/instruction_to_readline.html 用过 Bash 命令行的一定知道,Bash 有几个特性: TAB 键可以 ...

  2. 哈希表(一):解决hash冲突的几种方法

    (一)线性探测法 线性探测法是最简单的处理冲突的方法. (1)插入元素:插入元素时,如果发生冲突,算法将从该槽位向后遍历哈希表,直到找到表中的下一个空槽,并将该值放入到空槽当中. (2)查找元素:查找 ...

  3. python的时间和日期--time、datetime应用

    time >>> import time >>> time.localtime() #以time.struct_time类型,打印本地时间 time.struct_ ...

  4. PXC 避免加入集群时发生SST

    环境 现有集群节点: 192.168.99.210:3101 新加入节点: 192.168.99.211:3101 通过xtrabackup备份还原实例,并通过同步方式追数据: 已有节点情况: roo ...

  5. dev....把pivotgridview和chart一起导出

    首先~: 命名空间: using DevExpress.XtraPrinting;using DevExpress.XtraCharts.Native;using DevExpress.XtraPri ...

  6. [New learn]响应者链机制介绍

    1.简介  测试代码库:https://github.com/xufeng79x/EventHandler 响应者链是系统寻找事件相应者的一个路径,他是同touch事件的Hit-testing过程具有 ...

  7. 后台传入的boolean类型到前台alert为String类型了(解决方法)

    后台代码: // 进入仪器list界面之前查看 是否是科研处人员        SessionContainer sc = (SessionContainer) session.getAttribut ...

  8. react表单提交

    class FlavorForm extends React.Component { constructor(props) { super(props); this.state = {value: ' ...

  9. 【JBPM4】完成任务

    示例代码: ProcessEngine processEngine = Configuration.getProcessEngine(); TaskService taskService = proc ...

  10. javascript大神修炼记(3)——条件分支

    读者朋友们好,我们今天接着前面的讲,前面已经大概了讲了一下运算符,今天的任务主要就是讲解逻辑条件分支,循环. 我们先就来模拟一个逻辑块,就用我们经常接触到的买车票来说吧,车票的价格对不同的人价格是有差 ...