NCBI C++ ToolKit
igraph_utils.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_GRAPH___IGRAPH_UTILS__HPP
2 #define GUI_GRAPH___IGRAPH_UTILS__HPP
3 
4 /* $Id: igraph_utils.hpp 15168 2007-10-15 19:11:34Z dicuccio $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Andrey Yazhuk
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbistl.hpp>
36 #include <corelib/ncbistd.hpp>
37 
38 #include <set>
39 #include <algorithm>
40 
41 /** @addtogroup GUI_GRAPH
42  *
43  * @{
44  */
45 
47 
48 template<class P> void destroy(P pT) { delete pT; }
49 
50 template<class P> void destroy_null(P& pT) { delete pT; pT = NULL; }
51 
52 template<class P> void destroy_null_array(P& pT) { delete[] pT; pT = NULL; }
53 
54 template<class P> struct Destroyer
55 {
56  static void destroy(P pT) { delete pT; };
57  static void destroy_null(P& pT) { delete pT; pT = NULL; };
58 };
59 
60 template<class ContT> void destroy_and_erase_elems(ContT& C)
61 {
62  typedef typename ContT::value_type value_type;
63  for_each(C.begin(), C.end(), Destroyer<value_type>::destroy);
64  C.clear();
65 }
66 
67 template<class InIt> void destroy_elems(InIt first, InIt last)
68 {
69  typedef typename InIt::value_type value_type;
71 }
72 
73 template<class T> bool set_contains(const set<T>& Set, const T& Elem)
74 {
75  return Set.find(Elem)!=Set.end();
76 }
77 
79 
80 #endif
Definition: set.hpp:45
const_iterator find(const key_type &key) const
Definition: set.hpp:137
const_iterator end() const
Definition: set.hpp:136
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define C(s)
Definition: common.h:231
#define T(s)
Definition: common.h:230
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:46
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:51
#define P(a, b)
Definition: sqlwparams.h:19
#define NULL
Definition: ncbistd.hpp:225
void destroy_elems(InIt first, InIt last)
void destroy_null(P &pT)
bool set_contains(const set< T > &Set, const T &Elem)
void destroy(P pT)
void destroy_and_erase_elems(ContT &C)
static void destroy(P pT)
static void destroy_null(P &pT)
void destroy_null_array(P &pT)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
double value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:228
The NCBI C++/STL use hints.
Modified on Wed Jul 17 13:22:49 2024 by modify_doxy.py rev. 669887