コード例 #1
0
ファイル: Partition.hpp プロジェクト: pohmann/WALi-OpenNWA
    // Return true if v1 and v2 are equivalent
    bool AreEquivalent(int v1, int v2) const
    {
      if (v1 == v2) {
	return true;
      }

      // The element does not exist, so we do not
      // know any equivalence information,
      // hence, v1 and v2 are not equivalent.
      if (!elementExists(v1) || !elementExists(v2)) {
	return false;
      }

      return disjoint_sets_.find_set(v1) == disjoint_sets_.find_set(v2);
    }
コード例 #2
0
bool CSVVector::isEmpty(int row, int column) const
{
    if(elementExists(row, column))
        return data[row][column].isEmpty();
    else
        return false;
}
コード例 #3
0
QString CSVVector::getString(int row, int column) const
{
    if(elementExists(row, column))
        return data[row][column].toString();
    else
        return QString("Not available");
}
コード例 #4
0
float CSVVector::get(int row, int column)
{
    if(elementExists(row, column))
        return data[row][column].getData();
    else
        return numeric_limits<double>::quiet_NaN();
}
コード例 #5
0
int DisjointSets< TYPE, _Compare >::IndexOf(const TYPE& element) const
{
	assert(elementExists(element));
	m_elementForComparison = &element;
	int indexOfElement = m_storedPointers.at(m_lookupConstant)->index;
	m_elementForComparison = NULL;
	return indexOfElement;
}
コード例 #6
0
void CSVVector::set(int row, int column, float value)
{
    if(elementExists(row, column))
    {
        data[row][column].setData(value);
        data[row][column].setEmpty(false);
    }
}
コード例 #7
0
	chunk* chunkPtrArray::getChunkPtr(int x, int y, int z){
		x -= originX; y -= originY; z -= originZ;
		if (!elementExists(x, y, z)) return nullptr;
#ifdef NEWORLD_DEBUG_PERFORMANCE_REC
		c_getChunkPtrFromCPA++;
#endif
		return array[x*size2 + y*size + z];
	}
コード例 #8
0
void DisjointSets< TYPE, _Compare >::Union(const TYPE& element1, const TYPE& element2)
{
	assert(elementExists(element1));
	assert(elementExists(element2));

	UNode<TYPE>* repr1 = getRepresentativeNode(element1);
	UNode<TYPE>* repr2 = getRepresentativeNode(element2);
	Union(repr1, repr2);

	// check if they are fused now
	TYPE& DBGref1 = getRepresentativeReference(element1);
	TYPE& DBGref2 = getRepresentativeReference(element2);
	assert(&DBGref1 == &DBGref2);
	// double check
	UNode<TYPE>* DBGrepr1 = getRepresentativeNode(element1);
	UNode<TYPE>* DBGrepr2 = getRepresentativeNode(element2);
	assert(DBGrepr1 == DBGrepr2);
}
コード例 #9
0
ファイル: Partition.hpp プロジェクト: pohmann/WALi-OpenNWA
    // Return the representative for the node v.
    int FindSet(int v) const
    {
      // If element does not exist
      if (!elementExists(v)) {
	// Then it is its own root.
	// This avoids adding singleton sets to the partition.
	return v;
      }

      return disjoint_sets_.find_set(v);
    }
コード例 #10
0
int DisjointSets< TYPE, _Compare >::addElementIfNotExists(const TYPE& element)
{
	if(!elementExists(element))
	{
		return addElement(element);
	}
	else
	{
		return IndexOf(element);
	}
}
コード例 #11
0
ファイル: Partition.hpp プロジェクト: pohmann/WALi-OpenNWA
    // Return a list of elements that are in the same disjoint set
    // as v.
    std::list<int> GetRelatedSet(int v) const
    {
      std::list<int> ret;
      if (!elementExists(v)) {
	ret.push_back(v);
	return ret;
      }
      int root = disjoint_sets_.find_set(v);
      root_set_map_t::const_iterator it = rootSetMap_.find(root);
      assert(it!=rootSetMap_.end());
      return it->second;
    }
コード例 #12
0
	void chunkIndexArray::AddChunk(int ci, int cx, int cy, int cz) {
		for (int x = 0; x != size; x++) {
			for (int y = 0; y != size; y++) {
				for (int z = 0; z != size; z++) {
					if (Array[x*size2 + y*size + z] >= ci) Array[x*size2 + y*size + z]++;
				}
			}
		}
		cx -= originX;
		cy -= originY;
		cz -= originZ;
		if (elementExists(cx, cy, cz)) Array[cx*size2 + cy*size + cz] = ci;
	}
コード例 #13
0
	void chunkPtrArray::move(int xd, int yd, int zd){
		chunk** arrTemp = new chunk*[size3];
		for (int x = 0; x < size; x++) {
			for (int y = 0; y < size; y++) {
				for (int z = 0; z < size; z++) {
					if (elementExists(x + xd, y + yd, z + zd))arrTemp[x*size2 + y*size + z] = array[(x + xd)*size2 + (y + yd)*size + (z + zd)];
					else arrTemp[x*size2 + y*size + z] = nullptr;
				}
			}
		}
		delete[] array;
		array = arrTemp;
		originX += xd; originY += yd; originZ += zd;
	}
コード例 #14
0
	void chunkIndexArray::move(int xd, int yd, int zd){
		int* arrTemp = new int[size3];
		for (int x = 0; x != size; x++) {
			for (int y = 0; y != size; y++) {
				for (int z = 0; z != size; z++) {
					if (elementExists(x + xd, y + yd, z + zd))
						arrTemp[x*size2 + y*size + z] = Array[(x + xd)*size2 + (y + yd)*size + (z + zd)];
					else
						arrTemp[x*size2 + y*size + z] = -1;
				}
			}
		}
		delete[] arrTemp;
		Array = arrTemp;
		originX += xd; originY += yd; originZ += zd;
	}
コード例 #15
0
QPixmap kMancalaRenderer::renderPixmap(QString name, const QSize size) {
    QPixmap p(size);
    p.fill(Qt::transparent);

    QPainter painter(&p);

    if ( !elementExists(name)) {
      qErrnoWarning("Element doesn't exist");
      return QPixmap();
    }

	qDebug() << "rendering Pixmap" << name;
    render(&painter, name, QRectF(0,0,size.width(), size.height()));
    painter.end();
	qDebug() << "rendering Pixmap done" << name;

    return p;
}
コード例 #16
0
int DisjointSets< TYPE, _Compare >::addElement(const TYPE& element)
{
	int returnedPosition;

	assert(!elementExists(element));

	m_storedElements.push_back(element);

	UNode<TYPE>* node = new UNode<TYPE>;
	node->count = 1;
	node->parent = NULL;
	node->rank = 0;
	node->index = m_numElements;
	//m_nodes.push_back(node);

	m_storedPointers[m_numElements] = node;

	returnedPosition = m_numElements;

	m_numElements++;
	m_numSets++;

	return returnedPosition;
}
コード例 #17
0
    int chunkIndexArray::getChunkIndex(int x,int y,int z){
		x -= originX; y -= originY; z -= originZ;
		if (!elementExists(x, y, z))  return -1;
		return Array[x*size2 + y*size + z];
    }
コード例 #18
0
TYPE DisjointSets< TYPE, _Compare >::getRepresentative(const TYPE& element) const
{
	assert(elementExists(element));
	UNode<TYPE>* representativeNode = getRepresentativeNode(element);
	return m_storedElements.at(representativeNode->index);
}
コード例 #19
0
int DisjointSets< TYPE, _Compare >::NumSetElements(const TYPE& element) const
{
	assert(elementExists(element));
	UNode<TYPE>* representativeNode = getRepresentativeNode(element);
	return representativeNode->count;
}
コード例 #20
0
	void chunkPtrArray::setChunkPtr(int x, int y, int z, chunk* c) {
		x -= originX; y -= originY; z -= originZ;
		if (!elementExists(x, y, z)) return;
		array[x*size2 + y*size + z] = c;
	}
コード例 #21
0
	void chunkPtrArray::AddChunk(chunk* cptr, int cx, int cy, int cz) {
		cx -= originX; cy -= originY; cz -= originZ;
		if (elementExists(cx, cy, cz)) array[cx*size2 + cy*size + cz] = cptr;
	}
コード例 #22
0
	void chunkPtrArray::DeleteChunk(int cx, int cy, int cz){
		cx -= originX; cy -= originY; cz -= originZ;
		if (elementExists(cx, cy, cz)) array[cx*size2 + cy*size + cz] = nullptr;
	}