klee
DiscretePDF.h
Go to the documentation of this file.
1//===-- DiscretePDF.h -------------------------------------------*- C++ -*-===//
2//
3// The KLEE Symbolic Virtual Machine
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef KLEE_DISCRETEPDF_H
11#define KLEE_DISCRETEPDF_H
12
13#include <functional>
14
15namespace klee {
16 template <class T, class Comparator = std::less<T>>
18 // not perfectly parameterized, but float/double/int should work ok,
19 // although it would be better to have choose argument range from 0
20 // to queryable max.
21 typedef double weight_type;
22
23 public:
26
27 bool empty() const;
28 void insert(T item, weight_type weight);
29 void update(T item, weight_type newWeight);
30 void remove(T item);
31 bool inTree(T item);
33
34 /* pick a tree element according to its
35 * weight. p should be in [0,1).
36 */
37 T choose(double p);
38
39 private:
40 class Node;
41 Node *m_root;
42
43 Node **lookup(T item, Node **parent_out);
44 void split(Node *node);
45 void rotate(Node *node);
46 void lengthen(Node *node);
47 void propagateSumsUp(Node *n);
48 };
49
50}
51
52#include "DiscretePDF.inc"
53
54#endif /* KLEE_DISCRETEPDF_H */
void insert(T item, weight_type weight)
void update(T item, weight_type newWeight)
void lengthen(Node *node)
weight_type getWeight(T item)
void remove(T item)
T choose(double p)
void rotate(Node *node)
void propagateSumsUp(Node *n)
bool empty() const
bool inTree(T item)
Node ** lookup(T item, Node **parent_out)
void split(Node *node)
Definition: main.cpp:291