You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -325,8 +326,8 @@ We can implement the same functionality using a hash table. Wouldn't a hash tabl
325
326
326
327
<!-- Kun hajautustaulusta haetaan tietoa tietyllä avaimella, metodin hashCode perusteella selvitetään paikka, mistä tietoa haetaan. Samassa paikassa voi olla useampi value (listassa), jolloin haettavaa avainta verrataan jokaiseen listalla olevaan valueon equals-metodia käyttäen. Kun taulukosta haetaan valuea tietyllä avaimella -- eli indeksillä -- ei vastaavaa toiminnallisuutta tarvitse tehdä. Taulukossa joko on value tai valuea ei ole. Taulukkoon liittyy pieni tehokkuushyöty ohjelman suorituskyvyn kannalta. -->
327
328
When we search for a value of a key from a hash table, we use the hashCode method to find the index to search from.
328
-
There can be multiple values at the same index (on a list). Then we have to kompare the key we want to find the value for to the key of each key-value pair on the list using the equals method.
329
-
When we search for a a value of a key -- or index -- in an array, we do not have to do any of that.
329
+
There can be multiple values at the same index (on a list). Then we have to compare the key we want to find the value for to the key of each key-value pair on the list using the equals method.
330
+
When we search for a value of a key -- or index -- in an array, we do not have to do any of that.
330
331
An array either contains a certain value or it does not, so there is a small performance beneft on using arrays.
331
332
332
333
<!-- Tämä tehokkuushyöty kuitenkin tulee lisääntyneen virhealttiuden sekä työmäärän kustannuksella. Hajautustauluun on valmiiksi toteutettuna sisäisen taulukon kasvattaminen ja sen toiminnallisuutta on testattu hyvin laajasti. Taulukkoa käytettäessä tällaista etua ei ole -- uutta toiminnallisuutta toteuttaessa saattaa päätyä virheisiin, mikä kasvattaa työmäärää. Virheet ovat toki luonnollinen osa ohjelmistokehitystä. -->
@@ -335,7 +336,7 @@ Hash tables have tested and proven functionality for increasing the size of the
335
336
However, errors are accepted and natural part of software development.
336
337
337
338
<!-- Kun ajattelemme muistin käyttöä, hajautustaululla voi olla -- tapauksesta riippuen -- pieni etu. Kun taulukko luodaan, muistista varataan heti tila koko taulukolle. Mikäli taulukon jokaiseen indeksiin ei tarvitse lisätä tietoa, on osa tästä tiedosta varattuna turhaan. Hajautustaululla taas tällaista muistin varaamista ei ennakkoon tehdä -- hajautustaulun kokoa kasvatetaan tarvittaessa. -->
338
-
When we consider the memory usage, hash table might -- in some situations -- have some benefits.
339
+
When we consider the memory usage, hash tables might -- in some situations -- have some benefits.
339
340
When an array is created, enough memory for the whole array is allocated for it.
340
341
If we do not have values in each element of the array, some of the memory stays unused.
341
342
With hash tables this does not happen -- the size of the hash table is increased only when necessary.
0 commit comments