NCBI C++ ToolKit
|
Search Toolkit Book for CLinks
Set of edges with weights between nodes represented by zero-based positive integers. More...
#include <algo/cobalt/links.hpp>
Classes | |
struct | SLink |
Single link. More... | |
Public Types | |
typedef list< SLink >::const_iterator | SLink_CI |
![]() | |
enum | EAllocFillMode { eAllocFillNone = 1 , eAllocFillZero , eAllocFillPattern } |
Control filling of newly allocated memory. More... | |
typedef CObjectCounterLocker | TLockerType |
Default locker type for CRef. More... | |
typedef atomic< Uint8 > | TCounter |
Counter type is CAtomiCounter. More... | |
typedef Uint8 | TCount |
Alias for value type of counter. More... | |
Public Member Functions | |
CLinks (Uint4 num_elements) | |
Constructor. More... | |
~CLinks () | |
Destructor. More... | |
void | AddLink (int first, int second, double weight) |
Add link. More... | |
bool | IsLink (int first, int second) const |
Check if link exists between given two nodes. More... | |
bool | IsLink (const vector< int > &first, const vector< int > &second, double &dist) const |
Check if links exist between all pairs of elemens from two sets. More... | |
bool | IsSorted (void) const |
Check whether the links are sorted according to weights. More... | |
void | Sort (void) |
Sort links according to weights in ascending order. More... | |
Uint4 | GetNumElements (void) const |
Get number of nodes. More... | |
Uint4 | GetNumLinks (void) const |
Get number of links. More... | |
double | GetMaxWeight (void) const |
Get maximum weight over all links. More... | |
SLink_CI | begin (void) const |
Get iterator pointing to the first link. More... | |
SLink_CI | end (void) const |
Get iterator pointing behind the last link. More... | |
![]() | |
CObject (void) | |
Constructor. More... | |
CObject (const CObject &src) | |
Copy constructor. More... | |
virtual | ~CObject (void) |
Destructor. More... | |
CObject & | operator= (const CObject &src) THROWS_NONE |
Assignment operator. More... | |
bool | CanBeDeleted (void) const THROWS_NONE |
Check if object can be deleted. More... | |
bool | IsAllocatedInPool (void) const THROWS_NONE |
Check if object is allocated in memory pool (not system heap) More... | |
bool | Referenced (void) const THROWS_NONE |
Check if object is referenced. More... | |
bool | ReferencedOnlyOnce (void) const THROWS_NONE |
Check if object is referenced only once. More... | |
void | AddReference (void) const |
Add reference to object. More... | |
void | RemoveReference (void) const |
Remove reference to object. More... | |
void | ReleaseReference (void) const |
Remove reference without deleting object. More... | |
virtual void | DoNotDeleteThisObject (void) |
Mark this object as not allocated in heap – do not delete this object. More... | |
virtual void | DoDeleteThisObject (void) |
Mark this object as allocated in heap – object can be deleted. More... | |
void * | operator new (size_t size) |
Define new operator for memory allocation. More... | |
void * | operator new[] (size_t size) |
Define new[] operator for 'array' memory allocation. More... | |
void | operator delete (void *ptr) |
Define delete operator for memory deallocation. More... | |
void | operator delete[] (void *ptr) |
Define delete[] operator for memory deallocation. More... | |
void * | operator new (size_t size, void *place) |
Define new operator. More... | |
void | operator delete (void *ptr, void *place) |
Define delete operator. More... | |
void * | operator new (size_t size, CObjectMemoryPool *place) |
Define new operator using memory pool. More... | |
void | operator delete (void *ptr, CObjectMemoryPool *place) |
Define delete operator. More... | |
virtual void | DebugDump (CDebugDumpContext ddc, unsigned int depth) const |
Define method for dumping debug information. More... | |
![]() | |
CDebugDumpable (void) | |
virtual | ~CDebugDumpable (void) |
void | DebugDumpText (ostream &out, const string &bundle, unsigned int depth) const |
void | DebugDumpFormat (CDebugDumpFormatter &ddf, const string &bundle, unsigned int depth) const |
void | DumpToConsole (void) const |
Protected Attributes | |
list< SLink > | m_Links |
Links. More... | |
vector< SLink * > | m_LinkPtrs |
Pointers to links in m_Links sorted according to node indexes; used for checks whether a link exists. More... | |
Uint4 | m_NumElements |
Number of nodes. More... | |
Uint4 | m_NumLinks |
Number of links. More... | |
bool | m_IsSorted |
Is list of links sorted. More... | |
double | m_MaxWeight |
Maximym weight in the list. More... | |
Private Member Functions | |
CLinks (const CLinks &links) | |
Forbid copy constructor. More... | |
CLinks & | operator= (const CLinks &links) |
Forbid assignment operator. More... | |
void | x_InitLinkPtrs (void) |
Initialize secondary list of link pointers. More... | |
bool | x_IsLinkPtr (int first, int second) const |
Check if link exists by searching list of link pointers sorted by node indexes. More... | |
const CLinks::SLink * | x_GetLink (int first, int second) const |
Get link by node ids. More... | |
Additional Inherited Members | |
![]() | |
static NCBI_XNCBI_EXPORT void | ThrowNullPointerException (void) |
Define method to throw null pointer exception. More... | |
static NCBI_XNCBI_EXPORT void | ThrowNullPointerException (const type_info &type) |
static EAllocFillMode | GetAllocFillMode (void) |
static void | SetAllocFillMode (EAllocFillMode mode) |
static void | SetAllocFillMode (const string &value) |
Set mode from configuration parameter value. More... | |
![]() | |
static void | EnableDebugDump (bool on) |
![]() | |
static const TCount | eCounterBitsCanBeDeleted = 1 << 0 |
Define possible object states. More... | |
static const TCount | eCounterBitsInPlainHeap = 1 << 1 |
Heap signature was found. More... | |
static const TCount | eCounterBitsPlaceMask |
Mask for 'in heap' state flags. More... | |
static const int | eCounterStep = 1 << 2 |
Skip over the "in heap" bits. More... | |
static const TCount | eCounterValid = TCount(1) << (sizeof(TCount) * 8 - 2) |
Minimal value for valid objects (reference counter is zero) Must be a single bit value. More... | |
static const TCount | eCounterStateMask |
Valid object, and object in heap. More... | |
![]() | |
virtual void | DeleteThis (void) |
Virtual method "deleting" this object. More... | |
Set of edges with weights between nodes represented by zero-based positive integers.
typedef list<SLink>::const_iterator CLinks::SLink_CI |
|
inline |
Add link.
first | Node number [in] |
second | Node number [in] |
weight | Link weight [in] |
The links are assumed to be undirected. All nodes are stored such that first < second, if the inputs are different the nodes will be swaped. The method does not check whether given link already exists. Adding two links between the same nodes may cause unexpected results.
Definition at line 60 of file links.cpp.
References first(), m_IsSorted, m_Links, m_MaxWeight, m_NumElements, m_NumLinks, NCBI_THROW, swap(), and weight.
Referenced by BOOST_AUTO_TEST_CASE(), TKmerMethods< TKmerCounts >::ComputeDistLinks(), and CMultiAligner::x_FindQueryClusters().
|
inline |
Get iterator pointing to the first link.
Definition at line 144 of file links.hpp.
Referenced by BOOST_AUTO_TEST_CASE(), and CClusterer::ComputeClustersFromLinks().
|
inline |
Get iterator pointing behind the last link.
Definition at line 149 of file links.hpp.
Referenced by CClusterer::ComputeClustersFromLinks().
|
inline |
|
inline |
Get number of nodes.
Definition at line 129 of file links.hpp.
Referenced by BOOST_AUTO_TEST_CASE(), and CClusterer::ComputeClustersFromLinks().
|
inline |
bool CLinks::IsLink | ( | const vector< int > & | first, |
const vector< int > & | second, | ||
double & | dist | ||
) | const |
Check if links exist between all pairs of elemens from two sets.
Existence of links whithin the sets is not checked.
first | List of elements for the first set [in] |
second | List of elements for the second set [in] |
dist | Average distance between elements of the two sets [out] |
The existance of a link is checked by doing binary search in sorted list of links
Definition at line 99 of file links.cpp.
References ITERATE, m_IsSorted, NCBI_THROW, CLinks::SLink::weight, and x_GetLink().
Check if link exists between given two nodes.
first | Node number [in] |
second | Node number [in] |
The link is checked by doing binary search in sorted list of links
Definition at line 81 of file links.cpp.
References first(), m_IsSorted, m_NumElements, NCBI_THROW, swap(), and x_IsLinkPtr().
Referenced by BOOST_AUTO_TEST_CASE(), CClusterer::x_CanAddElem(), and CClusterer::x_CanJoinClusters().
|
inline |
Check whether the links are sorted according to weights.
Definition at line 120 of file links.hpp.
Referenced by BOOST_AUTO_TEST_CASE(), and CClusterer::ComputeClustersFromLinks().
void CLinks::Sort | ( | void | ) |
Sort links according to weights in ascending order.
Definition at line 124 of file links.cpp.
References m_IsSorted, m_Links, and x_InitLinkPtrs().
Referenced by BOOST_AUTO_TEST_CASE(), CClusterer::ComputeClustersFromLinks(), and CMultiAligner::x_FindQueryClusters().
|
private |
Get link by node ids.
first | First node |
second | Second node |
Definition at line 158 of file links.cpp.
References _ASSERT, compare_links_by_nodes(), first(), m_LinkPtrs, NULL, and swap().
Referenced by IsLink().
|
private |
Initialize secondary list of link pointers.
Definition at line 135 of file links.cpp.
References compare_links_by_nodes(), m_LinkPtrs, m_Links, NON_CONST_ITERATE, and ct::sort().
Referenced by Sort().
Check if link exists by searching list of link pointers sorted by node indexes.
first | Node number [in] |
second | Node number [in] |
Definition at line 148 of file links.cpp.
References _ASSERT, compare_links_by_nodes(), first(), and m_LinkPtrs.
Referenced by IsLink().
|
protected |
|
protected |
Pointers to links in m_Links sorted according to node indexes; used for checks whether a link exists.
Definition at line 181 of file links.hpp.
Referenced by x_GetLink(), x_InitLinkPtrs(), and x_IsLinkPtr().
|
protected |
Links.
Definition at line 177 of file links.hpp.
Referenced by AddLink(), Sort(), and x_InitLinkPtrs().
|
protected |
|
protected |
|
protected |