From d403189f2304ef237d1a05a37c4970d9410386a9 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Tue, 7 Mar 2017 09:16:13 +0100 Subject: [PATCH] use unsigned in place of uint --- .../src/graph/datastructs/BinomialHeap.h | 10 ++++------ .../src/graph/datastructs/Components.h | 16 +++++++--------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/alib2algo_experimental/src/graph/datastructs/BinomialHeap.h b/alib2algo_experimental/src/graph/datastructs/BinomialHeap.h index 0185cdc10b..feeb9e66c3 100644 --- a/alib2algo_experimental/src/graph/datastructs/BinomialHeap.h +++ b/alib2algo_experimental/src/graph/datastructs/BinomialHeap.h @@ -8,8 +8,6 @@ #ifndef BINOMIAL_HEAP_INCLUDED #define BINOMIAL_HEAP_INCLUDED -#include <sys/types.h> - #include <stdexcept> /// binomial heap used as mergeable priority queue @@ -30,22 +28,22 @@ class BinomialHeap { /// merges this heap with another heap (!! this is a DESTRUCTIVE merge, heap in argument will be cleared !!) void mergeWith( BinomialHeap<elem_t> && that ); - uint size() const { return _size; } + size_t size() const { return _size; } protected: struct Node { elem_t value; - uint degree; + unsigned degree; Node * parent; Node * child; Node * sibling; - Node( const elem_t & val, uint deg = 0, Node * par = NULL, Node * chld = NULL, Node * sib = NULL ) + Node( const elem_t & val, unsigned deg = 0, Node * par = NULL, Node * chld = NULL, Node * sib = NULL ) : value(val), degree(deg), parent(par), child(chld), sibling(sib) {} }; Node * _head; ///< head of a singly linked list of binomial trees - uint _size; ///< count of elements stored in the heap + size_t _size; ///< count of elements stored in the heap int (* _compare)( const elem_t &, const elem_t & ); ///< user-defined comparator function protected: diff --git a/alib2algo_experimental/src/graph/datastructs/Components.h b/alib2algo_experimental/src/graph/datastructs/Components.h index 74737e278f..3db1f0080b 100644 --- a/alib2algo_experimental/src/graph/datastructs/Components.h +++ b/alib2algo_experimental/src/graph/datastructs/Components.h @@ -1,12 +1,10 @@ /* - * Kruskal.cpp + * Composnents.h * * Created on: Mar 26, 2016 * Author: Jan Broz */ -#include <sys/types.h> - #include <unordered_map> #include <graph/common/Node.h> @@ -73,7 +71,7 @@ class Components2 { /// wrapper over the node containing identification of parent and height of subtree struct SetNode { - uint parent; + unsigned parent; int height; }; @@ -81,18 +79,18 @@ class Components2 { public: - Components2( uint nodeCount ) { _nodes = new SetNode [nodeCount]; } + Components2( unsigned nodeCount ) { _nodes = new SetNode [nodeCount]; } ~Components2() { delete [] _nodes; } /// marks a node as a single-element component - void MakeSet( uint node ) + void MakeSet( unsigned node ) { _nodes[ node ].parent = node; _nodes[ node ].height = 0; } /// returns a reprezentative of the component in which the given node is - uint Find( uint node ) + unsigned Find( unsigned node ) { if (node != _nodes[ node ].parent) _nodes[ node ].parent = Find( _nodes[ node ].parent ); // shorten the path to root for next use @@ -100,14 +98,14 @@ class Components2 { } /// unifies 2 acyclic components - void Union( uint node1, uint node2 ) + void Union( unsigned node1, unsigned node2 ) { Link( Find( node1 ), Find( node2 ) ); } protected: - void Link( uint root1, uint root2 ) + void Link( unsigned root1, unsigned root2 ) { // connect smaller into bigger to limit the final depth if (_nodes[ root1 ].height < _nodes[ root2 ].height) { -- GitLab