}
void xbt_automaton_exp_label_display(xbt_automaton_exp_label_t label){
+ printf("(");
switch(label->type){
- case 0 :
- printf("(");
- xbt_automaton_exp_label_display(label->u.or_and.left_exp);
- printf(" || ");
- xbt_automaton_exp_label_display(label->u.or_and.right_exp);
- printf(")");
- break;
- case 1 :
- printf("(");
- xbt_automaton_exp_label_display(label->u.or_and.left_exp);
- printf(" && ");
- xbt_automaton_exp_label_display(label->u.or_and.right_exp);
- printf(")");
- break;
- case 2 :
- printf("(!");
- xbt_automaton_exp_label_display(label->u.exp_not);
- printf(")");
- break;
- case 3 :
- printf("(%s)",label->u.predicat);
- break;
- case 4 :
- printf("(1)");
- break;
+ case 0:
+ xbt_automaton_exp_label_display(label->u.or_and.left_exp);
+ printf(" || ");
+ xbt_automaton_exp_label_display(label->u.or_and.right_exp);
+ break;
+ case 1:
+ xbt_automaton_exp_label_display(label->u.or_and.left_exp);
+ printf(" && ");
+ xbt_automaton_exp_label_display(label->u.or_and.right_exp);
+ break;
+ case 2:
+ printf("!");
+ xbt_automaton_exp_label_display(label->u.exp_not);
+ break;
+ case 3:
+ printf("%s", label->u.predicat);
+ break;
+ case 4:
+ printf("1");
+ break;
+ default:
+ break;
}
+ printf(")");
}
xbt_automaton_state_t xbt_automaton_get_current_state(xbt_automaton_t a){
}
int xbt_automaton_propositional_symbols_compare_value(xbt_dynar_t s1, xbt_dynar_t s2){
- int *iptr1, *iptr2;
- unsigned int cursor;
unsigned int nb_elem = xbt_dynar_length(s1);
- for(cursor=0;cursor<nb_elem;cursor++){
- iptr1 = xbt_dynar_get_ptr(s1, cursor);
- iptr2 = xbt_dynar_get_ptr(s2, cursor);
+ for (unsigned int cursor = 0; cursor < nb_elem; cursor++) {
+ int* iptr1 = xbt_dynar_get_ptr(s1, cursor);
+ int* iptr2 = xbt_dynar_get_ptr(s2, cursor);
if(*iptr1 != *iptr2)
return 1;
}
/* dict - a generic dictionary, variation over hash table */
-/* Copyright (c) 2004-2015. The SimGrid Team.
+/* Copyright (c) 2004-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-
#include <string.h>
#include <stdio.h>
*/
void xbt_dict_free(xbt_dict_t * dict)
{
- int i;
- xbt_dictelm_t current, previous;
+ xbt_dictelm_t current;
+ xbt_dictelm_t previous;
int table_size;
xbt_dictelm_t *table;
table = (*dict)->table;
/* Warning: the size of the table is 'table_size+1'...
* This is because table_size is used as a binary mask in xbt_dict_rehash */
- for (i = 0; (*dict)->count && i <= table_size; i++) {
+ for (int i = 0; (*dict)->count && i <= table_size; i++) {
current = table[i];
while (current != nullptr) {
previous = current;
/** Returns the amount of elements in the dict */
unsigned int xbt_dict_size(xbt_dict_t dict)
{
- return (dict ? (unsigned int) dict->count : (unsigned int) 0);
+ return (dict != nullptr ? static_cast<unsigned int>(dict->count) : static_cast<unsigned int>(0));
}
/* Expend the size of the dict */
{
unsigned int hash_code = xbt_str_hash_ext(key, key_len);
- xbt_dictelm_t current, previous = nullptr;
+ xbt_dictelm_t current;
+ xbt_dictelm_t previous = nullptr;
XBT_CDEBUG(xbt_dict, "ADD %.*s hash = %u, size = %d, & = %u", key_len, key, hash_code,
dict->table_size, hash_code & dict->table_size);
if (current == nullptr)
THROWF(not_found_error, 0, "key %.*s not found", key_len, key);
-
- if (previous != nullptr) {
- previous->next = current->next;
- } else {
- dict->table[hash_code & dict->table_size] = current->next;
+ else {
+ if (previous != nullptr) {
+ previous->next = current->next;
+ } else {
+ dict->table[hash_code & dict->table_size] = current->next;
+ }
}
if (!dict->table[hash_code & dict->table_size])
}
/* Report current sizes */
- if (count == 0)
- continue;
- if (size == 0)
- continue;
- printf("%uelm x %u cells; ", count, size);
+ if (count != 0 && size != 0)
+ printf("%uelm x %u cells; ", count, size);
}
printf("\n");
xbt_dynar_free(&sizes);
int total_count = 0;
printf("Overall stats:");
xbt_dynar_foreach(all_sizes, count, size) {
- if (count == 0)
- continue;
- if (size == 0)
- continue;
- printf("%uelm x %d cells; ", count, size);
- avg += count * size;
- total_count += size;
+ if (count != 0 && size != 0) {
+ printf("%uelm x %d cells; ", count, size);
+ avg += count * size;
+ total_count += size;
+ }
}
printf("; %f elm per cell\n", avg / (double) total_count);
}