#include
#include
#include “concurrenthashtable.h”
/// A bucket_t is a lockable unordered_map of key/value pairs
template
// INSTRUCTOR NOTE: YOU WILL NEED TO ADD FIELDS TO THIS STRUCT
};
/// Construct a concurrent hash table by specifying the number of buckets it
/// should have
///
/// @param _buckets The number of buckets in the concurrent hash table
template
ConcurrentHashTable
: num_buckets(_buckets) {
std::cout << "ConcurrentHashTable constructor is not implemented"
<< std::endl;
}
/// Clear the Concurrent Hash Table. This operation needs to use 2pl
template
std::cout << "clear is not implemented" << std::endl;
}
/// Insert the provided key/value pair only if there is no mapping for the key
/// yet.
///
/// @param key The key to insert
/// @param val The value to insert
///
/// @return true if the key/value was inserted, false if the key already
/// existed in the table
template
bool ConcurrentHashTable
std::cout << "insert is not implemented" << std::endl;
return false;
}
/// Insert the provided key/value pair if there is no mapping for the key yet.
/// If there is a key, then update the mapping by replacing the old value with
/// the provided value
///
/// @param key The key to upsert
/// @param val The value to upsert
///
/// @return true if the key/value was inserted, false if the key already
/// existed in the table and was thus updated instead
template
bool ConcurrentHashTable
std::cout << "upsert is not implemented" << std::endl;
return false;
}
/// Apply a function to the value associated with a given key. The function
/// is allowed to modify the value.
///
/// @param key The key whose value will be modified
/// @param f The function to apply to the key's value
///
/// @return true if the key existed and the function was applied, false
/// otherwise
template
bool ConcurrentHashTable
std::cout << "do_with is not implemented" << std::endl;
return false;
}
/// Apply a function to the value associated with a given key. The function
/// is not allowed to modify the value.
///
/// @param key The key whose value will be modified
/// @param f The function to apply to the key's value
///
/// @return true if the key existed and the function was applied, false
/// otherwise
template
bool ConcurrentHashTable
K key, std::function
std::cout << "do_with_readonly is not implemented" << std::endl;
return false;
}
/// Remove the mapping from a key to its value
///
/// @param key The key whose mapping should be removed
///
/// @return true if the key was found and the value unmapped, false otherwise
template
bool ConcurrentHashTable
std::cout << "remove is not implemented" << std::endl;
return false;
}
/// Apply a function to every key/value pair in the ConcurrentHashTable. Note
/// that the function is not allowed to modify keys or values.
///
/// @param f The function to apply to each key/value pair
/// @param then A function to run when this is done, but before unlocking...
/// useful for 2pl
template
void ConcurrentHashTable
std::function
std::cout << "do_all_readonly is not implemented" << std::endl;
}