Gator Library
An implementation of the Red-Black Tree and Priority queue data structure in C++.
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
GatorLibrary Class Reference

The GatorLibrary class represents a library system.This class provides functionality to manage books in the library, including inserting, borrowing, returning, and deleting books. It also provides functions to print book information, count color flips in the red-black tree, and find the closest book to a given book ID. More...

#include <gator_library.hpp>

Collaboration diagram for GatorLibrary:
Collaboration graph

Public Member Functions

void PrintBook (int bookID)
 Display the book details.
 
void PrintBooks (int bookID1, int bookID2)
 Display the book details for all books in the range.
 
void InsertBook (int bookID, string bookName, string authorName, string availabilityStatus)
 Insert a new book into the library.
 
bool BorrowBook (int patronID, int bookID, int patronPriority)
 Borrow a book from the library.
 
void ReturnBook (int patronID, int bookID)
 Return a book to the library.
 
void DeleteBook (int bookID)
 Delete a book from the library.
 
void ColorFlipCount ()
 Display the number of color flips in the red black tree.
 
void FindClosestBook (int targetId)
 Find the book Id closest to the targetId.
 

Private Attributes

rbtree rbtBooks
 

Detailed Description

The GatorLibrary class represents a library system.

This class provides functionality to manage books in the library, including inserting, borrowing, returning, and deleting books. It also provides functions to print book information, count color flips in the red-black tree, and find the closest book to a given book ID.

Member Function Documentation

◆ BorrowBook()

bool GatorLibrary::BorrowBook ( int  patronID,
int  bookID,
int  patronPriority 
)

Borrow a book from the library.

Parameters
patronIDInteger.
bookIDInteger.
patronPriorityInteger.
Returns
True if the book is borrowed, false otherwise.

If the book is not available, add the reservation to the book's reservation heap. Reservation heap is a priority queue of reservations.

Here is the caller graph for this function:

◆ ColorFlipCount()

void GatorLibrary::ColorFlipCount ( )

Display the number of color flips in the red black tree.

Color flip count is the number of times the color of a node is flipped from red to black or vice versa.

Here is the caller graph for this function:

◆ DeleteBook()

void GatorLibrary::DeleteBook ( int  bookID)

Delete a book from the library.

Parameters
bookIDInteger.

If the book is borrowed, the reservation is cancelled for all the patrons.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindClosestBook()

void GatorLibrary::FindClosestBook ( int  targetId)

Find the book Id closest to the targetId.

Parameters
targetIdInteger.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InsertBook()

void GatorLibrary::InsertBook ( int  bookID,
string  bookName,
string  authorName,
string  availabilityStatus 
)

Insert a new book into the library.

Parameters
bookIDString.
bookNameString.
authorNameString.
availabilityStatusString.
Here is the caller graph for this function:

◆ PrintBook()

void GatorLibrary::PrintBook ( int  bookID)

Display the book details.

Parameters
bookIDInteger.
Here is the caller graph for this function:

◆ PrintBooks()

void GatorLibrary::PrintBooks ( int  bookID1,
int  bookID2 
)

Display the book details for all books in the range.

Parameters
bookID1
bookID2
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReturnBook()

void GatorLibrary::ReturnBook ( int  patronID,
int  bookID 
)

Return a book to the library.

Parameters
patronIDInteger.
bookIDInteger.

If the book is reserved, the book is borrowed by the next patron in the reservation heap.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ rbtBooks

rbtree GatorLibrary::rbtBooks
private

The documentation for this class was generated from the following files: