본문 바로가기

programming/C++

3. Hash Function에 의해 자료를 보관

App::App()
{
              arr.ExtendStorage(MAX_STU);
}


template <class T>
void MyVector<T>::reserve(int _capa)
{
          ExtendStorage(_capa);
}
App::InitCatamer()
{
          arr.ExtendStorage(MAX_STU):
          Stu **seek = arr.Begin();
          Stu **end = arr.End();
          for(         ;seek!= end; ++seek)
          {
                   (*seek)=0;
           }
}   

App:Insert
{
           Stu *s = ;
           ... //학생 개체 생성
           int index=0;
           index = HashFun(s);
           arr[index] = s;
}

App::Serch()
{
             //검색할 키 입력
             index = HashFun(key);
             //index가 유효
             arr[index]->View();     //cout<<arr[index]<<endl;
}

App::Delete()
{
          //삭제할 키 입력
          index = HashFun(key);
          delete arr[index];
          arr[index] =0;
}


App: ListAll()
{
          int i=0;
          for(i=0; i<MAX_STU; i++)
          {
                 if(arr[i])
                 {
                       cout<<arr[i]<<endl;
                  }
           }
}


App:: ~App()
{
          int i=0;
          for(i=0; i<MAX_STU; i++)
          {
                 if(arr[i])
                 {
                       delte arr[i];   //인덱스연산자 사용!!
                  }
           }
}

'programming > C++' 카테고리의 다른 글

MyVector!!!  (0) 2009.11.19
1. 순차보관  (0) 2009.11.19
2. 특정 키순으로 보관(complete)  (0) 2009.11.19
MyVector - 떡떡한배열2  (0) 2009.11.18
떡떡한 배열(?)  (0) 2009.11.17