#ifndef _MUTEXTABLE_
#define _MUTEXTABLE_

#include "sys/sys"
#include "config/config"
#include "ThreadsAndMutexes/mutextree/mutextree"

class MutexTable {
public:
    MutexTable(unsigned sz);
    MutexTable(MutexTable const &other);
    ~MutexTable();

    MutexTable const &operator=(MutexTable const &other);

    void lock(void *o);
    void unlock(void *o);

    unsigned size() const                       { return _size; }
    int weight(unsigned i) const;
    int balance(unsigned i) const;

private:
    void copy(MutexTable const &other);
    void destroy();
    unsigned hash(void *o);

    MutexTree **_table;
    unsigned _size;
};

#endif
