📄 array.h,v
字号:
head 1.1;access;symbols;locks zaki:1.1; strict;comment @ * @;1.1date 2001.06.12.16.41.58; author zaki; state Exp;branches;next ;desc@Charm with Hashing.@1.1log@Initial revision@text@#ifndef __ARRAY_H#define __ARRAY_H#include <iostream.h>const float grow = 2;template <class Items>class Array{private: int theSz; int totSz; Items *theAry;public: Array(int sz, Items *ary); Array(int sz=2); Array(Array<Items> *ary); ~Array(); void copy (Array<Items> *ary); void Realloc(int newlen); void compact(int nsz=-1); void add(Items it); void optadd(Items it){ theAry[theSz++] = it; } Items *& array(){ return theAry; } void reset(){ theSz = 0; } int& size(){ return theSz; } int& totsize(){ return totSz; } Items& operator [] (int index){ return theAry[index]; } int compare(Array<Items> *a2); int subset(Array<Items> * ar); //int subset(Array<int> * ar); int search(Items key) { int head=0; int tail=theSz-1,mid; while(head <= tail) { mid=(head+tail); if(theAry[mid] == key) return mid; if(theAry[mid] < key) head=mid+1; else tail=mid-1; } return -1; } friend ostream& operator << (ostream& fout, Array<Items>& ary);};#endif //__ARRAY_H@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -