Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client & file table ds #1

Open
gilayalon opened this issue Jan 5, 2013 · 1 comment
Open

client & file table ds #1

gilayalon opened this issue Jan 5, 2013 · 1 comment

Comments

@gilayalon
Copy link
Owner

Create a data structure to manage available clients & files.

@gilayalon
Copy link
Owner Author

Use a binary search tree for the file table (ordered by name).
Use a hash table for the client lists.


| filename | client list |

Each client is a struct with fields ip & port.

Operations:
(n = file count, m = client count)

  1. DIR - The file list contains only files that are 'online', so just send the list to the client. O(n)
  2. GET - Find the requested file in the list, randomly select a client for download. O(logn)
  3. CONNECT - Loop through the client file list, marking each available file. If the file is 'online', add the client to the file's client list (can be done during the search); Else, insert the file at the end. O(m'logm)
  4. DISCONNECT - Loop through the file list. For each file, search the client list for the disconnecting client. If it exists, delete it. If the client list is empty, delete the file. O(m)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant