Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. hash trouble

hash trouble

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabasecryptographyquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sirrius
    wrote on last edited by
    #1

    Here is the whole code: I should of put it out here to begin with on my previous forum. I tends to generate an error c2783 on the find_index() call in the insert funtion. Is it the way I am sending the struct in the main to the insert fucntion? I don't know. Very frustrated with this. I put void main() on the bottom of this page. Thanks for the help. #ifndef TABLE1_H #define TABLE1_1 #include #include const size_t CAPACITY = 811; int NEVER_USED = -1; int PREVIOUSLY_USED = -2; struct tractor { int key; }; template class table { //MEMBER CONSTANTS private: //MEMBER VARIABLES recordType data[CAPACITY]; size_t used; //HELPER FUNCTIONS template size_t hash(const recordType key) const { return (key % CAPACITY); } size_t next_index(size_t index) const { if((index+1)==CAPACITY) return ((index + 1) % CAPACITY); } template void find_index(int key, bool &found, std::size_t &index) const { size_t count; //number of entries that have been examined count = 0; i=hash(key); while((count= 0); //SET INDEX SO THAT DATA[INDEX] IS THE SPOT TO PLACE THE NEW ENTRY find_index(entry.key,already_present,index); //IF THE KEY WASN'T ALREADY THERE, THEN FIND THE LOCATION FOR THE NEW ENTRY. if(!already_present) { assert(size() < CAPACITY); index = hash(entry); while(!is_vacant(index)) index = next_index(index); ++used; } data[index] = entry; } /*template*/ void remove(int key) { bool found; std::size_t index; //SPOT WHERE DATA[INDEX].KEY==KEY assert(key >= 0); find_index(key,found,index); if(found) { //THE KEY WAS FOUND SO REMOVE THIS RECORD AND REDUCE USED BY 1 data[index].key = PREVIOUSLY_USED; //INDICATES A SPOT THATS NO LONGER IN USE --used; } } //CONSTANT MEMBER FUNCTIONS /*template

    Z 1 Reply Last reply
    0
    • S Sirrius

      Here is the whole code: I should of put it out here to begin with on my previous forum. I tends to generate an error c2783 on the find_index() call in the insert funtion. Is it the way I am sending the struct in the main to the insert fucntion? I don't know. Very frustrated with this. I put void main() on the bottom of this page. Thanks for the help. #ifndef TABLE1_H #define TABLE1_1 #include #include const size_t CAPACITY = 811; int NEVER_USED = -1; int PREVIOUSLY_USED = -2; struct tractor { int key; }; template class table { //MEMBER CONSTANTS private: //MEMBER VARIABLES recordType data[CAPACITY]; size_t used; //HELPER FUNCTIONS template size_t hash(const recordType key) const { return (key % CAPACITY); } size_t next_index(size_t index) const { if((index+1)==CAPACITY) return ((index + 1) % CAPACITY); } template void find_index(int key, bool &found, std::size_t &index) const { size_t count; //number of entries that have been examined count = 0; i=hash(key); while((count= 0); //SET INDEX SO THAT DATA[INDEX] IS THE SPOT TO PLACE THE NEW ENTRY find_index(entry.key,already_present,index); //IF THE KEY WASN'T ALREADY THERE, THEN FIND THE LOCATION FOR THE NEW ENTRY. if(!already_present) { assert(size() < CAPACITY); index = hash(entry); while(!is_vacant(index)) index = next_index(index); ++used; } data[index] = entry; } /*template*/ void remove(int key) { bool found; std::size_t index; //SPOT WHERE DATA[INDEX].KEY==KEY assert(key >= 0); find_index(key,found,index); if(found) { //THE KEY WAS FOUND SO REMOVE THIS RECORD AND REDUCE USED BY 1 data[index].key = PREVIOUSLY_USED; //INDICATES A SPOT THATS NO LONGER IN USE --used; } } //CONSTANT MEMBER FUNCTIONS /*template

      Z Offline
      Z Offline
      ZoogieZork
      wrote on last edited by
      #2

      Just a guess, based on the error code -- when you call find_index, you need to specify the template argument, e.g.: find_index<tractor>( ... ). In many cases, the compiler will attempt to deduce the template argument based on the types of data you pass to it, but it can't in this case. - Mike

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups