Esempio n. 1
0
  int Position (const INDEX_2 & ind) const
  {
    int i = HashValue(ind);
    while (1)
      {
	if (hash.Get(i) == ind) return i;
	if (hash.Get(i).I1() == invalid) return 0;
	i++;
	if (i > hash.Size()) i = 1;
      }
  }
Esempio n. 2
0
 void Set (const INDEX & ahash, const T & acont)
 {
   int pos;
   PositionCreate (ahash, pos);
   hash.Elem(pos) = ahash;
   cont.Elem(pos) = acont;
 }
Esempio n. 3
0
  // returns 1, if new postion is created
  int PositionCreate (const INDEX_2 & ind, int & apos)
  {
    int i = HashValue (ind);
    if (hash.Get(i) == ind) 
      {
	apos = i;
	return 0;
      }
    if (hash.Get(i).I1() == invalid)
      {
	hash.Elem(i) = ind; 
	apos = i;
	return 1;
      }
    return PositionCreate2 (ind, apos);    
  }
Esempio n. 4
0
 // public:    //SZ
 BASE_INDEX_3_CLOSED_HASHTABLE (int size)
   : hash(size)
 {
   hash.SetName ("i3-hashtable, hash");
   invalid = -1;
   for (int i = 0; i < size; i++)
     hash[i].I1() = invalid;
 }
Esempio n. 5
0
  int UsedElements () const
  {
    int n = hash.Size();
    int cnt = 0;
    for (int i = 0; i < n; i++)
      if (hash[i].I1() != invalid)
	cnt++;
    return cnt;
  }
Esempio n. 6
0
  int Position (const INDEX_3 & ind) const
  {
    int i = HashValue(ind);
    while (1)
      {
	if (hash[i] == ind) return i;
	if (hash[i].I1() == invalid) return -1;
        i = (i+1) % hash.Size();
      }
  }
Esempio n. 7
0
  int Costs (const INDEX_3 & ind) const
  {
    int i = HashValue(ind);
    int c = 1;
    while (1)
      {
	if (hash[i] == ind) return c;
	if (hash[i].I1() == invalid) return c;
        i = (i+1) % hash.Size();
        c++;
      }
  }
Esempio n. 8
0
 INDEX_3_CLOSED_HASHTABLE (int size)
   : BASE_INDEX_3_CLOSED_HASHTABLE(size), cont(size)
 {
   cont.SetName ("i3-hashtable, contents");
 }
Esempio n. 9
0
 int HashValue (const INDEX_3 & ind) const
 {
   return (ind.I1() + 15 * ind.I2() + 41 * ind.I3()) % hash.Size();
 }
Esempio n. 10
0
 const T & Get (const INDEX & ahash) const
 {
   int pos = Position (ahash);
   return cont.Get(pos);
 }
Esempio n. 11
0
 int GetNEdges () const
 { return edge2vert.Size(); }
Esempio n. 12
0
 inline void SetData (int pos, const T & acont)
 {
   cont.Elem(pos) = acont;
 }
Esempio n. 13
0
 inline void SetData (int pos, const INDEX & ahash, const T & acont)
 {
   hash.Elem(pos) = ahash;
   cont.Elem(pos) = acont;
 }
Esempio n. 14
0
 void SetName (const char * aname)
 {
   cont.SetName(aname);
   hash.SetName(aname);
 }
Esempio n. 15
0
 int HashValue (const INDEX_2 & ind) const
   {
     return (ind.I1() + 71 * ind.I2()) % hash.Size() + 1;
   }
Esempio n. 16
0
 int UsedPos (int pos) const { return ! (hash.Get(pos).I1() == invalid); }
Esempio n. 17
0
 void GetData (int pos, T & acont) const
 {
   acont = cont.Get(pos);
 }
Esempio n. 18
0
  void SetSize (int size)
 {
   BaseSetSize(size);
   cont.SetSize(size);
 }
Esempio n. 19
0
 void GetSegmentEdge (int segnr, int & enr, int & orient) const
 {
   enr = abs(segedges.Get(segnr));
   orient = segedges.Get(segnr) > 0 ? 1 : -1;
 }
Esempio n. 20
0
 void DeleteData ()
 { 
   SetSize (cont.Size()); 
 }
Esempio n. 21
0
 void GetData (int pos, INDEX & ahash, T & acont) const
 {
   ahash = hash.Get(pos);
   acont = cont.Get(pos);
 }
Esempio n. 22
0
 int GetNSurfedges() const {return surfedges.Size();}
Esempio n. 23
0
 const T & GetData (int pos) { return cont.Get(pos); }
Esempio n. 24
0
 int GetNFaces () const
 { return face2vert.Size(); }
Esempio n. 25
0
 int Size() const 
 {
   return hash.Size(); 
 }
Esempio n. 26
0
 void GetSurface2VolumeElement (int selnr, int & elnr1, int & elnr2) const
 { 
   elnr1 = surf2volelement.Get(selnr)[0];
   elnr2 = surf2volelement.Get(selnr)[1];
 }
Esempio n. 27
0
 int HashValue (const INDEX & ind) const
 {
   return ind % hash.Size() + 1;
 }