All Downloads are FREE. Search and download functionalities are using the official Maven repository.

z3-z3-4.13.0.src.util.uint_map.h Maven / Gradle / Ivy

The newest version!
/*++
Copyright (c) 2006 Microsoft Corporation

Module Name:

    uint_map.h

Abstract:

    

Author:

    Leonardo de Moura (leonardo) 2010-07-01.

Revision History:

--*/
#pragma once

#include "util/vector.h"

/**
   \brief Implement a map from unsigned to T * using vectors
*/
template
class uint_map {
    ptr_vector m_map;
public:
    bool contains(unsigned k) const { return m_map.get(k, 0) != 0; }

    bool find(unsigned k, T * & v) const { 
        if (k >= m_map.size())
            return false;
        else {
            v = m_map[k];
            return v != 0;
        }
    }
    
    T * find(unsigned k) const { 
        SASSERT(k < m_map.size() && m_map[k] != 0); 
        return m_map[k]; 
    }

    void insert(unsigned k, T * v) {
        m_map.reserve(k+1);
        m_map[k] = v;
        SASSERT(contains(k));
    }

    void erase(unsigned k) {
        if (k < m_map.size()) 
            m_map[k] = 0;
    }

    void reset() {
        m_map.reset();
    }
};







© 2015 - 2024 Weber Informatics LLC | Privacy Policy