Beispiel #1
0
void ListIterator::assign(HashList& list, int offset)
{
    clear();
    m_hashList = &list;
    m_length = list.count();
    if (!m_length)
	return;
    m_objects = new GenObject* [m_length];
    m_hashes = new unsigned int[m_length];
    offset = (m_length - offset) % m_length;
    unsigned int i = 0;
    for (unsigned int n = 0; n < list.length(); n++) {
	ObjList* l = list.getList(n);
	if (!l)
	    continue;
	for (l = l->skipNull(); i < m_length; l = l->skipNext()) {
	    if (!l)
		break;
	    unsigned int idx = ((i++) + offset) % m_length;
	    m_objects[idx] = l->get();
	    m_hashes[idx] = l->get()->toString().hash();
	}
    }
    while (i < m_length)
	m_objects[((i++) + offset) % m_length] = 0;
}
Beispiel #2
0
	HashList Hash::GetAvailableAlgorithms ()
	{
		HashList l;
		
		l.push_back (shared_ptr <Hash> (new Sha512 ()));
		l.push_back (shared_ptr <Hash> (new Whirlpool ()));
		l.push_back (shared_ptr <Hash> (new Sha256 ()));
		l.push_back (shared_ptr <Hash> (new Ripemd160 ()));

		return l;
	}
Beispiel #3
0
void block_tx_hashes_impl(
    sync_blockchain& chain, HashList& tx_hashes, IndexType index)
{
    std::error_code ec;
    auto txs = chain.block_transaction_hashes(index, ec);
    check_errc(ec);
    for (const auto& inv: txs)
    {
        BITCOIN_ASSERT(inv.type == inventory_type_id::transaction);
        tx_hashes.push_back(to_binary(inv.hash));
    }
}
Beispiel #4
0
int main(){
	int n;
	while (1) {
		scanf("%d", &n);
		if (n == 0) break;
		hash.clean();
		for (int i=0; i<n; i++) {
			scanf("%d", a+i);
			hash.push(a[i]);
		}
		int ans = min, temp;
		for (int i=0; i<n; i++)
			for (int j=i+1; j<n; j++)
				for (int k=j+1; k<n; k++)
					if (hash.isExist(temp = a[i] + a[j] + a[k]))
						ans = max(ans, temp);
		if (ans == min) printf("no solution\n");
		else printf("%d\n", ans);
	}
	return 0;
}
Beispiel #5
0
int main()
{
    string temp;
    HashList first;
    first.DataInput("four hello");
    first.DataInput("second hello");
    first.DataInput("three hello");
    first.DataInput("th12345");
    first.DataInput("th33333");
    first.DataInput("th55555");
    temp = first.DataOutput("th12345");
    
    cout << temp << endl;
    return 0;
}
Beispiel #6
0
float containSketches(const HashList & hashesSortedRef, const HashList & hashesSortedQuery, float & errorToSet)
{
    int common = 0;
    int denom = hashesSortedRef.size() < hashesSortedQuery.size() ?
        hashesSortedRef.size() :
        hashesSortedQuery.size();
    
    int i = 0;
    int j = 0;
    
    for ( int steps = 0; steps < denom && i < hashesSortedRef.size(); steps++ )
    {
        if ( hashLessThan(hashesSortedRef.at(i), hashesSortedQuery.at(j), hashesSortedRef.get64()) )
        {
            i++;
            steps--;
        }
        else if ( hashLessThan(hashesSortedQuery.at(j), hashesSortedRef.at(i), hashesSortedRef.get64()) )
        {
            j++;
        }
        else
        {
            i++;
            j++;
            common++;
        }
    }
    
    errorToSet = 1. / sqrt(j);
    
    return float(common) / j;
}