Esempio n. 1
0
    void update( K key, UV val ) {
      uint64_t index = computeIndex( key );
      GlobalAddress< Cell > target = base + index; 

      Grappa::delegate::call( target.core(), [key, val, target]() {   // TODO: upgrade to call_async; using GCE
        // list of entries in this cell
        std::list<DHT_TYPE(Entry)> * entries = target.pointer()->entries;

        // if first time the cell is hit then initialize
        if ( entries == NULL ) {
          entries = new std::list<Entry>();
          target.pointer()->entries = entries;
        }

        // find matching key in the list
        typename std::list<DHT_TYPE(Entry)>::iterator i;
        for (i = entries->begin(); i!=entries->end(); ++i) {
          if ( i->key == key ) {
            // key found so update
            i->value = UpF(i->value, val);
            hash_tables_size+=1;
            return 0;
          }
        }

        // this is the first time the key has been seen
        // so add it to the list
        Entry newe( key, UpF(Init, val));

        return 0; 
      });
    }
Esempio n. 2
0
void
icososphere::subdivide( int span, float* v1, float* v2, float *v3
	, float* s1, float* s2, float* s3
	, float* e1, float* e2, float* e3 )
{
	if (span > 1) {
		int span2 = span>>1;

		float *v12 = avgptr(s1,e2);
		float *v23 = avgptr(s2,e3);
		float *v31 = avgptr(s3,e1);
		float *s12 = newe(span2);
		float *e31 = s12 + span2*3;
		float *s23 = newe(span2);
		float *e12 = s23 + span2*3;
		float *s31 = newe(span2);
		float *e23 = s31 + span2*3;

		for(int i=0;i<3;i++) {
			v12[i] = v1[i] + v2[i];
			v23[i] = v2[i] + v3[i];
			v31[i] = v3[i] + v1[i];
		}

		normalize(v12);
		normalize(v23);
		normalize(v31);

		subdivide( span2, v1, v12, v31
			, s1, s12, v31
			, e1, v12, e31);
		subdivide( span2, v2, v23, v12
			, s2, s23, v12
			, e2, v23, e12 );
		subdivide( span2, v3, v31, v23
			, s3, s31, v23
			, e3, v31, e23 );
		subdivide( span2, v12, v23, v31
			, e12, e23, e31
			, s12, s23, s31 );
	}
Esempio n. 3
0
	void ArchiveEditable::add(const _TCHAR *fn)
	{
		ListItr li = find(fn);
		if(li == list_.end()) {
			struct _stat st;
			if( 0 == _tstat(fn, &st) ) {
				if(st.st_mode & _S_IFDIR) { // ディレクトリなら
					TDIR *dir; tdirent *ent;
					dir = topendir(fn);
					while(dir) {
						ent = treaddir(dir);
						if(!ent) break;
						if(!_tcscmp(ent->d_name, _T(".")) && !_tcscmp(ent->d_name, _T(".."))) {
							basic_string<_TCHAR> path(fn); (path += _T("/")) += ent->d_name;
							add(path.c_str());
							PRN(path.c_str());
						}
					}
					tclosedir(dir);
				}
				else {
					// 最後尾に追加
					ArchiveEntry newe(fn);
					newe.time = st.st_mtime;
					newe.size = st.st_size;
					if(list_.size() > 0) newe.pos = list_.back().pos+list_.back().size;
					else newe.pos = 0;
					list_.push_back(EntryAttr(newe, EntryAttr::NEW));
				}
			}
		}
		else {
			struct _stat st;
			if( 0 == _tstat(fn, &st) && (li->time != st.st_mtime || li->size != st.st_size)) {
				li->attr = EntryAttr::UPDATE;
				li->time = st.st_mtime; li->size = st.st_size;
			}
			else if(li->attr == EntryAttr::REMOVE) li->attr = EntryAttr::ALREADY;
		}
	}