Exemplo n.º 1
0
bool JPetReader::loadData(const char* treename)
{
  if (!isOpen()) {
    ERROR("File not open");
    return false;
  }
  if (!treename) {
    ERROR("empty tree name");
    return false;
  }
  fTree = dynamic_cast<TTree*>(fFile->Get(treename));
  if (!fTree) {
    ERROR("in reading tree");
    return false;
  }
  TObjArray* arr = fTree->GetListOfBranches();
  fBranch = (TBranch*)(arr->At(0));
  if (!fBranch) {
    ERROR("in reading branch from tree");
    return false;
  }
  fBranch->SetAddress(&fEntry);
  firstEntry();
  return true;
}
Exemplo n.º 2
0
// 置換表にエントリーを登録する.
void ChainTable::store(const Key key, const Key after_key, const ChainElement& ce, const Bitboard& bb)
{
	ChainEntry *chain_entry, *replace;

	chain_entry = replace = firstEntry(key);

	// この局面のハッシュキーの上位32ビットを登録する.
	const uint32_t key32 = key >> 32;

	for (int i = 0; i < CLUSTER_SIZE; ++i, ++chain_entry)
	{
		// 空もしくはキーが一致
		if (!chain_entry->key() || chain_entry->key() == key32)
		{
			// 空のエントリーが見つかったので,そこを使う.
			replace = chain_entry;
			break;
		}

		// 登録されている局面より連鎖数が大きいなら,おそらく今の局面のほうが大事なのだろう.
		//if (ce.chain() > chain_entry->chainElement()->chain())
			//replace = chain_entry;

		// 常に上書きする。
		replace = chain_entry;
	}
	replace->save(key32, after_key, ce, bb);
}
Exemplo n.º 3
0
bool TranspositionTable::probe(const LightField* self, const LightField* enemy, TTEntry* &ptt) const
{
	Key key = OnePlayer ? self->key() : self->key() ^ enemy->key();

	// 最初のエントリーを取得
	TTEntry* const tte = firstEntry(key);
	uint32_t key32 = key >> 32;

	for (int i = 0; i < CLUSTER_SIZE; ++i)
	{
		// 空か、同じ局面が見つかった
		if (!tte[i].key32_ || (tte[i].key32_ == key32))
		{
			if (OnePlayer || (tte->player() == self->player())) // 手盤が一致
			{
				if (tte[i].generation_ != generation8_ && tte[i].key32_)
					tte[i].generation_ = generation8_; // Refresh

				ptt = &tte[i];
				return (bool)tte[i].key32_;
			}
		}
	}

	// 見つからなかったら、replaceできるポインタを返す。
	TTEntry* replace = tte;

	for (int i = 1; i < CLUSTER_SIZE; ++i)
		if (replace->depth_ > tte[i].depth_) // 一番残り深さの少ない局面をreplace候補とする
			replace = &tte[i];

	ptt = replace;
	return false;
}
Exemplo n.º 4
0
/* =============================================================================
 * rbtree_verify
 * =============================================================================
 */
long
rbtree_verify (rbtree_t* s, long verbose)
{
    node_t* root = s->root;
    if (root == NULL) {
        return 1;
    }
    if (verbose) {
       printf("Integrity check: ");
    }

    if (root->p != NULL) {
        printf("  (WARNING) root %lX parent=%lX\n",
               (unsigned long)root, (unsigned long)root->p);
        return -1;
    }
    if (root->c != BLACK) {
        printf("  (WARNING) root %lX color=%lX\n",
               (unsigned long)root, (unsigned long)root->c);
    }

    /* Weak check of binary-tree property */
    long ctr = 0;
    node_t* its = firstEntry(s);
    long int (*compare)(const void*, const void*) = s->compare->compare_notm;
    while (its != NULL) {
        ctr++;
        node_t* child = its->l;
        if (child != NULL && child->p != its) {
            printf("Bad parent\n");
        }
        child = its->r;
        if (child != NULL && child->p != its) {
            printf("Bad parent\n");
        }
        node_t* nxt = successor(its);
        if (nxt == NULL) {
            break;
        }
        if (compare(its->k, nxt->k) >= 0) {
            printf("Key order %lX (%ld %ld) %lX (%ld %ld)\n",
                   (unsigned long)its, (long)its->k, (long)its->v,
                   (unsigned long)nxt, (long)nxt->k, (long)nxt->v);
            return -3;
        }
        its = nxt;
    }

    long vfy = verifyRedBlack(root, 0);
    if (verbose) {
        printf(" Nodes=%ld Depth=%ld\n", ctr, vfy);
    }

    return vfy;
}
Exemplo n.º 5
0
boost::optional<OwnerAccessControlEntry> LocalDomainAccessStore::getOwnerAccessControlEntry(
        const std::string& userId,
        const std::string& domain,
        const std::string& interfaceName,
        const std::string& operation)
{
    QSqlQuery query = createGetAceQuery(GET_OWNER_ACE, userId, domain, interfaceName, operation);
    bool success = false;
    success = query.exec();
    assert(success);

    std::vector<OwnerAccessControlEntry> ownerAceList = extractOwnerAces(query);
    return firstEntry(ownerAceList);
}
Exemplo n.º 6
0
boost::optional<MasterAccessControlEntry> LocalDomainAccessStore::getMediatorAccessControlEntry(
        const std::string& uid,
        const std::string& domain,
        const std::string& interfaceName,
        const std::string& operation)
{
    QSqlQuery query = createGetAceQuery(GET_MEDIATOR_ACE, uid, domain, interfaceName, operation);
    bool success = false;
    success = query.exec();
    assert(success);

    std::vector<MasterAccessControlEntry> mediatorAceList = extractMasterAces(query);
    return firstEntry(mediatorAceList);
}
Exemplo n.º 7
0
// 置換表からkeyに一致するエントリーへのポインタを返す.
const ChainEntry* ChainTable::probe(const Key key) const 
{
	const ChainEntry* chain_entry = firstEntry(key);
	const uint32_t key32 = key >> 32;

	// キーに一致したら返す.
	for (int i = 0; i < CLUSTER_SIZE; ++i, ++chain_entry)
	{
		if (chain_entry->key() == key32)
			return chain_entry;
	}

	return nullptr;
}
Exemplo n.º 8
0
static int set_size(intset_t *set)
{
  int size;
  node_t *n;

  if (!rbtree_verify((rbtree_t *)set, 0)) {
    printf("Validation failed!\n");
    exit(1);
  }

  size = 0;
  for (n = firstEntry((rbtree_t *)set); n != NULL; n = successor(n))
    size++;

  return size;
}
Exemplo n.º 9
0
void TranspositionTable::store(const Key posKey, const Score score, const Bound bound, Depth depth,
  Move move, const Score evalScore)
{
#ifdef OUTPUT_TRANSPOSITION_EXPIRATION_RATE
  ++numberOfSaves;
#endif

  TTEntry* tte = firstEntry(posKey);
  TTEntry* replace = tte;
  const u32 posKeyHigh32 = posKey >> 32;

  if (depth < Depth0) {
    depth = Depth0;
  }

  for (int i = 0; i < ClusterSize; ++i, ++tte) {
    // 置換表が空か、keyが同じな古い情報が入っているとき
    if (!tte->key() || tte->key() == posKeyHigh32) {
      // move が無いなら、とりあえず古い情報でも良いので、他の指し手を保存する。
      if (move.isNone()) {
        move = tte->move();
      }

      tte->save(depth, score, move, posKeyHigh32,
        bound, this->generation(), evalScore);
      return;
    }

    int c = (replace->generation() == this->generation() ? 2 : 0);
    c += (tte->generation() == this->generation() || tte->type() == BoundExact ? -2 : 0);
    c += (tte->depth() < replace->depth() ? 1 : 0);

    if (0 < c) {
      replace = tte;
    }
  }

#ifdef OUTPUT_TRANSPOSITION_EXPIRATION_RATE
  if (replace->key() != 0 && replace->key() != posKeyHigh32) {
    ++numberOfCacheExpirations;
  }
#endif

  replace->save(depth, score, move, posKeyHigh32,
    bound, this->generation(), evalScore);
}
Exemplo n.º 10
0
TTEntry* TranspositionTable::probe(const Key posKey) {
  const Key posKeyHigh32 = posKey >> 32;
  TTEntry* tte = firstEntry(posKey);

  // firstEntry() で、posKey の下位 (size() - 1) ビットを hash key に使用した。
  // ここでは posKey の上位 32bit が 保存されている hash key と同じか調べる。
  for (int i = 0; i < ClusterSize && tte[i].key(); ++i) {
    if (tte[i].key() == posKeyHigh32) {
#ifdef OUTPUT_TRANSPOSITION_HIT_RATE
      ++numberOfHits;
#endif
      return &tte[i];
    }
  }
#ifdef OUTPUT_TRANSPOSITION_HIT_RATE
  ++numberOfMissHits;
#endif
  return nullptr;
}
Exemplo n.º 11
0
void DumpRenderTree::processArgsLine(const QStringList &args)
{
    setStandAloneMode(true);

    m_standAloneModeTestList = args;

    QFileInfo firstEntry(m_standAloneModeTestList.first());
    if (firstEntry.isDir()) {
        QDir folderEntry(m_standAloneModeTestList.first());
        QStringList supportedExt;
        // Check for all supported extensions (from Scripts/webkitpy/layout_tests/layout_package/test_files.py).
        supportedExt << "*.html" << "*.shtml" << "*.xml" << "*.xhtml" << "*.xhtmlmp" << "*.pl" << "*.php" << "*.svg";
        m_standAloneModeTestList = folderEntry.entryList(supportedExt, QDir::Files);
        for (int i = 0; i < m_standAloneModeTestList.size(); ++i)
            m_standAloneModeTestList[i] = folderEntry.absoluteFilePath(m_standAloneModeTestList[i]);
    }
    connect(this, SIGNAL(ready()), this, SLOT(loadNextTestInStandAloneMode()), Qt::QueuedConnection);

    if (!m_standAloneModeTestList.isEmpty()) {
        QString first = m_standAloneModeTestList.takeFirst();
        processLine(first);
    }
}
Exemplo n.º 12
0
void DumpRenderTree::processArgsLine(const QStringList &args)
{
    setStandAloneMode(true);

    for (int i = 1; i < args.size(); ++i)
        if (!args.at(i).startsWith('-'))
            m_standAloneModeTestList.append(args[i]);

    QFileInfo firstEntry(m_standAloneModeTestList.first());
    if (firstEntry.isDir()) {
        QDir folderEntry(m_standAloneModeTestList.first());
        QStringList supportedExt;
        // Check for all supported extensions (from Scripts/webkitpy/layout_tests/layout_package/test_files.py).
        supportedExt << "*.html" << "*.shtml" << "*.xml" << "*.xhtml" << "*.xhtmlmp" << "*.pl" << "*.php" << "*.svg";
        m_standAloneModeTestList = folderEntry.entryList(supportedExt, QDir::Files);
        for (int i = 0; i < m_standAloneModeTestList.size(); ++i)
            m_standAloneModeTestList[i] = folderEntry.absoluteFilePath(m_standAloneModeTestList[i]);
    }

    processLine(m_standAloneModeTestList.first());
    m_standAloneModeTestList.removeFirst();

    connect(this, SIGNAL(ready()), this, SLOT(loadNextTestInStandAloneMode()));
}
Exemplo n.º 13
0
void FilteringEdit::keyPressEvent(QKeyEvent *e)
{
    int key = e->key();
    Qt::KeyboardModifiers m = e->modifiers();
    const Qt::KeyboardModifiers generalMods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier;

    if (m == 0) {
        if (key == Qt::Key_Up) {
            emit prevEntry();
            return;
        }
        if (key == Qt::Key_Down) {
            emit nextEntry();
            return;
        }
        if (key == Qt::Key_PageDown) {
            emit nextPageOfEntries();
            return;
        }
        if (key == Qt::Key_PageUp) {
            emit prevPageOfEntries();
            return;
        }
    }

    if (key == Qt::Key_Return || key == Qt::Key_Enter) {
        if (m == 0) {
            emit selectedCurrentEntryWithText(this->toPlainText());
            return;
        }
        if (m == Qt::ShiftModifier) {
            if (m_allowSelectAll)
                emit selectAllEntries();
            else
                emit shiftSelectCurrentEntry();
            return;
        }
        if (m == Qt::ControlModifier) {
            emit selectedCurrentText(this->toPlainText());
            return;
        }

        if (m == Qt::ShiftModifier | Qt::ControlModifier) {
            emit getCurrentEntryForEdit();
            return;
        }
    }

    if (m == Qt::ControlModifier) {
        if (key == Qt::Key_Home) {
            emit firstEntry();
            return;
        }
        if (key == Qt::Key_End) {
            emit lastEntry();
            return;
        }
    }

    QTextEdit::keyPressEvent(e);
}