Exemplo n.º 1
0
void List::addAll(const IList* list){
  IIterator* iter = list->iterator();
  assert(iter != nullptr);
  while(iter->hasNext()){
    addBack(iter->next());
  }
  delete iter;  // don't forget to delete your iterator
}
Exemplo n.º 2
0
void
ImportsList::initialise( IList<IPosition<SourceToken> >& importPositions )
{	
	IIterator<IPosition<SourceToken> >* it = importPositions.elements();
	while ( it->hasNext() )
	{
		this->imports->insertLast( new Import( this->cu, it->next() ) );
	}
	delete it;
	this->addBlank();
}
Exemplo n.º 3
0
std::string List::toString() const {
  bool start = true;
  std::string strOut = "";
  IIterator* iter = iterator();
  if(!iter->hasNext()){ // empty list
    strOut += "[]";
  }
  else{
    while(iter->hasNext()){
      if(start){
        strOut += '[';
      }
      else{
        strOut += ',';
      }
      start = false;
      strOut += std::to_string(iter->next());
    }
    strOut += ']';
  }
  delete iter;
  return strOut;
}