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

📄 stlsubst.h

📁 伯克利做的SFTP安全文件传输协议
💻 H
字号:
// stlsubst.h// my substitutes for STL, for crypto++// idea is to have the absolute minimum that crypto++//   uses, to ease porting burden// copyright SafeTP Development Group, Inc., 2000  Terms of use are as specified in license.txt#ifndef __STLSUBST_H#define __STLSUBST_H#include "typ.h"       // bool// --------------------- pair ----------------------------------// struct with two fieldstemplate <class T1, class T2>struct pair {    T1 first;    T2 second;    pair() {}    pair(const T1& a, const T2& b) : first(a), second(b) {}};#if 0     // crypto++ doesn't use thesetemplate <class T1, class T2>inline bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y) {    return x.first == y.first && x.second == y.second;}template <class T1, class T2>inline bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y) {    return x.first < y.first || (!(y.first < x.first) && x.second < y.second);}template <class T1, class T2>inline pair<T1, T2> make_pair(const T1& x, const T2& y) {    return pair<T1, T2>(x, y);}#endif // 0// ------------------- vector ------------------------// array#define STDVECTOR vector     // instead of 'std::vector'template <class T>class vector {private:        // data  T *data;  int size;public:  vector(int s=0) : data(new T[max(s,1)]), size(s) {}  ~vector() { delete[] data; }  T& operator[] (int i) { return data[i]; }  T const& operator[] (int i) const { return data[i]; }  void resize(int newsize);};template <class T>void vector<T>::resize(int newsize){  // make new storage  T *newdata = new T[newsize];  // copy the elements stored in both  for (int i=0; i<min(size,newsize); i++) {    newdata[i] = data[i];  }  // free old storage  delete[] data;  // replace old with new  data = newdata;  size = newsize;}// ---------------------- swap ---------------------// wouldn't have to do this if g++ didn't suck#define SWAPCODE(T)   \{                     \  T temp = a;         \  a = b;              \  b = temp;           \}#define STDSWAP _sm_swaptemplate <class T>inline void _sm_swap(T &a, T &b)  SWAPCODE(T)// explicit instantiation to avoid problems where the compiler// wants to think that T is a const type, and therefore uses// temporaries, defeating the swap// because G++ SUCKS, I must write out the codeinline void _sm_swap(unsigned int *&a, unsigned int *&b)  SWAPCODE(unsigned int*)inline void _sm_swap(unsigned short *&a, unsigned short *&b)  SWAPCODE(unsigned short*)#endif // __STLSUBST_H

⌨️ 快捷键说明

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