예제 #1
0
파일: view.cpp 프로젝트: malloc47/term-do
string View::formatList(list_t &list, const string d1, const string sep, const string d2) {
  string output = "";
  if(list.empty()) return output;
  FOR_l(i,list)
    output = output + (i==0 || is_dir(list[i-1]) || is_opt(list[i-1]) ? "" : sep) + list.at(i);
  return d1 + output + d2;
}
예제 #2
0
파일: task_copy.C 프로젝트: gnb/cant
gboolean
post_parse()
{
    if (file_ != 0)
    {
    	if (tofile_ == 0 && todir_ == 0)
	{
	    log::errorf("One of \"tofile\" or \"todir\" must be specified with \"file\"\n");
	    return FALSE;
	}
    }
    else if (filesets_.first() != 0)
    {
    	if (tofile_ != 0)
	{
	    log::errorf("Only \"todir\" is allowed with \"filesets\"\n");
	    return FALSE;
	}
    	if (todir_ == 0)
	{
	    log::errorf("Must use \"todir\" is \"filesets\"\n");
	    return FALSE;
	}
    }
    else if (file_ == 0 && filesets_.first() == 0)
    {
    	log::errorf("At least one of \"file\" or \"<fileset>\" must be present\n");
	return FALSE;
    }

    if (mapper_ == 0)
    	mapper_ = mapper_t::create("identity", 0, 0);

    return TRUE;
}
예제 #3
0
파일: Query.cpp 프로젝트: Aspenka/SSD
relation_data_t Query::getRelationModel(list_t values, Model * & model)
{
    relation_data_t rData;
    QList <Model *> list;
    if(!values.empty())
    {
        QStringList fields = model->getSchema()->getFields();
        int i = 0;
        while(i < values.size())
        {
            int j = i;
            Model * temp = new Model();
            temp->setSchema(model->getSchema());
            temp->setIsNew(false);
            while(values[j] != QPair <QString, QVariant> ("", ""))
            {
                if((fields.contains(values[j].first)) && (values[j].second != ""))
                {
                    temp->setField(values[j].first, values[j].second);
                }                
                j++;
            }
            list.append(temp);
            i = j + 1;
        }
    }
    rData.insert(rName, list);
    return rData;
}
예제 #4
0
 /** Mark an element as recently used. */
 void touch (const key_type& k)
 {
     auto found (map_.find(k));
     assert(found != map_.end());
     if (found != map_.end())
         list_.splice(list_.begin(), list_, found->second);
 }
예제 #5
0
    boost::optional<mapped_type&> try_get (const key_type& k)
    {
        auto found (map_.find(k));
        if (found == map_.end())
            return boost::optional<mapped_type&>();

        list_.splice(list_.begin(), list_, found->second);
        return found->second->second;
    }
예제 #6
0
handle_t *MEM_CacheLimiterCClass::insert(void *data)
{
	cclass_list.push_back(new MEM_CacheLimiterHandleCClass(data, this));
	list_t::iterator it = cclass_list.end();
	--it;
	cclass_list.back()->set_iter(it);

	return cache.insert(cclass_list.back());
}
예제 #7
0
 /** Prune the cache back to a given size.
  *  If the cache is larger than the maximum, the oldest entries
  *  will be deleted.
  * @post size() <= max_size
  * @param max_size  The maximum cache size */
 void prune (size_t max_size)
 {
     while (size_ > max_size)
     {
         map_.erase(list_.back().first);
         list_.pop_back();
         --size_;
     }
 }
예제 #8
0
파일: view.cpp 프로젝트: malloc47/term-do
list_t View::chopList(list_t list, const string prefix) {
  if(list.empty()) return list;
  FOR_l(i,list) {
    string item = list[i];
    // normal chop
    if(!item.compare(0,prefix.length(),prefix))
      list.at(i) = item.substr(prefix.length());
    else
      list.at(i) = "["+item+"]";
  }
예제 #9
0
static void remove_even(list_t &l) {
    bool even = false;
    for (auto it = l.begin(); it != l.end();) {
        if (even)
            it = l.erase(it);
        else
            ++it;

        even = !even;
    }
}
예제 #10
0
 void prune (size_t max_size, func on_remove)
 {
     while (size_ > max_size)
     {
         pair_t& tbr (list_.back());
         on_remove(tbr.first, tbr.second);
         map_.erase(tbr.first);
         list_.pop_back();
         --size_;
     }
 }
예제 #11
0
파일: view.cpp 프로젝트: malloc47/term-do
string View::formatList(list_t &list, const string d1, const string sep, const string d2,const unsigned int length) { 
  string output = "";
  if(list.empty()) return output;
  if(list.size()==1 && list.front().size()==0) return output;
  FOR_l(i,list)
    if(output.length() + list.at(i).length() + sep.length()*2 +
       d2.length()*2 + string("... ").length() > length) {
      output = output + sep + "... ";
      break;
    }
    else
      output = output + (i==0 ? "" : sep) + list.at(i);;
  return d1 + output + d2;
}
예제 #12
0
    /** Fetch an element from the cache.
     *  If the key does not exist yet, a new empty element will be
     *  created. */
    mapped_type& operator[] (const key_type& k)
    {
        auto found (map_.find(k));
        if (found == map_.end())
        {
            list_.push_front(pair_t(k, mapped_type()));
            map_[k] = list_.begin();
            ++size_;

            return list_.begin()->second;
        }
        list_.splice(list_.begin(), list_, found->second);

        return found->second->second;
    }
예제 #13
0
파일: task_copy.C 프로젝트: gnb/cant
gboolean
exec()
{
    list_iterator_t<fileset_t> iter;
    
    result_ = TRUE;
    ncopied_ = 0;
    
    exp_todir_ = expand(todir_);

    if (file_ != 0)
    {
    	string_var expfile = expand(file_);
    	copy_one(expfile, this);
    }

    /* execute for <fileset> children */
    
    for (iter = filesets_.first() ; iter != 0 ; ++iter)
	(*iter)->apply(project_->properties(), copy_one, this);
    
    exp_todir_ = (char*)0;

    return result_;
}
예제 #14
0
파일: task_copy.C 프로젝트: gnb/cant
~copy_task_t()
{
    if (mapper_ != 0)
	delete mapper_;
    
    /* delete filesets */
    // TODO: void unref(refcounted_t*)
    filesets_.apply_remove(unref);
}
예제 #15
0
파일: list.c 프로젝트: dsmrd/dsmrd
/*@null@*/ static node_t list_get_node_by_value(list_t inst, void* val) {
	node_t n = inst->head;
	int ctr = 0;
	while ((n != NULL) && (inst->cmp(node_get_value(n), val))) {
		ctr++;
		n = n->next;
	}
	return n;
}
예제 #16
0
    /** Remove an element from the cache. */
    void remove (const key_type& k)
    {
        auto found (map_.find(k));
        if (found == map_.end())
            return;

        list_.erase(found->second);
        map_.erase(found);
        --size_;
    }
예제 #17
0
파일: task_copy.C 프로젝트: gnb/cant
gboolean
add_fileset(xml_node_t *node)
{
    fileset_t *fs;

    if ((fs = parse_fileset(project_, node, "dir")) == 0)
    	return FALSE;
	
    filesets_.append(fs);
    return TRUE;
}
예제 #18
0
    void prune_if (size_t max_size, pred op)
    {
        if (list_.empty())
            return;

        auto i (std::prev(list_.end()));
        while (size_ > max_size)
        {
            if (op(*i))
            {
                map_.erase(i->first);
                i = list_.erase(i);
                --size_;
            }
            if (i == list_.begin())
                return;

            --i;
        }
    }
예제 #19
0
int list_find(list_t list, void *data){
    struct list_node *p = list->head;
    int i = 0;
    while (p != NULL) {
        if (list->eq(p->data, data))
            return i;
        i++;
        p = p->next;
    }
    return -1;
}
예제 #20
0
파일: list.c 프로젝트: dsmrd/dsmrd
int list_index_of(list_t inst, void* val) {
	node_t n = inst->head;
	int rval = 0;
	while ((n != NULL) && (inst->cmp(node_get_value(n), val))) {
		rval++;
		n = n->next;
	}
	if (n == NULL) {
		rval = -1;
	}
	return rval;
}
예제 #21
0
string_t
generate(const string_t& method, const list_t& arguments)
{
	std::string call("H\x02\x00""C"s);

	generator::value_visitor visitor(call);
	visitor(method);
	visitor(static_cast<int_t>(arguments.size()));
	for (const auto& argument : arguments)
		boost::apply_visitor(visitor, argument);

	return std::move(call);
}
예제 #22
0
파일: WORDCHAIN.cpp 프로젝트: blmarket/icpc
int walk2(list_t::iterator it, int s, int t)
{
    if(s==t) return 0;
    for(int i=0;i<30;i++)
    {
        if(links[s][i].size())
        {
            output.insert(it, mp(links[s][i].back(),s));
            links[s][i].pop_back();
            return walk2(it, i,t);
        }
    }
    return -1;
}
예제 #23
0
파일: WORDCHAIN.cpp 프로젝트: blmarket/icpc
void process(int dataId)
{
    int n;
    cin >> n;
    for(int i=0;i<30;i++) for(int j=0;j<30;j++) links[i][j].clear();
    output.clear();
    for(int i=0;i<n;i++)
    {
        string tmp;
        cin >> tmp;
        int c1 = tmp[0] - 'a';
        int c2 = *(tmp.rbegin()) - 'a';
        links[c1][c2].pb(tmp);
    }
}
예제 #24
0
파일: WORDCHAIN.cpp 프로젝트: blmarket/icpc
int pump(list_t::iterator it)
{
    int pos = it->second;
redo:
    for(int i=0;i<30;i++)
    {
        if(links[pos][i].size())
        {
            output.insert(it, mp(links[pos][i].back(), pos));
            links[pos][i].pop_back();
            if(walk2(it, i, pos) == -1) return -1;
            goto redo;
        }
    }
    return 0;
}
예제 #25
0
파일: list.c 프로젝트: dsmrd/dsmrd
void list_clear(list_t inst) {
	void* val;
	node_t n = inst->head;
	node_t m;
	while (n != NULL) {
		m = n->next;
		val = node_exit(n);
		//printf("exit val@%p\n", inst->val);
if (inst->lfree != NULL) {
		inst->lfree(val);
}
		n = m;
	}
	inst->head = NULL;
	inst->tail = NULL;
}
예제 #26
0
파일: WORDCHAIN.cpp 프로젝트: blmarket/icpc
void solve(int dataId)
{
    int s = -1, t= -1, use = -1;
    for(int i=0;i<26;i++)
    {
        int outd = 0, ind=0;
        for(int j=0;j<26;j++)
        {
            outd += links[i][j].size();
            ind += links[j][i].size();
        }
        if(outd || ind) use = i;
        if(outd > ind+1 || ind > outd+1)
        {
            cout << "IMPOSSIBLE" << endl;
            return;
        }
        if(outd > ind)
        {
            if(s != -1)
            {
                cout << "IMPOSSIBLE" << endl;
                return;
            }
            s = i;
        }
        if(ind > outd)
        {
            if(t != -1)
            {
                cout << "IMPOSSIBLE" << endl;
                return;
            }
            t = i;
        }
    }
    if(s == -1) s = t = use;

    if(walk2(output.end(), s, t) == -1)
    {
        cout << "IMPOSSIBLE" << endl;
        return;
    }
    output.pb(mp("", t));
    foreach(it, output)
    {
        if(pump(it) == -1)
        {
            cout << "IMPOSSIBLE" << endl;
            return;
        }
    }

    for(int i=0;i<30;i++) for(int j=0;j<30;j++) if(links[i][j].size())
    {
        cout << "IMPOSSIBLE" << endl;
        return;
    }

    output.pop_back();
    list_t::iterator it = output.begin();
    do
    {
        cout << it->first;
        ++it;
        if(it == output.end()) break;
        cout << " ";
    } while(true);
    cout << endl;
}
예제 #27
0
파일: SelNodes.hpp 프로젝트: CueMol/cuemol2
 int size() const { return m_list.size(); }
예제 #28
0
파일: SelNodes.hpp 프로젝트: CueMol/cuemol2
 LString pop_back() {
   LString ret = m_list.back().first;
   m_list.pop_back();
   return ret;
 }
예제 #29
0
void MEM_CacheLimiterCClass::destruct(void *data, list_t::iterator it)
{
	data_destructor(data);
	cclass_list.erase(it);
}
예제 #30
0
파일: SelNodes.hpp 프로젝트: CueMol/cuemol2
 LString pop_front() {
   LString ret = m_list.front().first;
   m_list.pop_front();
   return ret;
 }