-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCDN_Node.cpp
More file actions
42 lines (34 loc) · 1.21 KB
/
CDN_Node.cpp
File metadata and controls
42 lines (34 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "CDN_Node.hpp"
#include "Movie.hpp"
#include <iostream>
// Constructor
CDNNode::CDNNode(double x, double y, int skipListMaxLevel, float skipListProbability)
: x(x), y(y), popularMovies(skipListMaxLevel, skipListProbability) {}
// Getters
double CDNNode::getX() const {
return x;
}
double CDNNode::getY() const {
return y;
}
// Stores a popular movie in the CDN node's skip list
void CDNNode::storePopularMovie(Movie* movie) {
popularMovies.insert(movie);
// std::cout << "Stored popular movie: " << movie->getName() << " in CDN node (" << x << ", " << y << ")\n";
}
// Fetches a movie if it's in the CDN node's popular movie list
Movie* CDNNode::fetchMovie(const std::string& movieName) {
return popularMovies.search(movieName);
}
// Retrieves names of all movies in the CDN node's skip list
std::vector<std::string> CDNNode::get_movie_names() {
return popularMovies.getAllNames();
}
// Checks if the skip list has reached a maximum capacity (for example, 10 movies in this case)
bool CDNNode::isFull() {
return popularMovies.getsize() >= 10; // Assuming max capacity is 10 movies
}
void CDNNode::remove_mov(const std::string& moviename)
{
popularMovies.remove(moviename);
}