tailieunhanh - A Complete Guide to Programming in C++ part 70

A Complete Guide to Programming in C++ part 70. 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. | SOLUTIONS 669 void IndexFile display throw ReadError IndexEntry entry OL if index throw ReadError IndexFile Setting the get pointer cout endl The Index endl while true if index break if throw ReadError name long IndexFile search long k throw ReadError IndexEntry entry long key long mid begin 0 end Number of file records. int size Length of an index entry. 0L ios end end size if index throw ReadError name if end 0 return -1 end - 1 Position of the last entry while begin end mid begin end 1 2 index mid size if index throw ReadError name key if k key end mid - 1 else begin mid 670 CHAPTER 29 MORE ABOUT FILES index begin size if index throw ReadError name if k Key found return begin size else return -1 void IndexFile insert long k long n throw ReadError WriteError IndexEntry entry int size Length of an index entry. 0 ios end long nr Get file length 0 if file is empty. if index throw ReadError name nr - size Last entry. bool found false while nr 0 found Search position to insert if index nr throw ReadError name if k To shift. index nr size nr - size else found true k n Insert index nr size if index throw WriteError name SOLUTIONS 671 void IndexFile retrieve IndexEntry entry long pos throw ReadError if index pos throw ReadError name ----------------------------------------------------- Implementing the methods of class IndexFileSystem. bool IndexFileSystem insert Accounts acc throw ReadError WriteError if search -1 No multiple entries. long pos append acc Add to primary file. IndexFile insert pos Add to Index return true else return false Account IndexFileSystem retrieve long key Get the record address from the index long pos .

TỪ KHÓA LIÊN QUAN