programming/C++

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

설은 2009. 11. 19. 20:21

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];   //인덱스연산자 사용!!
                  }
           }
}