Ejemplo n.º 1
0
//////////////////////////////////
// list all entries with property
//
void DbIntlog::EntriesWithProperty(DbEntry::scopemode vProp, slist &l) const
{
    if (vProp == DbEntry::local)
    {
        slist_iter i(m_types);
        DbIntlog *db;

        while ((db = (DbIntlog*)i.next()) != 0)
        {
            EntryWithProp *ewp = new EntryWithProp;
            ewp->id = db->GetId();
            ewp->arity = -1;
            l.append(ewp);
        }
    }
    else
    {
        hashtable_iter it(this);
        DbEntry *dbe;

        while ((dbe = (DbEntry*)it.next()) != 0)
            if (dbe->vProp == vProp)
            {
                EntryWithProp *ewp = new EntryWithProp;
                ewp->id = dbe->funct;
                ewp->arity = dbe->arity;
                l.append(ewp);
            }
    }
}
Ejemplo n.º 2
0
int main()
{
	int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
	const slist<int> sl(arr, arr + sizeof(arr)/sizeof(arr[0]));
	
	for(auto i : sl)
		std::cout << i << ' ';
	std::cout << std::endl;

	auto iter = sl.begin();
	++iter;
	++iter;
	iter = sl.previous(iter);

	std::cout << *iter << std::endl;

	iter._M_node = __slist_reverse(iter._M_node);

	for(auto i : sl)
		std::cout << i << ' ';
	std::cout << std::endl;

	std::cout << *iter << std::endl;

	return 0;
}//main
Ejemplo n.º 3
0
// Purpose: to test the copy constructor
// Invoked as: CopyTist(some_slist);
void CopyTest(slist to_mod)
{
   // Add 6 to the end of the linked list
   to_mod.addRear(6);

   // Print its contents
   cout << "CopyTest display: ";
   to_mod.displayAll();
}
Ejemplo n.º 4
0
slist<ListType>::slist(const slist<ListType> &L)
{//note, reverses order in the circular list!

	list_size = ZERO;
	CurrentItem = NULL;

	while (list_size < L.Size())
		Insert(L.Next());
}
Ejemplo n.º 5
0
po::options_description store_and_notify(vector<string> argv,
                                         po::variables_map &vm,
                                         po::options_description* generic) {
   po::options_description config_file_options;
   populate_options(config_file_options);

   po::options_description cmdline_options;
   if (generic)
      cmdline_options.add(*generic);
   cmdline_options.add(config_file_options);

   /** Config hierarchy:
    *  - first,  command line arguments
    *  - second, /home/nao/data/configs/$hostname.cfg
    *  - third,  /home/nao/data/runswift.cfg
    *  - fourth, `pwd`/runswift.cfg
    **/
   // arguments from this call
   store(po::command_line_parser(argv).options(cmdline_options).run(), vm);

   // arguments from previous calls
   static slist<vector<string> > argvs;
   for (slist<vector<string> >::const_iterator argv_ci = argvs.begin();
        argv_ci != argvs.end(); ++argv_ci)
      store(po::command_line_parser(*argv_ci).options(cmdline_options).run(),
            vm);

   ifstream ifs;
   string hostname;

   ifs.open("/etc/hostname");
   ifs >> hostname;
   ifs.close();

   ifs.open(string("/home/nao/data/configs/" + hostname + ".cfg").c_str());
   store(parse_config_file(ifs, config_file_options), vm);
   ifs.close();

   ifs.open("/home/nao/data/runswift.cfg");
   store(parse_config_file(ifs, config_file_options), vm);
   ifs.close();

   ifs.open("runswift.cfg");
   store(parse_config_file(ifs, config_file_options), vm);
   ifs.close();

   /** Doesn't do anything right now, but will 'notify' any variables
    * we try to set via program_options */
   po::notify(vm);

   // assuming all options were valid and no exception was thrown, save argv for
   // repeated use
   argvs.push_front(argv);

   return cmdline_options;
}
Ejemplo n.º 6
0
template <typename T> void reverse_print(slist<T>& list) {
  stack<T> stack;
  typename slist<T>::Node* n = list.head();
  while (n != nullptr) {
    stack.push(n->value);
    n = n->next;
  }

  while (!stack.empty()) {
    cout << stack.top() << "   ";
    stack.pop();
  }
  cout << endl;
}
Ejemplo n.º 7
0
 friend auto operator==(const slist& left, const slist& right)
 {
     return left.count() == right.count() && (!left.node_ || *left.node_ == *right.node_);
 }
Ejemplo n.º 8
0
 slist(expression e, slist next) : node_(std::make_shared<node>(std::move(e), std::move(next.node_))), count_(next.count() + 1) { }