示例#1
0
文件: timers.c 项目: Stopka/StopWatch
void storage_store(){
	APP_LOG(APP_LOG_LEVEL_INFO,"storage_store()");
	APP_LOG(APP_LOG_LEVEL_INFO,"max_cell_size: %d timer_size: %d laps_size: %d clock_size: %d",PERSIST_DATA_MAX_LENGTH,sizeof(Timer),sizeof(Laps),sizeof(Clock));
	
	int result;
	uint8_t c=timers_count();
	
	result=persist_write_int(STORAGE_KEY_VERSION,STORAGE_VERSION);
	if(result<0){
		APP_LOG(APP_LOG_LEVEL_ERROR,"write error count %d in storage %d #%d",c,STORAGE_KEY_COUNT,result);  
		return;
	}
	
	result=persist_write_int(STORAGE_KEY_COUNT,c);
	if(result<0){
		APP_LOG(APP_LOG_LEVEL_ERROR,"write error count %d in storage %d #%d",count_total(count),STORAGE_KEY_COUNT,result); 
		return;
	}
	APP_LOG(APP_LOG_LEVEL_INFO,"timer count %d",count_total(count));
	
	Timer* timer;
	for(uint8_t i=0;i<c;i++){
		timer=timers_get(i);
		result=persist_write_data(STORAGE_KEY_DATA+i,timer,sizeof(Timer));
		if(result<0){
			APP_LOG(APP_LOG_LEVEL_ERROR,"write error timer %d in storage %d #%d",i,STORAGE_KEY_DATA+i,result); 
			continue;
		}
		APP_LOG(APP_LOG_LEVEL_INFO,"stored timer %d",i);
	}
	APP_LOG(APP_LOG_LEVEL_INFO,"stored");
}
示例#2
0
uint32_t count_total(rbNode_s *node)/*#{{{*/
{
    if(!node){
        return 0;}

    return count_total(node -> child[LEFT]) + count_total(node -> child[RIGHT]) 
           + 1;
} /* end count_total #}}} */
示例#3
0
文件: timers.c 项目: Stopka/StopWatch
uint8_t timers_add(Timer* timer) {
	uint8_t pos;
	if(timer_getDirection(timer)==TIMER_DIRECTION_UP){
		pos=count->stopwatch;
		for(uint8_t i=count_total(count);i>pos;i--){
			timers[i]=timers[i-1];
		}
		count->stopwatch++;
	}else{
		pos=count_total(count);
		count->timer++;
	}
	timers[pos]=timer;
	return pos;
}
示例#4
0
static void
_gtk_rbtree_test (GtkRBTree *tree)
{
  GtkRBTree *tmp_tree;

  if (tree == NULL)
    return;

  /* Test the entire tree */
  tmp_tree = tree;
  while (tmp_tree->parent_tree)
    tmp_tree = tmp_tree->parent_tree;
  
  if (_gtk_rbtree_is_nil (tmp_tree->root))
    return;

  _gtk_rbtree_test_structure (tmp_tree);

  g_assert ((_count_nodes (tmp_tree, tmp_tree->root->left) +
	     _count_nodes (tmp_tree, tmp_tree->root->right) + 1) == tmp_tree->root->count);
      
  _gtk_rbtree_test_height (tmp_tree, tmp_tree->root);
  _gtk_rbtree_test_dirty (tmp_tree, tmp_tree->root, GTK_RBNODE_FLAG_SET (tmp_tree->root, GTK_RBNODE_DESCENDANTS_INVALID));
  g_assert (count_total (tmp_tree, tmp_tree->root) == tmp_tree->root->total_count);
}
示例#5
0
uint32_t total_data_count(cardDeck_s *tree)/*#{{{*/
{
    if(!tree || !tree -> root){
        return 0;}

    return count_total(tree -> root);
} /* end total_data_count #}}} */
示例#6
0
文件: timers.c 项目: Stopka/StopWatch
void timers_deinit(void) {
	APP_LOG(APP_LOG_LEVEL_INFO,"timers_deinit()");
	storage_store();
	
	APP_LOG(APP_LOG_LEVEL_INFO,"cleaning..");
  for(uint8_t i=0;i<count_total(count);i++){
		free(timers[i]);
	}
	count_destroy(count);
	scheduler_deinit();
	APP_LOG(APP_LOG_LEVEL_INFO,"cleaned");
}
示例#7
0
static guint
count_total (GtkRBTree *tree,
             GtkRBNode *node)
{
  guint res;
  
  if (_gtk_rbtree_is_nil (node))
    return 0;
  
  res =
    count_total (tree, node->left) +
    count_total (tree, node->right) +
    (guint)1 +
    (node->children ? count_total (node->children, node->children->root) : 0);

  if (res != node->total_count)
    g_print ("total count incorrect for node\n");

  if (get_total_count (node) != node->total_count)
    g_error ("Node has incorrect total count %u, should be %u", node->total_count, get_total_count (node));
  
  return res;
}
示例#8
0
size_t node::count_total_all(void) const {
   size_t total(0);
   for(size_t i(0); i < theProgram->num_predicates(); ++i)
      total += count_total(theProgram->get_predicate(i));
   return total;
}
// return the sum of all the node values (including duplicates)
int BinarySearchTree::count_total() {
	return count_total(root);
}