Skip to content

Commit

Permalink
fixes in codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
gsomix committed May 3, 2012
1 parent f1050ea commit 84311ca
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions src/shogun/lib/Set.h
Expand Up @@ -6,7 +6,7 @@
*
* Written (W) 2012 Evgeniy Andreev (gsomix)
*
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
* Copyright (C) 2012 Evgeniy Andreev (gsomix)
*/

#ifndef _SET_H_
Expand Down Expand Up @@ -65,7 +65,7 @@ template<class T> class CSet: public CSGObject
num_elements=0;

hash_array=SG_MALLOC(HashSetNode<T>*, size);
for(int32_t i=0; i<size; i++)
for (int32_t i=0; i<size; i++)
{
hash_array[i]=NULL;
}
Expand All @@ -76,16 +76,16 @@ template<class T> class CSet: public CSGObject
/** Default destructor */
virtual ~CSet()
{
if(hash_array != NULL)
if (hash_array!=NULL)
{
for(int32_t i = 0; i < hash_size; i++)
for (int32_t i=0; i<hash_size; i++)
{
delete hash_array[i];
}
SG_FREE(hash_array);
}

if(array != NULL)
if (array!=NULL)
{
delete array;
}
Expand All @@ -100,8 +100,8 @@ template<class T> class CSet: public CSGObject
*/
void add(const T& e)
{
int32_t index = hash(e);
if(chain_search(index, e) == NULL)
int32_t index=hash(e);
if (chain_search(index, e)==NULL)
{
insert_key(index, e);
num_elements++;
Expand All @@ -114,8 +114,8 @@ template<class T> class CSet: public CSGObject
*/
bool contains(const T& e)
{
int32_t index = hash(e);
if(chain_search(index, e) != NULL)
int32_t index=hash(e);
if (chain_search(index, e)!=NULL)
{
return true;
}
Expand All @@ -129,10 +129,10 @@ template<class T> class CSet: public CSGObject
*/
void remove(const T& e)
{
int32_t index = hash(e);
HashSetNode<T>* result = chain_search(index, e);
int32_t index=hash(e);
HashSetNode<T>* result=chain_search(index, e);

if(result != NULL)
if (result!=NULL)
{
delete_key(index, result);
num_elements--;
Expand All @@ -146,10 +146,10 @@ template<class T> class CSet: public CSGObject
*/
int32_t index_of(const T& e)
{
int32_t index = hash(e);
HashSetNode<T>* result = chain_search(index, e);
int32_t index=hash(e);
HashSetNode<T>* result=chain_search(index, e);

if(result != NULL)
if (result!=NULL)
{
return result->index;
}
Expand Down Expand Up @@ -220,7 +220,7 @@ template<class T> class CSet: public CSGObject

bool is_free(HashSetNode<T>* node)
{
if(node->left == NULL && node->right == NULL)
if ((node->left==NULL) && (node->right==NULL))
{
return true;
}
Expand All @@ -231,24 +231,24 @@ template<class T> class CSet: public CSGObject
/** Searchs key in list(chain) */
HashSetNode<T>* chain_search(int32_t index, const T& key)
{
if(hash_array[index] == NULL)
if (hash_array[index]==NULL)
{
return NULL;
}
else
{
HashSetNode<T>* current = hash_array[index];
HashSetNode<T>* current=hash_array[index];

do // iterating all items in the list
{
if(current->element == key)
if (current->element==key)
{
return current; // it's a search key
}

current = current->right;
current=current->right;

} while(current != NULL);
} while (current!=NULL);

return NULL;
}
Expand All @@ -260,7 +260,7 @@ template<class T> class CSet: public CSGObject
int32_t new_index;
HashSetNode<T>* new_node;

if(free_index >= array->get_num_elements() || array->get_element(free_index)==NULL)
if ((free_index>=array->get_num_elements()) || (array->get_element(free_index)==NULL))
{
// init new node
new_node=new HashSetNode<T>;
Expand All @@ -284,35 +284,35 @@ template<class T> class CSet: public CSGObject
new_node->right=NULL;

// add new node in start of list
if(hash_array[index] == NULL)
if (hash_array[index]==NULL)
{
hash_array[index] = new_node;
hash_array[index]=new_node;
}
else
{
hash_array[index]->left = new_node;
new_node->right = hash_array[index];
hash_array[index]->left=new_node;
new_node->right=hash_array[index];

hash_array[index] = new_node;
hash_array[index]=new_node;
}
}

/** Deletes key from set */
void delete_key(int32_t index, HashSetNode<T>* node)
{
int32_t temp = 0;
int32_t temp=0;

if(node == NULL)
if (node==NULL)
{
return;
}

if(node->right != NULL)
if (node->right!=NULL)
{
node->right->left = node->left;
}

if(node->left != NULL)
if (node->left!=NULL)
{
node->left->right = node->right;
}
Expand All @@ -321,7 +321,7 @@ template<class T> class CSet: public CSGObject
hash_array[index] = node->right;
}

temp = node->index;
temp=node->index;

node->index=free_index;
node->left=NULL;
Expand Down

0 comments on commit 84311ca

Please sign in to comment.