Example #1
0
void leaf_data::add_reference( uint32_t ref ) {
	//logfile() << format( "leaf_data[%s]::add_reference( %s )\n" ) % idx_ % ref;
	assert( can_add( ref ) );
	if ( has_reference( ref ) ) return;
	iterator first = begin();
	const iterator past = end();
	unsigned value = 0;
	while ( first != past ) {
		value = *first;
		++first;
	}
	++ref;
	if ( usedbytes() ) ++value;
	unsigned char* target = const_cast<unsigned char*>( first.raw() );
	assert( target == my_base() + usedbytes() );
	if ( ref > value && ( ref - value ) < 256 ) {
		assert( ref != value );
		*target = ref - value;
		set_usedbytes( usedbytes() + 1 );
	} else {
		*target++ = 0;
		byte_io::write<uint32_t>( target, ref );
		set_usedbytes( usedbytes() + 1 + byte_io::byte_lenght<uint32_t>() );
	}
	assert( usedbytes() <= capacity() );
}
Example #2
0
File: p2.c Project: jsliacan/misc
void build_graph(int *graph, int ne, int ze, int start){
  /*
   * graph - list of edges
   * ne - number of edges in this graph
   * ze - number of potential edges (total - ne - forbidden)
   * start - only concerned about adding new edges after the index=start
   */ 

  counter++;
  //printarr(graph,E);
  
  if((ze == 0) && (current_max < ne)){
    current_max = ne;
  }

  if(ze > 0){
    
    for(int i=start; i<E; i++){
      if(graph[i] == 0){
	int newgraph[E];
	int fe = 0;
	for(int j=0; j<E; j++){
	  newgraph[j] = graph[j];
	  if((j>=start) && (j<i) && (graph[j]==0)){
	    newgraph[j] = -1;
	    fe++;
	  }
	}
	int addable = can_add(newgraph, &fe, i); // can add edge i?
	if(addable && (MAX_COUNT <= ne+ze-fe)){
	  newgraph[i] = 1;
	  fe++;
	  build_graph(newgraph, ne+1, ze-fe, i+1);
	}
	/*
	else{ // if i not addable
	  //newgraph[i] = 1;
	  //printarr(newgraph,E);
	  //printf("not addable\n");
	  //graph[i] = -1;
	  //ze--;
	}
	*/
      }
    }	
  }
}
Example #3
0
 inline bool
 Context::can_add_contextual_function(string name,string_list targs){
   return can_add(name);
 }
Example #4
0
		void add(Unit & p) {
			assert(can_add(p));
			space_left -= 100;			
			units.add(&p);
			p.loc.set(this);
		}