~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.0.1/pjlib/include/pj++/tree.hpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: tree.hpp 2394 2008-12-23 17:27:53Z bennylp $ */
2
 
/*
3
 
 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
4
 
 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 
 */
20
 
#ifndef __PJPP_TREE_HPP__
21
 
#define __PJPP_TREE_HPP__
22
 
 
23
 
#include <pj/rbtree.h>
24
 
 
25
 
//
26
 
// Tree.
27
 
//
28
 
class PJ_Tree
29
 
{
30
 
public:
31
 
    typedef pj_rbtree_comp Comp;
32
 
    class iterator;
33
 
    class reverse_iterator;
34
 
 
35
 
    class Node : private pj_rbtree_node
36
 
    {
37
 
        friend class PJ_Tree;
38
 
        friend class iterator;
39
 
        friend class reverse_iterator;
40
 
 
41
 
    public:
42
 
        Node() {}
43
 
        explicit Node(void *data) { user_data = data; }
44
 
        void  set_user_data(void *data) { user_data = data; }
45
 
        void *get_user_data() const { return user_data; }
46
 
    };
47
 
 
48
 
    class iterator
49
 
    {
50
 
    public:
51
 
        iterator() {}
52
 
        iterator(const iterator &rhs) : tr_(rhs.tr_), nd_(rhs.nd_) {}
53
 
        iterator(pj_rbtree *tr, pj_rbtree_node *nd) : tr_(tr), nd_(nd) {}
54
 
        Node *operator*() { return (Node*)nd_; }
55
 
        bool operator==(const iterator &rhs) const { return tr_==rhs.tr_ && nd_==rhs.nd_; }
56
 
        iterator &operator=(const iterator &rhs) { tr_=rhs.tr_; nd_=rhs.nd_; return *this; }
57
 
        void operator++() { nd_=pj_rbtree_next(tr_, nd_); }
58
 
        void operator--() { nd_=pj_rbtree_prev(tr_, nd_); }
59
 
    protected:
60
 
        pj_rbtree *tr_;
61
 
        pj_rbtree_node *nd_;
62
 
    };
63
 
 
64
 
    class reverse_iterator : public iterator
65
 
    {
66
 
    public:
67
 
        reverse_iterator() {}
68
 
        reverse_iterator(const reverse_iterator &it) : iterator(it) {}
69
 
        reverse_iterator(pj_rbtree *t, pj_rbtree_node *n) : iterator(t, n) {}
70
 
        reverse_iterator &operator=(const reverse_iterator &rhs) { iterator::operator=(rhs); return *this; }
71
 
        Node *operator*() { return (Node*)nd_; }
72
 
        bool operator==(const reverse_iterator &rhs) const { return iterator::operator==(rhs); }
73
 
        void operator++() { nd_=pj_rbtree_prev(tr_, nd_); }
74
 
        void operator--() { nd_=pj_rbtree_next(tr_, nd_); }
75
 
    };
76
 
 
77
 
    explicit PJ_Tree(Comp *comp) { pj_rbtree_init(&t_, comp); }
78
 
 
79
 
    iterator begin()
80
 
    {
81
 
        return iterator(&t_, pj_rbtree_first(&t_));
82
 
    }
83
 
 
84
 
    iterator end()
85
 
    {
86
 
        return iterator(&t_, NULL);
87
 
    }
88
 
 
89
 
    reverse_iterator rbegin()
90
 
    {
91
 
        return reverse_iterator(&t_, pj_rbtree_last(&t_));
92
 
    }
93
 
 
94
 
    reverse_iterator rend()
95
 
    {
96
 
        return reverse_iterator(&t_, NULL);
97
 
    }
98
 
 
99
 
    bool insert(Node *node)
100
 
    {
101
 
        return pj_rbtree_insert(&t_, node)==0 ? true : false;
102
 
    }
103
 
 
104
 
    Node *find(const void *key)
105
 
    {
106
 
        return (Node*)pj_rbtree_find(&t_, key);
107
 
    }
108
 
 
109
 
    Node *erase(Node *node)
110
 
    {
111
 
        return (Node*)pj_rbtree_erase(&t_, node);
112
 
    }
113
 
 
114
 
    unsigned max_height(Node *node=NULL)
115
 
    {
116
 
        return pj_rbtree_max_height(&t_, node);
117
 
    }
118
 
 
119
 
    unsigned min_height(Node *node=NULL)
120
 
    {
121
 
        return pj_rbtree_min_height(&t_, node);
122
 
    }
123
 
 
124
 
private:
125
 
    pj_rbtree t_;
126
 
};
127
 
 
128
 
#endif  /* __PJPP_TREE_HPP__ */