z3-z3-4.13.0.src.util.obj_mark.h Maven / Gradle / Ivy
The newest version!
/*++
Copyright (c) 2006 Microsoft Corporation
Module Name:
obj_mark.h
Abstract:
A mapping from object to boolean (for objects that can be mapped to unsigned integers).
Author:
Leonardo de Moura (leonardo) 2008-01-02.
Revision History:
--*/
#pragma once
#include "util/bit_vector.h"
template
struct default_t2uint {
unsigned operator()(T const & obj) const { return obj.get_id(); }
};
template >
class obj_mark {
T2UInt m_proc;
BV m_marks;
public:
obj_mark(T2UInt const & p = T2UInt()):m_proc(p) {}
bool is_marked(T const & obj) const {
unsigned id = m_proc(obj);
return id < m_marks.size() && m_marks.get(id);
}
bool is_marked(T * obj) const { return is_marked(*obj); }
void mark(T const & obj, bool flag) {
unsigned id = m_proc(obj);
if (id >= m_marks.size()) {
m_marks.resize(id+1, 0);
}
m_marks.set(id, flag);
}
void mark(T const * obj, bool flag) { mark(*obj, flag); }
void mark(T const & obj) { mark(obj, true); }
void mark(T const * obj) { mark(obj, true); }
void reset() { m_marks.reset(); }
};