Example #1
0
TracePointVector
Trace::find_within_range(const GeoPoint &loc, const fixed range,
                         const unsigned mintime, const fixed resolution) const
{
  if (empty()) 
    return TracePointVector();
  
  TracePoint bb_target(loc);
  bb_target.project(task_projection);
  const unsigned mrange = task_projection.project_range(loc, range);

  // TracePointVector vectors;
  TracePointSet tset;
  TracePointSetFilterInserter filter(tset, mintime);
  trace_tree.find_within_range(bb_target, mrange, filter);

  /*
  // std::inserter(tset, tset.begin()));
  if (mintime>0) {
    TracePointSet::iterator tit = tset.lower_bound(bb_target);
    tset.erase(tset.begin(), tit);
  }
  */

  if (positive(resolution)) {
    const unsigned rrange = task_projection.project_range(loc, resolution);
    TracePointList tlist(tset.begin(), tset.end());
    thin_trace(tlist, rrange * rrange);
    return TracePointVector(tlist.begin(), tlist.end());
  } else {
    return TracePointVector(tset.begin(), tset.end());
  }
}
Example #2
0
TracePointVector
Trace::get_trace_points(const unsigned max_points) const
{
  TracePointSet tset(begin(), end());

  if (tset.empty())
    return TracePointVector();

  TracePointList tlist(tset.begin(), tset.end());

  unsigned mrange = 3;

  while (tlist.size() > max_points) {
    thin_trace(tlist, mrange);
    mrange = (mrange * 4) / 3;
  }

  return TracePointVector(tlist.begin(), tlist.end());
}
Example #3
0
TracePointVector
Trace::get_trace_points(const unsigned max_points) const
{
  if (max_points == 2) {
    if (trace_tree.size()<2) {
      return TracePointVector();
    }
    // special case - just look for points within time range
    TracePoint p;
    unsigned tmin = (unsigned)-1;
    for (TraceTree::const_iterator tr = trace_tree.begin();
         tr != trace_tree.end(); ++tr) {
      if (inside_time_window(tr->time) && (tr->time< tmin)) {
        p = *tr;
        tmin = tr->time;
      }
    }
    TracePointVector v;
    v.push_back(p);
    v.push_back(m_last_point);
    return v;
  }

  TracePointSet tset(begin(), end());

  if (tset.empty())
    return TracePointVector();

  TracePointList tlist(tset.begin(), tset.end());

  unsigned mrange = 3;

  while (tlist.size() > max_points) {
    thin_trace(tlist, mrange);
    mrange = (mrange * 4) / 3;
  }

  return TracePointVector(tlist.begin(), tlist.end());
}
Example #4
0
void parser_stream::undo(parser_stream_undo_type type)
{
    switch (type) {
    case parser_stream_undo_type::parsed_token_stream:
    {
	token_list tlist(m_parsed_token_stream->read_token_all());
	token_list orignal_tlist;
	std::for_each(tlist.begin(), tlist.end(), [&](token& t) {
		token_list sub_list(t.to_orignal_token_list());
		std::for_each(sub_list.begin(), sub_list.end(), [&](const token& sub_t) {
			orignal_tlist.push_back(sub_t);
		    });
	    });
	m_lexer->unread_token(orignal_tlist);
    }
    break;
    case parser_stream_undo_type::all:
    {
	m_lexer->unread_token(*m_token_streamer_read_token_list);
    }
    break;
    }
}
Example #5
0
/**
 * Convert the elements of the 'list' vector, which are SingleID
 * objects, into actual Transliterator objects.  In the course of
 * this, some (or all) entries may be removed.  If all entries
 * are removed, the NULL transliterator will be added.
 *
 * Delete entries with empty basicIDs; these are generated by
 * elements like "(A)" in the forward direction, or "A()" in
 * the reverse.  THIS MAY RESULT IN AN EMPTY VECTOR.  Convert
 * SingleID entries to actual transliterators.
 *
 * @param list vector of SingleID objects.  On exit, vector
 * of one or more Transliterators.
 * @return new value of insertIndex.  The index will shift if
 * there are empty items, like "(Lower)", with indices less than
 * insertIndex.
 */
void TransliteratorIDParser::instantiateList(UVector & list,
        UErrorCode & ec)
{
	UVector tlist(ec);
	if (U_FAILURE(ec))
	{
		goto RETURN;
	}
	tlist.setDeleter(_deleteTransliteratorTrIDPars);

	Transliterator * t;
	int32_t i;
	for (i = 0; i <= list.size(); ++i) // [sic]: i<=list.size()
	{
		// We run the loop too long by one, so we can
		// do an insert after the last element
		if (i == list.size())
		{
			break;
		}

		SingleID * single = (SingleID *) list.elementAt(i);
		if (single->basicID.length() != 0)
		{
			t = single->createInstance();
			if (t == NULL)
			{
				ec = U_INVALID_ID;
				goto RETURN;
			}
			tlist.addElement(t, ec);
			if (U_FAILURE(ec))
			{
				delete t;
				goto RETURN;
			}
		}
	}

	// An empty list is equivalent to a NULL transliterator.
	if (tlist.size() == 0)
	{
		t = createBasicInstance(ANY_NULL, NULL);
		if (t == NULL)
		{
			// Should never happen
			ec = U_INTERNAL_TRANSLITERATOR_ERROR;
		}
		tlist.addElement(t, ec);
		if (U_FAILURE(ec))
		{
			delete t;
		}
	}

RETURN:

	UObjectDeleter * save = list.setDeleter(_deleteSingleID);
	list.removeAllElements();

	if (U_SUCCESS(ec))
	{
		list.setDeleter(_deleteTransliteratorTrIDPars);

		while (tlist.size() > 0)
		{
			t = (Transliterator *) tlist.orphanElementAt(0);
			list.addElement(t, ec);
			if (U_FAILURE(ec))
			{
				delete t;
				list.removeAllElements();
				break;
			}
		}
	}

	list.setDeleter(save);
}
Example #6
0
void m1_copy_update(i4_bool all)
{
	w32 i;
	int t=0;
	i4_status_class * stat=i4_create_status(i4gets("updating_textures"));

	i4_array<i4_str *> tlist(64,64);

	i4_directory_struct ds;
	i4_get_directory(i4gets("default_tga_dir"), ds, i4_T);

	i4_array <m1_texture> network_tga_list(128,128);
	//if (!all)
//	  {
	m1_info.get_texture_list(tlist,all);
	t=tlist.size();
//	  }
//  else
//	  {
//	  t=ds.tfiles;
//	  }
	for (i=0; i<ds.tfiles; i++)
	{
		if (stat)
		{
			stat->update(i/(float)ds.tfiles);
		}

		m1_texture new_entry;

		new_entry.id            = r1_get_texture_id(*ds.files[i]);
		new_entry.last_modified = ds.file_status[i].last_modified;

		network_tga_list.add(new_entry);
	}

	if (stat)
	{
		delete stat;
	}

	stat = i4_create_status(i4gets("updating_textures"), i4_T);

	i4_directory_struct ds2;
	i4_get_directory(r1_get_compressed_dir(), ds2, i4_T);
	//i4_get_directory("textures",ds2,i4_T); //ds is "textures"
//  if (ds2.tfiles>t) t=ds.tfiles;//egal
	i4_array <m1_texture> local_gtx_list(128,128);

	m1_texture temp_tex;


	for (i=0; i<ds2.tfiles; i++)
	{
		if (stat && !stat->update(i/(float)ds2.tfiles))
		{
			if (stat)
			{
				delete stat;
			}
			return;
		}

		temp_tex.id            = r1_get_file_id(*ds2.files[i]); //get the number
		temp_tex.last_modified = ds2.file_status[i].last_modified;
		local_gtx_list.add(temp_tex);
	}

	if (stat)
	{
		delete stat;
	}
	stat = i4_create_status(i4gets("updating_textures"), i4_T);

	network_tga_list.sort(m1_texture_compare);
	local_gtx_list.sort(m1_texture_compare);

	for (i=0; i<t; i++)
	{
		if (stat && !stat->update(i/(float)t))
		{
			if (stat)
			{
				delete stat;
			}
			for (int ii=i; ii<t; ii++)
			{
				delete tlist[ii];
			}
			return;
		}

		if (tlist[i]->null())
		{
			continue;
		}
		i4_const_str tlistname("Texture_0000");
		if (*(tlist[i])==tlistname)
		{
			i4_warning("Skipped updating of anonymous texture %s", tlist[i]);
			delete tlist[i];
			continue; //continue if texture is not set (default texture name after conversion)
		}

		temp_tex.id = r1_get_texture_id(*tlist[i]);

		w32 network_index = network_tga_list.binary_search(&temp_tex,m1_texture_compare);
		if (network_index != -1)
		{
			w32 local_index = local_gtx_list.binary_search(&temp_tex,m1_texture_compare);

			if (local_index==-1 ||
				(local_gtx_list[local_index].last_modified<network_tga_list[network_index].last_modified)
			)
			{
				//m1_info.texture_list_changed();

				m1_update_texture(*tlist[i], i4_T,
								  stat,
								  i/(float)t, (i+1)/(float)t);
			}
		}
		else
		{
			char s1[256];
			char s2[256];
			char tga_dir[256];

			i4_os_string(*tlist[i],s1,256);
			i4_os_string(i4gets("default_tga_dir"),tga_dir,256);

			char * filename = remove_paths(s1);

			sprintf(s2,"Texture Missing: %s\\%s",tga_dir,filename);

			i4_str * n = i4_from_ascii(s2);
			i4_alert(*n,256);
			delete n;
		}

		delete tlist[i];
	}
	m1_info.texture_list_changed();
	if (stat)
	{
		delete stat;
	}
}
Example #7
0
int ForEachStatement::execImpl(QoreValue& return_value, ExceptionSink* xsink) {
   if (is_ref)
      return execRef(return_value, xsink);

   if (is_keys)
      return execKeys(return_value, xsink);

   // instantiate local variables
   LVListInstantiator lvi(lvars, xsink);

   // get list evaluation (although may be a single node)
   ReferenceHolder<AbstractQoreNode> tlist(list->eval(xsink), xsink);
   if (!code || *xsink || is_nothing(*tlist))
      return 0;

   qore_type_t t = tlist->getType();
   QoreListNode* l_tlist = t == NT_LIST ? reinterpret_cast<QoreListNode*>(*tlist) : 0;
   if (l_tlist) {
      if (l_tlist->empty())
         return 0;
   }
   else if (t == NT_OBJECT) {
      // check for an object derived from AbstractIterator
      AbstractIteratorHelper aih(xsink, "map operator", reinterpret_cast<QoreObject*>(*tlist));
      if (*xsink)
         return 0;
      if (aih)
         return execIterator(aih, return_value, xsink);
   }

   // execute "foreach" body
   unsigned i = 0;

   int rc = 0;

   while (true) {
      {
	 LValueHelper n(var, xsink);
	 if (!n)
	    break;

	 // assign variable to current value in list
	 if (n.assign(l_tlist ? l_tlist->get_referenced_entry(i) : tlist.release()))
	    break;
      }

      // set offset in thread-local data for "$#"
      ImplicitElementHelper eh(l_tlist ? (int)i : 0);

      // execute "foreach" body
      if (((rc = code->execImpl(return_value, xsink)) == RC_BREAK) || *xsink) {
	 rc = 0;
	 break;
      }

      if (rc == RC_RETURN)
	 break;
      else if (rc == RC_CONTINUE)
	 rc = 0;
      i++;
      // if the argument is not a list or list iteration is done, then break
      if (!l_tlist || i == l_tlist->size())
	 break;
   }

   return rc;
}
Example #8
0
int ForEachStatement::execRef(QoreValue& return_value, ExceptionSink* xsink) {
   int rc = 0;

   // instantiate local variables
   LVListInstantiator lvi(lvars, xsink);

   ParseReferenceNode* r = reinterpret_cast<ParseReferenceNode*>(list);

   // here we get the runtime reference
   ReferenceHolder<ReferenceNode> vr(r->evalToRef(xsink), xsink);
   if (*xsink)
      return 0;

   // get the current value of the lvalue expression
   ReferenceHolder<AbstractQoreNode> tlist(vr->eval(xsink), xsink);
   if (!code || *xsink || is_nothing(*tlist))
      return 0;

   QoreListNode* l_tlist = tlist->getType() == NT_LIST ? reinterpret_cast<QoreListNode*>(*tlist) : 0;
   if (l_tlist && l_tlist->empty())
      return 0;

   // execute "foreach" body
   ReferenceHolder<AbstractQoreNode> ln(0, xsink);
   unsigned i = 0;

   if (l_tlist)
      ln = new QoreListNode;

   while (true) {
      {
	 LValueHelper n(var, xsink);
	 if (!n)
	    return 0;

	 // assign variable to current value in list
	 if (n.assign(l_tlist ? l_tlist->get_referenced_entry(i) : tlist.release()))
	    return 0;
      }

      // set offset in thread-local data for "$#"
      ImplicitElementHelper eh(l_tlist ? (int)i : 0);

      // execute "for" body
      rc = code->execImpl(return_value, xsink);
      if (*xsink)
	 return 0;

      // get value of foreach variable
      AbstractQoreNode* nv = var->eval(xsink);
      if (*xsink)
	 return 0;

      // assign new value to temporary variable for later assignment to referenced lvalue
      if (l_tlist)
	 reinterpret_cast<QoreListNode*>(*ln)->push(nv);
      else
	 ln = nv;

      if (rc == RC_BREAK) {
	 // assign remaining values to list unchanged
	 if (l_tlist)
	    while (++i < l_tlist->size())
	       reinterpret_cast<QoreListNode*>(*ln)->push(l_tlist->get_referenced_entry(i));

	 rc = 0;
	 break;
      }

      if (rc == RC_RETURN)
	 break;
      else if (rc == RC_CONTINUE)
	 rc = 0;
      i++;

      // break out of loop if appropriate
      if (!l_tlist || i == l_tlist->size())
	 break;
   }

   // write the value back to the lvalue
   LValueHelper val(**vr, xsink);
   if (!val)
      return 0;

   if (val.assign(ln.release()))
      return 0;

   return rc;
}
Example #9
0
int tlist(

  tree *rootp,   /* I */
  char *Buf,     /* O (modified) */
  int   BufSize) /* I */

  {
  char tmpLine[32];

  int  BSize;

  /* check for bad inputs */
  if ((rootp == NULL) || (Buf == NULL))
    {
    /* empty tree - failure */

    return(1);
    }

  if (BufSize <= 16)
    {
    /* inadequate space to append data */

    return(-1);
    }

  BSize = BufSize;

  if (rootp->left != NULL)
    {
    tlist(rootp->left, Buf, BSize);

    BSize -= strlen(Buf);
    }

  if (rootp->right != NULL)
    {
    tlist(rootp->right, Buf, BSize);

    BSize -= strlen(Buf);
    }

  if (BSize <= 16)
    {
    /* inadequate space to append data */

    return(-1);
    }

  sprintf(tmpLine, "%ld.%ld.%ld.%ld",

          (rootp->key & 0xff000000) >> 24,
          (rootp->key & 0x00ff0000) >> 16,
          (rootp->key & 0x0000ff00) >> 8,
          (rootp->key & 0x000000ff));

  if ((Buf[0] != '\0') && (BSize > 1))
    {
    strcat(Buf, ",");

    BSize--;
    }

  if (BSize > (int)strlen(tmpLine))
    {
    strcat(Buf, tmpLine);
    }

  return(-1);
  }  /* END tlist() */