Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Bolji getHashCode sa String?

[es] :: .NET :: Bolji getHashCode sa String?

[ Pregleda: 299 | Odgovora: 3 ]

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Bongo_zg
zagreb

Član broj: 114214
Poruke: 33
*.dsl.siol.net.



Profil

icon Bolji getHashCode sa String?08.02.2008. u 15:03

za String object koristim getHashCode da bi dobio neki hash...
no, ovaj postojeci mi cesto daje iste vrijednosti za razlicite stringove...

da li postoji neki "bolji" hash umjesto standardnog?
htio bi dobiti neku 32bitnu vrijednost, a ne neki byte array
Think Big!
08.02.2008. u 15:03 

mmix
Miljan Mitrovic
Software Architect
Pancevo, Srbija

SuperModerator
Član broj: 17944
Poruke: 2398
195.252.78.*



Profil

icon Re: Bolji getHashCode sa String?08.02.2008. u 15:33
String.getHashCode je prilicno unique, morao bi bas da se potrudis da naletis na dva razlicita string (narocito smislena) sa istim hashom...
Koji stringovi ti generisu isti hash?
▪ The quicker a phone is answered in sales, the slower it's answered in customer services - Brownridge's Law
▪ Democracy is a device that ensures we shall be governed no better than we deserve - George Bernard Shaw
▪ To err is human--and to blame it on a computer is even more so - Robert Orben
08.02.2008. u 15:33 

Bongo_zg
zagreb

Član broj: 114214
Poruke: 33
*.dsl.siol.net.



Profil

icon Re: Bolji getHashCode sa String?08.02.2008. u 15:41
npr.
2055-3.html
i

2256-8.html
no, imam jos razlicitih primjera
Think Big!
08.02.2008. u 15:41 

mmix
Miljan Mitrovic
Software Architect
Pancevo, Srbija

SuperModerator
Član broj: 17944
Poruke: 2398
195.252.78.*



Profil

icon Re: Bolji getHashCode sa String?08.02.2008. u 16:00
Nesto ne radis kako valja, sledeci kod je dao sledeci rezultat, hashovi su razliciti..

Koji framework koristis i kako pozivas getHasCode()?

Code:


            Console.WriteLine("2055-3.html Hash: 0x{0:X8}", "2055-3.html".GetHashCode());
            Console.WriteLine("2256-8.html Hash: 0x{0:X8}", "2256-8.html".GetHashCode());
            Console.ReadLine();



Izlaz:
2055-3.html Hash: 0x03DBDE87
2256-8.html Hash: 0xD847FA85

▪ The quicker a phone is answered in sales, the slower it's answered in customer services - Brownridge's Law
▪ Democracy is a device that ensures we shall be governed no better than we deserve - George Bernard Shaw
▪ To err is human--and to blame it on a computer is even more so - Robert Orben
08.02.2008. u 16:00 

[es] :: .NET :: Bolji getHashCode sa String?

[ Pregleda: 299 | Odgovora: 3 ]

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.