I think they are all trimmed, although I should tell you right away - the code was only a glimpse and a long time ago, I could be wrong.
Look at the code to add an element
//+------------------------------------------------------------------+//| Insert the value with the specified key from the map. |//+------------------------------------------------------------------+
template<typename TKey,typename TValue>
bool CHashMap::Insert(TKey key,TValue value,constbool add)
{
if(m_capacity==0)
Initialize(0);
//--- get hash code from keyint hash_code=m_comparer.HashCode(key)&0x7FFFFFFF;int target_bucket=hash_code%m_capacity;
//--- collisions count in one bucket with different hashesint collision_count=0;
//--- search pair with specified keyfor(int i=m_buckets[target_bucket]; i>=0; i=m_entries[i].next)
{
//--- hash compare if(m_entries[i].hash_code!=hash_code)
{
collision_count++;
continue;
}
//--- value compare if(m_comparer.Equals(m_entries[i].key,key))
{
//--- adding duplicateif(add)
return(false);
m_entries[i].value=value;
return(true);
}
}
//--- check collisionif(collision_count>=m_collision_threshold)
{
int new_size=CPrimeGenerator::ExpandPrime(m_count);
Resize(new_size);
}
//--- calculate indexint index;
if(m_free_count>0)
{
index=m_free_list;
m_free_list=m_entries[index].next;
m_free_count--;
}
else
{
if(m_count==ArraySize(m_entries))
{
int new_size=CPrimeGenerator::ExpandPrime(m_count);
Resize(new_size);
target_bucket=hash_code%new_size;
}
index=m_count;
m_count++;
}
//--- set pairm_entries[index].hash_code=hash_code;
m_entries[index].next=m_buckets[target_bucket];
m_entries[index].key=key;
m_entries[index].value=value;
m_buckets[target_bucket]=index;
return(true);
}
Yes, thank you, there are simply no uncut ones in the code. Odd that the HashCode method itself didn't do any trimming. Apparently the calculation was for foolproof (crooked custom hashes).
void ReverseEnumerateAll(CList& list)
{
CObject* node = list.GetLastNode();
for(int i = list.Total()-1; node != NULL; i--, node = node.Prev())
printf("Element at " + (string)i);
}
Как работает этот код? На самом деле все просто. В функции EnumerateAll() в самом начале мы получаем ссылку на первый узел. Затем в цикле for мы печатаем порядковый узел этого узла
и переходим к следующему узлу командой node = node.Next(), не забывая при этом проитерировать текущий индекс элемента на единицу (i++). Перебор продолжается до тех пор, пока текущий
узел node не станет равен NULL, за это ответствен код во втором блоке for: node != NULL.
Аналогично работает реверсивная версия этой функции ReverseEnumerateAll() с той лишь разницей, что она вначале получает последний элемент списка CObject* node = list.GetLastNode().
В цикле for она получает не следующий, а предыдущий элемент списка node = node.Prev().
Apparently you don't mean inheritance, but a wrapper from a class over a structure?
Why is the sign bit cut off?
Why is the sign bit clipped?
the hash must be positive because it acts as an index in the array
hash must be positive, because it acts as an index in the array
uint?
uint?
doesn't make sense
makes no sense
The combination of highlighted lines seems to be erroneous.
Forum on trading, automated trading systems and trading strategies testing
Generic classes library - errors, description, questions, peculiarities of use and suggestions
fxsaber, 2018.06.11 20:04
How do you compare a trimmed hash to an uncut hash?
How can you compare a trimmed hash with an uncut hash?
I think they are all trimmed, although I must say right away - the code was only a glimpse and a long time ago, I could be wrong.
Look at the code to add the element
I think they are all trimmed, although I should tell you right away - the code was only a glimpse and a long time ago, I could be wrong.
Look at the code to add an element
Yes, thank you, there are simply no uncut ones in the code. Odd that the HashCode method itself didn't do any trimming. Apparently the calculation was for foolproof (crooked custom hashes).
Sorry if it already happened. I couldn't find it in the documentation.
Is there any loop on Set-ups?
Sorry if it already happened. I couldn't find it in the documentation.
Is there any loop on Set-ups?
Unfortunately, no.
But you can implement it yourself.
For example, see the example from the articleMQL5 RECEIPTS - REALIZE ASSOCIATED MASSIVE OR DICTIONARY FOR FAST DATA ACCESS