SundanceIntHashSet.cpp
Go to the documentation of this file.
00001 #include "SundanceIntHashSet.hpp"
00002 #include "PlayaExceptions.hpp"
00003 
00004 
00005 using namespace Sundance;
00006 using namespace Teuchos;
00007 
00008 IntHashSet::IntHashSet()
00009   : capacity_(0),
00010     data_(),
00011     size_(0)
00012 {;}
00013 
00014 void IntHashSet::setCapacity(int capacity)
00015 {
00016   capacity_ = capacity;
00017   data_.resize(capacity_);
00018 }
00019     
00020 
00021 
00022 
00023 bool IntHashSet::contains(int x) const 
00024 {
00025   int ptr = hashFunc(x);
00026   const std::list<int>& d = data_[ptr];
00027   for (std::list<int>::const_iterator i=d.begin(); i != d.end(); i++)
00028     {
00029       if (x == *i) return true;
00030     }
00031   return false;
00032 }
00033 
00034 void IntHashSet::fillArray(int* a) const
00035 {
00036   int k = 0;
00037   for (int i=0; i<data_.size(); i++)
00038     {
00039       for (std::list<int>::const_iterator 
00040              j=data_[i].begin(); j!=data_[i].end(); j++, k++)
00041         {
00042           a[k] = *j;
00043         }
00044     }
00045 }
00046 
00047 
00048 

Site Contact