Пример #1
0
void find_boundary_component_germs(GRID const& G, FACETSET & C,
				   int& num_comps, int& num_facets)

{
  typedef GRID                          grid_type;
  typedef grid_types<GRID>              gt;
  typedef typename gt::Facet            Facet;
  typedef typename gt::FacetIterator    FacetIterator;
  typedef iscellinside_pred<grid_type>  inside;
  typedef BoundaryComponentEdgeIterator2D<grid_type, inside> BCFacetIterator;

  partial_grid_function<Facet,bool> marked(G,false);

  num_comps = num_facets = 0;
  for(FacetIterator f = G.FirstFacet(); ! f.IsDone(); ++f)
    if( (! marked(*f))  && (G.IsOnBoundary(*f))) {
      C.push_back(*f);
      num_comps++;
      BCFacetIterator bf(*f,inside(G));
      while(! bf.IsDone()) {
	num_facets++;
	marked[*bf] = true;
	++bf;
      }
    }
}
Пример #2
0
/*
 * Usage: rev-tree [--edges] [--cache <cache-file>] <commit-id> [<commit-id2>]
 *
 * The cache-file can be quite important for big trees. This is an
 * expensive operation if you have to walk the whole chain of
 * parents in a tree with a long revision history.
 */
int main(int argc, char **argv)
{
	int i;
	int nr = 0;
	unsigned char sha1[MAX_COMMITS][20];

	/*
	 * First - pick up all the revisions we can (both from
	 * caches and from commit file chains).
	 */
	for (i = 1; i < argc ; i++) {
		char *arg = argv[i];

		if (!strcmp(arg, "--cache")) {
			read_cache_file(argv[2]);
			i++;
			continue;
		}

		if (!strcmp(arg, "--edges")) {
			show_edges = 1;
			continue;
		}

		if (nr >= MAX_COMMITS || get_sha1_hex(arg, sha1[nr]))
			usage("rev-tree [--edges] [--cache <cache-file>] <commit-id> [<commit-id>]");
		parse_commit(sha1[nr]);
		nr++;
	}

	/*
	 * Now we have the maximal tree. Walk the different sha files back to the root.
	 */
	for (i = 0; i < nr; i++)
		mark_sha1_path(lookup_rev(sha1[i]), 1 << i);

	/*
	 * Now print out the results..
	 */
	for (i = 0; i < nr_revs; i++) {
		struct revision *rev = revs[i];
		struct parent *p;

		if (!interesting(rev))
			continue;

		printf("%s:%d", sha1_to_hex(rev->sha1), marked(rev));
		p = rev->parent;
		while (p) {
			printf(" %s:%d", sha1_to_hex(p->parent->sha1), marked(p->parent));
			p = p->next;
		}
		printf("\n");
	}
	return 0;
}
Пример #3
0
void JSNode::mark()
{
    ASSERT(!marked());

    Node* node = m_impl.get();

    // Nodes in the document are kept alive by JSDocument::mark,
    // so we have no special responsibilities and can just call the base class here.
    if (node->inDocument()) {
        // But if the document isn't marked we have to mark it to ensure that
        // nodes reachable from this one are also marked
        if (Document* doc = node->ownerDocument())
            if (DOMObject* docWrapper = getCachedDOMObjectWrapper(*Heap::heap(this)->globalData(), doc))
                if (!docWrapper->marked())
                    docWrapper->mark();
        DOMObject::mark();
        return;
    }

    // This is a node outside the document, so find the root of the tree it is in,
    // and start marking from there.
    Node* root = node;
    for (Node* current = m_impl.get(); current; current = current->parentNode())
        root = current;

    // If we're already marking this tree, then we can simply mark this wrapper
    // by calling the base class; our caller is iterating the tree.
    if (root->inSubtreeMark()) {
        DOMObject::mark();
        return;
    }

    // Mark the whole tree; use the global set of roots to avoid reentering.
    root->setInSubtreeMark(true);
    for (Node* nodeToMark = root; nodeToMark; nodeToMark = nodeToMark->traverseNextNode()) {
        JSNode* wrapper = getCachedDOMNodeWrapper(m_impl->document(), nodeToMark);
        if (wrapper) {
            if (!wrapper->marked())
                wrapper->mark();
        } else if (nodeToMark == node) {
            // This is the case where the map from the document to wrappers has
            // been cleared out, but a wrapper is being marked. For now, we'll
            // let the rest of the tree of wrappers get collected, because we have
            // no good way of finding them. Later we should test behavior of other
            // browsers and see if we need to preserve other wrappers in this case.
            if (!marked())
                mark();
        }
    }
    root->setInSubtreeMark(false);

    // Double check that we actually ended up marked. This assert caught problems in the past.
    ASSERT(marked());
}
Пример #4
0
void Board::makeHintMove()
{
	Path p;

	if(getHint_I(p))
	{
		mark_x = -1;
		mark_y = -1;
		marked(p.front().x, p.front().y);
		marked(p.back().x, p.back().y);
	}
}
Пример #5
0
void IOPoints::numDeg1(node v, int &xl, int &xr,
	bool doubleCount) const
{
	const List<InOutPoint> &L = m_out[v];
	ListConstIterator<InOutPoint> it;

	xl = xr = 0;
	for (it = L.begin(); it.valid() && marked((*it).m_adj); ++it)
		++xl;

	if (doubleCount || it.valid()) // avoid double counting if all are marked
		for (it = L.rbegin(); it.valid() && marked((*it).m_adj); --it)
			++xr;
}
Пример #6
0
// Compute the Number of leaves in the tree of color TreeColor
static int nb_leaves(GeometricGraph &G, short TreeColor, tbrin RootBrin,
		     svector<short> &ecolor)
  {svector<int> marked(1,G.ne(),0);  marked.SetName("marked");
  svector<bool> is_leaf(1,G.nv(),true);  is_leaf.SetName("is_leaf");
  tbrin b = RootBrin;
  int root_distance = 0;
  int nb_leaves = 0;
  while (1)
      {do
          {b = G.cir[b];
          if(b == RootBrin) return nb_leaves;
          }while (ecolor[b.GetEdge()] != TreeColor && !marked[b.GetEdge()]);

      if (!marked[b.GetEdge()])     // Montee dans l'arbre
          {root_distance++;
          marked[b.GetEdge()] = 1;
          b = -b;
          }
      else               // Descente
          {if (is_leaf[G.vin[b]])
              nb_leaves ++;
          root_distance--;
          is_leaf[G.vin[-b]] = false;
          b = -b;
          }
      }
  return nb_leaves;
  }
Пример #7
0
// sweep this node and all nodes reachable from it that
// haven't already been marked as reachable from roots
void JSON::sweep(boolean phase)
{
    if (!marked(phase))
    {
        switch (get_tag())
        {
            case Object_t:           
            case Array_t:
                AvlNode::apply(this->variant.object, (AvlApplyFn)sweep_item, (void *)phase);
                AvlNode::free(this->variant.object);
                break;
                
            case Thing_t:
                this->variant.thing->sweep(phase);
                WebThings::remove_thing(this->variant.thing);
                break;
                
            case Proxy_t:
                this->variant.proxy->sweep(phase);
                WebThings::remove_proxy(this->variant.proxy);
                break;
            
            case Unused_t:
                break;

            default:
                break;
        }
        
        free();
    }
}
Пример #8
0
// mark this node and nodes reachable from it
void JSON::reachable(boolean phase)
{
    if (!marked(phase))
    {   
        switch (get_tag())
        {
            case Object_t:           
            case Array_t:
                AvlNode::apply(this->variant.object, (AvlApplyFn)reachable_item, (void *)phase);
                break;
                
            case Thing_t:
                this->variant.thing->reachable(phase);
                break;
                
            case Proxy_t:
                this->variant.proxy->reachable(phase);
                break;
            
            case Unused_t:
                break;

            default:
                toggle_mark();
                break;
        }
    }
}
Пример #9
0
void Board::finish() {
  int x1, y1, x2, y2;
  History h[4];
  bool ready=FALSE;

  while(!ready && getHint_I(x1, y1, x2, y2, h)) {
    mark_x = -1;
    mark_y = -1;
    if(tilesLeft() == 2)
      ready = TRUE;
    marked(x1, y1);
    marked(x2, y2);
    kapp->processEvents();
    usleep(250*1000);
  }
}
Пример #10
0
Scheduler::schedulerchoice HLFscheduler::get_next_tasks(
    const Intree& t, 
    const vector<task_id>& _marked
) const {
    vector<task_id> marked(_marked);
    marked.erase(remove_if(marked.begin(), marked.end(),
        [&t](const task_id a) -> bool {
            return !t.contains_task(a);
        }), 
        marked.end()
    );
    auto tmp = Leafscheduler::get_next_tasks(t, marked);
    unsigned int maxlevel = 0; 
    for(auto const& it : tmp){
        maxlevel = t.get_level(it.first[0]) > maxlevel ? t.get_level(it.first[0]) : maxlevel;
    }
    tmp.erase(remove_if(tmp.begin(), tmp.end(),
                [maxlevel, t](const pair<vector<task_id>, myfloat>& a) -> bool {
                    if(a.first[0]==NOTASK)
                        return false;
                    return t.get_level(a.first[0])!=maxlevel;
                }), tmp.end());
    // normalize probability values
    myfloat sum = 0;
    for(auto const& it : tmp){
        sum += it.second;
    }
    for(unsigned int i=0; i<tmp.size(); ++i){
        tmp[i].second = tmp[i].second / sum;
    }
    return tmp;
}
Пример #11
0
static void mark_function(lua_State *L, lua_State *dL) {
	const void *p = lua_topointer(L, -1);
	int i;
	lua_Debug ar;
	char used_in[128];
	const char *name;
	
	
	if (!is_marked(dL, p)) {
		marked(dL, p, 0); //已经在table里头算了
		
		lua_pushvalue(L, -1);
		lua_getinfo(L, ">S", &ar);
		snprintf(used_in, sizeof(used_in) - 1, "%s:%d~%d", ar.short_src, ar.linedefined, ar.lastlinedefined);
		used_in[sizeof(used_in) - 1] = 0;
		
		for (i=1;;i++) {
			name = lua_getupvalue(L,-1,i);
			if (name == NULL)
				break;
			p = lua_topointer(L, -1);
			
			if (*name != '\0' && LUA_TTABLE == lua_type(L, -1)) {
				make_root(dL, p, name, RT_UPVALUE, used_in, 1);
				lua_insert(dL, MARKED_TABLE);
				mark_object(L, dL);
				lua_remove(dL, MARKED_TABLE);
			} else if (LUA_TFUNCTION == lua_type(L, -1)) {
				mark_function(L, dL);
			}
			lua_pop(L, 1);
		}
	}
}
Пример #12
0
 void Concat::reset_marks() const {
   if( marked() ) {
     unmark();
     left->reset_marks();
     right->reset_marks();
   }
 }
Пример #13
0
 wali::sem_elem_t Union::solve_recurse()
 {
   if( !marked() && !value.is_valid()) {
     mark();
     std::list< regex_t >::iterator it = children.begin();
     wali::sem_elem_t answer;
     for(; it != children.end(); it++ ) {
       regex_t child = *it;
       wali::sem_elem_t tmp = child->solve_recurse();
       if( answer.is_valid() ) {
         if( tmp.is_valid() ) {
           answer = answer->combine(tmp);
         }
         else {
           *wali::waliErr << "[WARNING] Concat::solve - "
             "A child was invalid (not all Root Regex's have a weight).\n";
         }
       }
       else {
         answer = tmp;
       }
     }
     value = answer;
   }
   return value;
 }
Пример #14
0
  /**
   * @brief Update the cost map based on aggregate observations
   * @todo Deprecate use of wx and wy here
   */
  void CostMap2D::updateDynamicObstacles(double wx, double wy, const std::vector<Observation>& observations)
  {
    // Revert to initial state
    memset(xy_markers_, 0, width_ * height_ * sizeof(bool));

    // Now propagate free space. We iterate again over observations, process only those from an origin
    // within a specific range, and a point within a certain z-range. We only want to propagate free space
    // in 2D so keep point and its origin within expected range
    for(std::vector<Observation>::const_iterator it = observations.begin(); it!= observations.end(); ++it){
      const Observation& obs = *it;
      if(!in_projection_range(obs.origin_.z))
        continue;

      const std_msgs::PointCloud& cloud = *(obs.cloud_);
      for(size_t i = 0; i < cloud.get_pts_size(); i++) {
        if(!in_projection_range(cloud.pts[i].z))
          continue;

        updateFreeSpace(obs.origin_, cloud.pts[i].x, cloud.pts[i].y);
      }
    }

    // Propagation queue should be empty from completion of last propagation.
    ROS_ASSERT(queue_.empty());

    // First we propagate costs. For this we iterate over observations, and process the internal point clouds
    for(std::vector<Observation>::const_iterator it = observations.begin(); it!= observations.end(); ++it){
      const Observation& obs = *it;
      const std_msgs::PointCloud& cloud = *(obs.cloud_);
      for(size_t i = 0; i < cloud.get_pts_size(); i++) {
        // Filter out points too high (can use for free space propagation?)
        if(cloud.pts[i].z > maxZ_)
          continue;

        //compute the squared distance from the hitpoint to the pointcloud's origin
        double sq_dist = (cloud.pts[i].x - obs.origin_.x) * (cloud.pts[i].x - obs.origin_.x) 
          + (cloud.pts[i].y - obs.origin_.y) * (cloud.pts[i].y - obs.origin_.y) 
          + (cloud.pts[i].z - obs.origin_.z) * (cloud.pts[i].z - obs.origin_.z);

        //Filter out points that are outside of the max range we'll consider
        if(sq_dist >= sq_obstacle_range_)
          continue;

        // Queue cell for cost propagation
        unsigned int ind = WC_IND(cloud.pts[i].x, cloud.pts[i].y);

        // If we have already processed the cell for this point, skip it
        if(marked(ind))
          continue;

        // Buffer for cost propagation. This will mark the cell
        unsigned int mx, my;
        IND_MC(ind, mx, my);
        enqueue(ind, mx, my);
      }
    }

    // Propagate costs
    propagateCosts();
  }
Пример #15
0
 vector<int> numIslands2(int m, int n, vector<pair<int, int>>& positions) {
     row = m;
     col = n;
     vector<int> res;
     UF uf(m*n);
     int count = 0;
     pair<int,int> pos[4] = {{0,1},{0,-1},{1,0},{-1,0}};
     vector<bool> marked(m*n+100, false);
     
     for(auto e : positions) {
         count++;
         int curisland = convert(e.first, e.second);
         marked[curisland] = true;
         for(int i = 0;i < 4;i++) {
             int posi = e.first + pos[i].first;
             int posj = e.second + pos[i].second;
             int neighborisland = convert(posi, posj);
             if(posi < 0 || posj < 0 || posi >= m || posj >= n || !marked[neighborisland]) continue;
             if(uf.connected(curisland, neighborisland)) {
                 continue;
             } else {
                 uf.Union(curisland, neighborisland);
                 count--;
             }
         }
         res.push_back(count);
     }
     return res;
 }
Пример #16
0
/*
 * Some revisions are less interesting than others.
 *
 * For example, if we use a cache-file, that one may contain
 * revisions that were never used. They are never interesting.
 *
 * And sometimes we're only interested in "edge" commits, ie
 * places where the marking changes between parent and child.
 */
static int interesting(struct revision *rev)
{
	unsigned mask = marked(rev);

	if (!mask)
		return 0;
	if (show_edges) {
		struct parent *p = rev->parent;
		while (p) {
			if (mask != marked(p->parent))
				return 1;
			p = p->next;
		}
		return 0;
	}
	return 1;
}
Пример #17
0
ListConstIterator<InOutPoint> IOPoints::searchRealBackward(
	ListConstIterator<InOutPoint> it) const
{
	while (it.valid() && marked((*it).m_adj))
		--it;

	return it;
}
Пример #18
0
void Player::mark(int index)
{
    if(p_board)
    {
        if(p_board->setSymbol(this->m_symbol, index))
            emit marked();
    }
}
Пример #19
0
void Board::finish()
{
	Path p;
	bool ready=false;

	while(!ready && getHint_I(p))
	{
		mark_x = -1;
		mark_y = -1;
		if(tilesLeft() == 2)
			ready = true;
		marked(p.front().x, p.front().y);
		marked(p.back().x, p.back().y);
		kapp->processEvents();
		usleep(250*1000);
	}
}
Пример #20
0
 void CostMap2D::enqueue(unsigned int source, unsigned int mx, unsigned int my){
   // If the cell is not marked for cost propagation
   unsigned int ind = MC_IND(mx, my);
   if(!marked(ind)){
     QueueElement* c = new QueueElement(computeDistance(source, ind), source, ind);
     queue_.push(c);
     mark(ind);
   }
 }
Пример #21
0
static void mark_table(lua_State *L, lua_State *dL) {
	const void *p = lua_topointer(L, -1);
	int len = 0;
	
	if (!is_marked(dL, p)) {
		marked(dL, p, 0);

		lua_pushnil(L);
		while (lua_next(L, -2) != 0) {
			++len;
			mark_object(L, dL);
			lua_pop(L, 1);
			mark_object(L, dL);
		}
		
		marked(dL, p, len);
	}
}
Пример #22
0
refSize makeSize(int count)
{ refSize newSize = malloc(sizeSize);
  if (newSize == nil)
  { fail("Cannot make a size for %i in makeSize!", count); }
  else
  { marked(newSize) = false;
    count(newSize)  = count;
    left(newSize)   = nil;
    right(newSize)  = nil;
    return newSize; }}
Пример #23
0
 void Union::reset_marks() const
 {
   if( marked() ) {
     unmark();
     std::list< regex_t >::const_iterator it = children.begin();
     for( ; it != children.end(); it++ ) {
       regex_t child = *it;
       child->reset_marks();
     }
   }
 }
Пример #24
0
 void Concat::to_mona_recurse(std::ostream& o, const std::string& prefix) const
 {
   if( !marked() ) {
     mark();
     left->to_mona_recurse(o,prefix);
     right->to_mona_recurse(o,prefix);
     monaHeader(o,prefix);
     o << "\n    ex1 r where p <= r & r <= q: ";
     left->monaName(o,prefix) << "(p,r) & ";
     right->monaName(o,prefix) << "(r,q);\n\n";
   }
 }
Пример #25
0
vector<Point> Solver::BFSolve(Maze::Ptr const& maze)
{
  queue<vector<Point> > paths;
  Point current = maze->GetStart();
  vector<Point> path;

  path.push_back(current);
  paths.push(path);

  vector<vector<bool> > marked(maze->Columns(), vector<bool>(maze->Rows(), false));

  while (!paths.empty())
  {
    path = paths.front();
    paths.pop();

    current = path.back();

    if (maze->GetFinish() == current)
      return path;

    if (maze->RightOpen(current) && !marked[current.Right().x()][current.Right().y()])
    {
      path.push_back(current.Right());
      paths.push(path);
      path.pop_back();
      marked[current.Right().x()][current.Right().y()] = true;
    }
    if (maze->DownOpen(current) && !marked[current.Down().x()][current.Down().y()])
    {
      path.push_back(current.Down());
      paths.push(path);
      path.pop_back();
      marked[current.Down().x()][current.Down().y()] = true;
    }
    if (maze->LeftOpen(current) && !marked[current.Left().x()][current.Left().y()])
    {
      path.push_back(current.Left());
      paths.push(path);
      path.pop_back();
      marked[current.Left().x()][current.Left().y()] = true;
    }
    if (maze->UpOpen(current) && !marked[current.Up().x()][current.Up().y()])
    {
      path.push_back(current.Up());
      paths.push(path);
      path.pop_back();
      marked[current.Up().x()][current.Up().y()] = true;
    }
  }

  return path;
}
Пример #26
0
adjEntry IOPoints::switchEndIn(node v)
{
	List<InOutPoint> &Lin  = m_in [v];
	List<InOutPoint> &Lout = m_out[v];

	ListConstIterator<InOutPoint> it;
	adjEntry adj;

	while ((it = Lin.rbegin()).valid() && marked(adj = (*it).m_adj))
		m_pointOf[adj] = &(*Lout.pushBack(Lin.popBackRet()));

	return it.valid() ? adj : 0;
}
Пример #27
0
InOutPoint IOPoints::middleNeighbor(node z1) const
{
	const List<InOutPoint> &L = m_in[z1];

	ListConstIterator<InOutPoint> it, itFound;
	int i,  pos = (L.size()-1)/2;

	for (it = L.begin().succ(), i = 1; i <= pos || !itFound.valid(); ++it, ++i)
		if (!marked((*it).m_adj))
			itFound = it;

	return *itFound;
}
Пример #28
0
inline static void clean_up_account_hooks(NewGC *gc)
{
  AccountHook *work = gc->hooks;
  AccountHook *prev = NULL;

  while(work) {
    if((!work->c1 || marked(gc, work->c1)) && marked(gc, work->c2)) {
      work->c1 = GC_resolve2(work->c1, gc);
      work->c2 = GC_resolve2(work->c2, gc);
      prev = work;
      work = work->next;
    } else {
      /* remove work hook */
      AccountHook *next = work->next;

      if(prev) prev->next = next;
      if(!prev) gc->hooks = next;
      ofm_free(work, sizeof(AccountHook));
      work = next;
    }
  }
}
Пример #29
0
/* TODO: maybe optimize this */
void WFrame::draw()
{
  WDrawable &d = wm().buffer_pixmap.drawable();
  WFrameStyle &style = wm().frame_style;

  WFrameStyleScheme &scheme = (marked() ? style.marked : style.normal);

  WFrameStyleSpecialized &substyle
    = (this == column()->selected_frame() ?
       (column() == column()->view()->selected_column() ?
        scheme.active_selected : scheme.inactive_selected)
       : scheme.inactive);

  if (decorated() || shaded())
  {

    WRect rect(0, 0, bounds.width, bounds.height);

    fill_rect(d, substyle.background_color, rect);

    draw_border(d, substyle.highlight_color, style.highlight_pixels,
                substyle.shadow_color, style.shadow_pixels,
                rect);

    WRect rect2 = rect.inside_tl_br_border(style.highlight_pixels,
                                           style.shadow_pixels);

    draw_border(d, substyle.padding_color, style.padding_pixels, rect2);

    WRect rect3 = rect2.inside_border(style.padding_pixels + style.spacing);
    rect3.height = wm().bar_height();

    // Draw the tag names
    utf8_string tags;
    {
      std::vector<utf8_string> tag_names;
      std::transform(client().view_frames().begin(),
                     client().view_frames().end(),
                     std::back_inserter(tag_names),
                     boost::bind(&WView::name,
                                 boost::bind(&WClient::ViewFrameMap::value_type::first, _1)));
      std::sort(tag_names.begin(), tag_names.end());
      BOOST_FOREACH(const utf8_string &str, tag_names)
      {
        tags += str;
        if (&str != &tag_names.back())
          tags += ' ';
      }
    }
Пример #30
0
/*
 * Constructs List L
 * L is the ordering for uncontracting the nodes in realizer
 */
void SchnyderLayout::contract(Graph& G, node a, node b, node c, List<node>& L)
{
	List<node> candidates;
	NodeArray<bool> marked(G, false);			// considered nodes
	NodeArray<int> deg(G, 0);					// # virtual neighbours

	int N = G.numberOfEdges();

	marked[a] = marked[b] = marked[c] = true;	// init outer face

	deg[a] = deg[b] = deg[c] = N;

	// mark neighbours of a and calc the degree of the second (virtual) neighbours
	for(adjEntry adj1 : a->adjEdges) {
		marked[adj1->twinNode()] = true;
		for(adjEntry adj2 : adj1->twinNode()->adjEdges) {
			deg[adj2->twinNode()]++;
		}
	}

	// find first candidates
	for(adjEntry adj1 : a->adjEdges) {
		if (deg[adj1->twinNode()] <= 2) {
			candidates.pushBack(adj1->twinNode());
		}
	}

	while (!candidates.empty()) {
		node u = candidates.popFrontRet();
		if (deg[u] == 2) {
			L.pushFront(u);
			deg[u] = N;
			for(adjEntry adj1 : u->adjEdges) {
				node v = adj1->twinNode();
				deg[v]--;										// u is virtualy deleted
				if (!marked[v]) {								// v is new neighbour of a
					marked[v] = true;
					for(adjEntry adj2 : v->adjEdges) {
						deg[adj2->twinNode()]++;				// degree of virtaul neighbours increase
					}
					if (deg[v] <= 2) candidates.pushBack(v);	// next candidate v
				}
				else
					if (deg[v] == 2) candidates.pushBack(v);	// next candidate v
			}
		}
	}
}