A Complete Guide to Programming in C++ part 69

A Complete Guide to Programming in C++ part 69. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | EXERCISES 659 Exercise 2 A hash file is required for speed of access to customer concept of hash files is explained on the opposite keep things simple each record in the hash file contains only a customer id and a customer id is the key used by the hash function opposite to compute the address of the record. Use linear solution as collision resolution technique. Note Linear solution provides for adequate access times if the address space is sufficiently large and not too full. It is also important to distribute the record numbers yielded by the hash function evenly throughout the available address hash function opposite will guarantee a good distribution if b is a sufficiently large prime number. Develop the HashEntry class used to represent customer need to store the customer id as an unsigned long value and the name of the customer as a char array with a length of 30. Supply default values for the constructor declaration and additionally declare the read_at and write_at methods that read customer information at a given position in a stream or write information at that position. Both methods expect the position and the stream as arguments. Define the HashFile class to represent a hash private members of the class comprise an fstream type file stream a string used to store the file name an int variable used to store the number b and the hash function shown opposite as a public members comprise a constructor that expects a file name and a number b as arguments. It opens the corresponding file for read and write destructor closes the file. Additionally declare the methods insert and retrieve to insert or retrieve single records. Both methods use a call to the hash function to compute the appropriate record number in the hash file. If a collision occurs the methods perform a sequential search to locate the next free slot in the address space mod of address space size or the desired customer .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.