Skip to content
Snippets Groups Projects
Commit d403189f authored by Jan Trávníček's avatar Jan Trávníček
Browse files

use unsigned in place of uint

parent c79e7184
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
/*
* 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) {
......
  • Contributor

    This does not fix all problems, there are more files with uint:

    g++ -pipe -std=c++11 -O3 -DNDEBUG -DRELEASE -c -Wall -pedantic -Wextra -Werror -Wshadow -Wpointer-arith -Wcast-qual -Wdelete-non-virtual-dtor -Wredundant-decls -fPIC -I/builds/travnja3/automata-library/alib2algo/src -I/builds/travnja3/automata-library/alib2str_experimental/src -I/builds/travnja3/automata-library/alib2str/src -I/builds/travnja3/automata-library/alib2data_experimental/src -I/builds/travnja3/automata-library/alib2data/src -I/builds/travnja3/automata-library/alib2common/src -I/builds/travnja3/automata-library/alib2std/src -I/usr/include/libxml2 -I/builds/travnja3/automata-library/alib2algo_experimental/src /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/Edmonds.cpp -o /builds/travnja3/automata-library/alib2algo_experimental/obj-release/graph/spanningtree/Edmonds.o
    In file included from /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/Edmonds.cpp:18:0:
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:32:2: error: 'uint' does not name a type
      uint size() const   { return _size; }
      ^~~~
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:38:3: error: 'uint' does not name a type
       uint    degree;
       ^~~~
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:44:28: error: 'uint' has not been declared
       Node(const elem_t & val, uint deg = 0, Node * par = NULL, Node * chld = NULL, Node * pr = NULL, Node * ne = NULL)
                                ^~~~
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:49:2: error: 'uint' does not name a type
      uint    _size;    ///< count of elements stored in the heap
      ^~~~
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h: In constructor 'FibonacciHeap<elem_t>::Node::Node(const elem_t&, int, FibonacciHeap<elem_t>::Node*, FibonacciHeap<elem_t>::Node*, FibonacciHeap<elem_t>::Node*, FibonacciHeap<elem_t>::Node*)':
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:45:18: error: class 'FibonacciHeap<elem_t>::Node' does not have any field named 'degree'
        : value(val), degree(deg), mark(false), parent(par), child(chld), prev(pr), next(ne) {}
                      ^~~~~~
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h: In constructor 'FibonacciHeap<elem_t>::FibonacciHeap(int (*)(const elem_t&, const elem_t&))':
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:70:4: error: class 'FibonacciHeap<elem_t>' does not have any field named '_size'
      , _size( 0 )
        ^~~~~
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h: In member function 'void FibonacciHeap<elem_t>::insert(const elem_t&)':
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:106:3: error: '_size' was not declared in this scope
       _size = 1;
       ^~~~~
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:112:2: error: '_size' was not declared in this scope
      _size++;
      ^~~~~
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h: In member function 'elem_t FibonacciHeap<elem_t>::extractMax()':
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:142:2: error: '_size' was not declared in this scope
      _size--;
      ^~~~~
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h: In member function 'void FibonacciHeap<elem_t>::consolidate()':
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:187:2: error: 'uint' was not declared in this scope
      uint maxDegree;
      ^~~~
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:189:7: error: expected ';' before 'i'
      uint i, degree;
           ^
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:192:2: error: 'maxDegree' was not declared in this scope
      maxDegree = log2( _size );
      ^~~~~~~~~
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:192:20: error: '_size' was not declared in this scope
      maxDegree = log2( _size );
                        ^~~~~
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:194:7: error: 'i' was not declared in this scope
      for (i = 0; i <= maxDegree; i++)
           ^
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:199:3: error: 'degree' was not declared in this scope
       degree = actual->degree;
       ^~~~~~
    /builds/travnja3/automata-library/alib2algo_experimental/src/graph/spanningtree/../datastructs/FibonacciHeap.h:215:7: error: 'i' was not declared in this scope
      for (i = 0; i <= maxDegree; i++) {
           ^
    make[4]: *** [/builds/travnja3/automata-library/alib2algo_experimental/obj-release/graph/spanningtree/Edmonds.d:3: /builds/travnja3/automata-library/alib2algo_experimental/obj-release/graph/spanningtree/Edmonds.o] Error 1
  • Author Owner

    Hmm I didn't look at those files since there weren't the mentioned includes... now there should not be any uints remaining in the master through the source code anymore.

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment