//===-- llvm/ADT/UniqueVector.h ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//===-- llvm/ADT/UniqueVector.h ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
-// This file was developed by James M. Laskey and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_ADT_UNIQUEVECTOR_H
#define LLVM_ADT_UNIQUEVECTOR_H
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_ADT_UNIQUEVECTOR_H
#define LLVM_ADT_UNIQUEVECTOR_H
/// UniqueVector - This class produces a sequential ID number (base 1) for each
/// unique entry that is added. T is the type of entries in the vector. This
/// class should have an implementation of operator== and of operator<.
/// UniqueVector - This class produces a sequential ID number (base 1) for each
/// unique entry that is added. T is the type of entries in the vector. This
/// class should have an implementation of operator== and of operator<.
public:
/// insert - Append entry to the vector if it doesn't already exist. Returns
/// the entry's index + 1 to be used as a unique ID.
unsigned insert(const T &Entry) {
// Check if the entry is already in the map.
public:
/// insert - Append entry to the vector if it doesn't already exist. Returns
/// the entry's index + 1 to be used as a unique ID.
unsigned insert(const T &Entry) {
// Check if the entry is already in the map.
- unsigned ID = Vector.size() + 1;
-
- // Insert in map.
- MI = Map.insert(MI, std::make_pair(Entry, ID));
-
- // Insert in vector.
- Vector.push_back(&MI->first);
+ Val = static_cast<unsigned>(Vector.size()) + 1;
/// idFor - return the ID for an existing entry. Returns 0 if the entry is
/// not found.
unsigned idFor(const T &Entry) const {
// Search for entry in the map.
/// idFor - return the ID for an existing entry. Returns 0 if the entry is
/// not found.
unsigned idFor(const T &Entry) const {
// Search for entry in the map.
/// size - Returns the number of entries in the vector.
///
size_t size() const { return Vector.size(); }
/// size - Returns the number of entries in the vector.
///
size_t size() const { return Vector.size(); }