Static Value-Flow Analysis
Classes | Public Member Functions | Private Types | Private Attributes | List of all members
SVF::List< Data > Class Template Reference

#include <WorkList.h>

Classes

class  ListNode
 

Public Member Functions

 List ()
 
 ~List ()
 
bool empty () const
 
bool find (const Data &data) const
 
void push (const Data &data)
 
Data pop ()
 

Private Types

typedef Set< Data > DataSet
 
typedef ListNode Node
 

Private Attributes

DataSet nodeSet
 
Nodehead
 
Nodetail
 

Detailed Description

template<class Data>
class SVF::List< Data >

Worklist with "first come first go" order. New nodes pushed at back and popped from front. Elements in the list are unique as they're recorded by Set.

Definition at line 56 of file WorkList.h.

Member Typedef Documentation

◆ DataSet

template<class Data >
typedef Set<Data> SVF::List< Data >::DataSet
private

Definition at line 73 of file WorkList.h.

◆ Node

template<class Data >
typedef ListNode SVF::List< Data >::Node
private

Definition at line 74 of file WorkList.h.

Constructor & Destructor Documentation

◆ List()

template<class Data >
SVF::List< Data >::List ( )
inline

Definition at line 77 of file WorkList.h.

78  {
79  head = nullptr;
80  tail = nullptr;
81  }
Node * head
Definition: WorkList.h:127
Node * tail
Definition: WorkList.h:128

◆ ~List()

template<class Data >
SVF::List< Data >::~List ( )
inline

Definition at line 83 of file WorkList.h.

83 {}

Member Function Documentation

◆ empty()

template<class Data >
bool SVF::List< Data >::empty ( void  ) const
inline

Definition at line 85 of file WorkList.h.

86  {
87  return (head == nullptr);
88  }

◆ find()

template<class Data >
bool SVF::List< Data >::find ( const Data &  data) const
inline

Definition at line 90 of file WorkList.h.

91  {
92  return nodeSet.find(data) != nodeSet.end();
93  }
DataSet nodeSet
Definition: WorkList.h:126

◆ pop()

template<class Data >
Data SVF::List< Data >::pop ( )
inline

get node from list head

change list head to the next node

the last node is popped.

Definition at line 108 of file WorkList.h.

109  {
110  assert(head != nullptr && "list is empty");
112  Node *head_node = head;
113 
115  head = head->next;
116  if (head == nullptr)
117  tail = nullptr;
118 
119  Data data = head_node->data;
120  nodeSet.erase(data);
121  delete head_node;
122  return data;
123  }
ListNode * next
Definition: WorkList.h:70
ListNode Node
Definition: WorkList.h:74

◆ push()

template<class Data >
void SVF::List< Data >::push ( const Data &  data)
inline

Definition at line 95 of file WorkList.h.

96  {
97  if (nodeSet.find(data) == nodeSet.end())
98  {
99  Node *new_node = new Node(data);
100  if (head == nullptr)
101  head = new_node;// the list is empty
102  else
103  tail->next = new_node;
104  tail = new_node;
105  }
106  }

Member Data Documentation

◆ head

template<class Data >
Node* SVF::List< Data >::head
private

Definition at line 127 of file WorkList.h.

◆ nodeSet

template<class Data >
DataSet SVF::List< Data >::nodeSet
private

Definition at line 126 of file WorkList.h.

◆ tail

template<class Data >
Node* SVF::List< Data >::tail
private

Definition at line 128 of file WorkList.h.


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