Lolly 1.4.27
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Friends | List of all members
rel_hashmap_rep< T, U > Class Template Reference

#include <rel_hashmap.hpp>

Inheritance diagram for rel_hashmap_rep< T, U >:
Inheritance graph
[legend]
Collaboration diagram for rel_hashmap_rep< T, U >:
Collaboration graph
[legend]

Public Member Functions

 rel_hashmap_rep (hashmap< T, U > item2, rel_hashmap< T, U > next2)
 
bool contains (T x)
 
void extend ()
 
void shorten ()
 
void merge ()
 
void find_changes (hashmap< T, U > &CH)
 
void find_differences (hashmap< T, U > &CH)
 
void change (hashmap< T, U > CH)
 

Public Attributes

hashmap< T, U > item
 
rel_hashmap< T, U > next
 

Friends

class rel_hashmap< T, U >
 

Additional Inherited Members

- Private Member Functions inherited from concrete_struct
 concrete_struct ()
 Default constructor for the concrete object. Increments the reference count.
 
virtual ~concrete_struct ()
 Virtual destructor for the concrete object. Decrements the reference count.
 
- Private Attributes inherited from concrete_struct
int ref_count
 The reference count for the concrete object.
 

Detailed Description

template<class T, class U>
class rel_hashmap_rep< T, U >

Definition at line 29 of file rel_hashmap.hpp.

Constructor & Destructor Documentation

◆ rel_hashmap_rep()

template<class T , class U >
rel_hashmap_rep< T, U >::rel_hashmap_rep ( hashmap< T, U > item2,
rel_hashmap< T, U > next2 )
inline

Definition at line 32 of file rel_hashmap.hpp.

35 : item (item2), next (next2) {}
The list class represents a linked list.
Definition list.hpp:48
rel_hashmap< T, U > next
hashmap< T, U > item

Member Function Documentation

◆ contains()

template<class T , class U >
bool rel_hashmap_rep< T, U >::contains ( T x)

Definition at line 41 of file rel_hashmap.ipp.

41 {
42 if (item->contains (x)) return true;
43 if (is_nil (next)) return false;
44 return next->contains (x);
45}
bool is_nil(rel_hashmap< T, U > h)

◆ extend()

template<class T , class U >
void rel_hashmap_rep< T, U >::extend ( )

Definition at line 49 of file rel_hashmap.ipp.

49 {
51 item= hashmap<T, U> (item->init);
52}
friend class rel_hashmap< T, U >

◆ shorten()

template<class T , class U >
void rel_hashmap_rep< T, U >::shorten ( )

Definition at line 56 of file rel_hashmap.ipp.

56 {
57 ASSERT (!is_nil (next), "relative hashmap cannot be shortened");
58 item= next->item;
59 next= next->next;
60}
#define ASSERT(cond, msg)
Macro used to assert that a condition is true, and throw an exception with an error message if the co...
Definition basic.hpp:85

◆ merge()

template<class T , class U >
void rel_hashmap_rep< T, U >::merge ( )

Definition at line 64 of file rel_hashmap.ipp.

64 {
65 ASSERT (!is_nil (next), "relative hashmap cannot be merged");
66 next->change (item);
67 shorten ();
68}

◆ find_changes()

template<class T , class U >
void rel_hashmap_rep< T, U >::find_changes ( hashmap< T, U > & CH)

Definition at line 72 of file rel_hashmap.ipp.

72 {
73 int i;
76 for (i= 0; i < CH->n; i++) {
77 list<hashentry<T, U>> l (CH->a[i]);
78 while (!is_nil (l)) {
79 if (h[l->item.key] == l->item.im)
81 l= l->next;
82 }
83 }
84 while (!is_nil (remove)) {
85 CH->reset (remove->item.key);
86 remove= remove->next;
87 }
88}
list< T > remove(list< T > l, T what)
Create a new list with a specific item removed.
Definition list.ipp:214

◆ find_differences()

template<class T , class U >
void rel_hashmap_rep< T, U >::find_differences ( hashmap< T, U > & CH)

Definition at line 92 of file rel_hashmap.ipp.

92 {
93 int i;
95 for (i= 0; i < item->n; i++) {
96 list<hashentry<T, U>> l (item->a[i]);
97 while (!is_nil (l)) {
98 if (!CH->contains (l->item.key))
99 add= list<hashentry<T, U>> (l->item, add);
100 l= l->next;
101 }
102 }
103 while (!is_nil (add)) {
104 CH (add->item.key)= next[add->item.key];
105 add = add->next;
106 }
108}
void find_changes(hashmap< T, U > &CH)

◆ change()

template<class T , class U >
void rel_hashmap_rep< T, U >::change ( hashmap< T, U > CH)

Definition at line 112 of file rel_hashmap.ipp.

112 {
113 int i;
114 for (i= 0; i < CH->n; i++) {
115 list<hashentry<T, U>> l (CH->a[i]);
116 while (!is_nil (l)) {
117 item (l->item.key)= l->item.im;
118 l = l->next;
119 }
120 }
121}

Friends And Related Symbol Documentation

◆ rel_hashmap< T, U >

template<class T , class U >
friend class rel_hashmap< T, U >
friend

Definition at line 42 of file rel_hashmap.hpp.

Member Data Documentation

◆ item

template<class T , class U >
hashmap<T, U> rel_hashmap_rep< T, U >::item

Definition at line 31 of file rel_hashmap.hpp.

◆ next

template<class T , class U >
rel_hashmap<T, U> rel_hashmap_rep< T, U >::next

Definition at line 32 of file rel_hashmap.hpp.


The documentation for this class was generated from the following files: