Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.57 KB | None | 0 0
  1. <rocketmagnet> hi everyone, when i creat a hashtable from string with a certain max lenght, what hash functino should i use ?
  2. <VLetrmx> elichai2, right
  3. * MarcinWieczorek (~marcin@dynamic-78-8-18-159.ssp.dialog.net.pl) has joined
  4. * database2 has quit (Ping timeout: 245 seconds)
  5. * lsm513 (~lsm5@93.170.51.236) has joined
  6. * AmR|EiSa has quit (Remote host closed the connection)
  7. <computerquip> rocketmagnet, sort of depends but FNV is a solid fast and general purpose hash.
  8. * gloomy (~Gloomy@109.57.146.149.mobile.3.dk) has joined
  9. <VLetrmx> elichai2, might be worth mentioning that Linux does have a mechanism that will let you effectively override functions, this is LD_PRELOAD, so depending on what platforms you're running on that might be an option.
  10. * jamesbvaughan (~jamesbvau@2804:2728:101:83e:8524:92f3:d39b:c2fc) has joined
  11. * lsm513 has quit (Ping timeout: 250 seconds)
  12. <elichai2> VLetrmx: hmmm, and there isn't anything similiar in windows?
  13. * AmR||EiSa (~AmR-EiSa@197.166.97.10) has joined
  14. <VLetrmx> elichai2, Don't know sorry, I know almost nothing about Windows
  15. <elichai2> yeah I get it, I don't use linux either but don't want to break compatibility just because it's easier
  16. * jamesbvaughan has quit (Ping timeout: 252 seconds)
  17. * royal_screwup21 (3309aae6@gateway/web/cgi-irc/kiwiirc.com/ip.51.9.170.230) has joined
  18. <elichai2> VLetrmx: btw, if you're interested: https://github.com/rust-bitcoin/rust-secp256k1/pull/100#issuecomment-469002386
  19. <badSophia> void sayHi(char name[]) <— why char name[] is not array?
  20. <badSophia> i can’t understand it
  21. <badSophia> :(
  22. <computerquip> badSophia, because legacy C syntax says that's a pointer.
  23. * form24 (~form@2804:2728:101:57d:95f6:6792:a36c:473f) has joined
  24. <badSophia> i think that there is a reason
  25. <badSophia> :(
  26. <badSophia> i think that it is related with declaration?
  27. <badSophia> computerquip: ?
  28. <computerquip> No, you can't pass a C-array directly or by value.
  29. <rocketmagnet> how to avoid collisions with hashtables ?
  30. * Spinoza_ has quit (Remote host closed the connection)
  31. * Spinoza_ (~Spinoza@97-91-132-136.dhcp.stls.mo.charter.com) has joined
  32. <computerquip> rocketmagnet, hash algorithms are usually *good enough*. There's always a small chance you're going to collide at some point in your lifetime.
  33. <fstd> lol
  34. * fstd makes a mental note never to use a data structure written by computerquip
  35. <VLetrmx> elichai2, worth mentioning that LDPRELOAD can't help you there since you want to override during compilation and LD_PRELOAD happens at runtime.
  36. * badSophia has quit (Quit: badSophia)
  37. <murii> Is there any problem if I declare a variable like this in a header file: char **a; then in a .c file I do: a = some_other_var ?
  38. * Vante has quit (Ping timeout: 245 seconds)
  39. <computerquip> fstd must not realize that unless you use a cryptographic function where a collision hasn't been found yet, you're always at risk of a potential collision.
  40. <elichai2> VLetrmx: really? lol Ok, I'll delete that comment :)
  41. <computerquip> But it's not practical to use SHA256 for a hash table algorithm.
  42. * form24 has quit (Ping timeout: 257 seconds)
  43. <murii> Qt Creator tells me this: no previous extern declaration for non-static variable. I just want to be sure everything is alright
  44. <fstd> computerquip: have you ever actually implemented a hash table? you seem to have some fundamental misconceptions there
  45. <computerquip> fstd, like what?
  46. <koollman> computerquip: even if a collision hash has not been found, you are always at risk of collions. by design
  47. <koollman> if you had no collision risk, it would be a fantastic compression algorithm to hash any data :)
  48. * wigust has quit (Quit: ZNC 1.7.2 - https://znc.in)
  49. <fstd> which is why you need a way to deal with the collisions. computerquip: for starters, i don't think people use cryptographic hashes for hash tables (but even if they would, a means for dealing with collisions would be a good idea)
  50. * stefanc_diff has quit (Ping timeout: 268 seconds)
  51. * BCMM has quit (Quit: Konversation terminated!)
  52. <fstd> the last thing you want is data structures that can "lose" elements merely because someone deemed it unlikely enough
  53. <fstd> rocketmagnet: the usual approach is to select a 'bucket' of elements with your hash, function
  54. <fstd> essentially a list of entities stored that have the same hash
  55. <koollman> you have to deal with collisions, because it's a hash table. unless you're creating a perfect hash table, but then it's a pretty different problem with know input
  56. <fstd> to lookup, you find the bucket by hash, then find the desired element by comparing keys or somesuch
  57. <koollman> *known
  58. * CrystalMath (~coderain@reactos/developer/theflash) has joined
  59. <computerquip> Not sure how any of that conflicts with what I said but sure.
  60. <fstd> well you essentially said not to worry about collisions becuase they're unlikely enough, or did I misunderstand that?
  61. <computerquip> You did.
  62. <computerquip> But whatever.
  63. <fstd> feel free to clarify then
  64. <computerquip> You've already done that after insulting me for no reason.
  65. <fstd> after taking another look, it doesn't seem like that's what you originally had in mind
  66. <fstd> also where's the insult?
  67. * georgios (~georgios@unaffiliated/anaphaxeton) has joined
  68. * Wetmelon has quit (Ping timeout: 245 seconds)
  69. <computerquip> Not sure what you expect when you start rebuking me in less than 30 seconds before I can finish with what I was saying.
  70. <computerquip> I didn't know I was on a fucking timer here.
  71. * johnflux has quit (Ping timeout: 255 seconds)
  72. <koollman> computerquip: attention span on internet is like 5s. get to the point quickly ;)
  73. * Psylent has quit (Quit: wheee)
  74. * fstd shakes his head
  75. <fstd> how would I even know that it was but an introduction to get to your real point
  76. <fstd> assuming that's what you actually were going to do, that is
  77. <fstd> might also be the usual getting-defensive-over-being-wrong-and-backpedaling..
  78. * fstd shrugs
  79. <computerquip> I guess I wouldn't want to work with you in a work place.
  80. <fstd> trust me, the feeling is mutual
  81. <computerquip> I hope nobody does frankly.
  82. <fstd> you hope nobody wants to work with me? uh, okay
  83. <rocketmagnet> how can i compute a hascompute function if i know the exaclt lenght of my strings ?
  84. <fstd> says more about yourself than it does about me, tbh
  85. <computerquip> Actively trying to shit on people as fast as you can, not a very professional outlook there guy.
  86. <fstd> if you're frequently wrong, you need to learn to not take it as a personal offense when you get called out
  87. * wigust (~wigust@178.71.234.40) has joined
  88. <fstd> otherwise you might end up in the place you hope me to be in -- becasue nobody likes to work with those people
  89. * mowcat (~mowcat@cpc105070-sgyl40-2-0-cust220.18-2.cable.virginm.net) has joined
  90. <computerquip> fstd, I wasn't even wrong which is the problem.
  91. * mowcat has quit (Max SendQ exceeded)
  92. * mowcat (~mowcat@cpc105070-sgyl40-2-0-cust220.18-2.cable.virginm.net) has joined
  93. <computerquip> You went out of your way to shit on me for no reason.
  94. <computerquip> Am I wrong?
  95. <computerquip> Why would I work with someone who does that?
  96. <fstd> i just got the impression that you're trying to give advice on something you're not familiar with, which is often a bad idea
  97. <computerquip> So your first instinct is to insult them?
  98. * Vante (~Vant@host87-250-15-075.etth.mark-itt.net) has joined
  99. <computerquip> Not, "what do you mean by that" or, "I think that's wrong" but to insult them.
  100. * Me4502 has quit (Read error: Connection reset by peer)
  101. <fstd> where's the insult? [again]?
  102. <fstd> i didn't say "what do you mean by that" becasue it seemed perfectly clear what you meant by that
  103. <computerquip> You said you would never use a data structure written by me not to mention the other comments.
  104. <fstd> how is that an insult? and what other comments?
  105. * gist (~jack@88.130.155.248) has joined
  106. * Vante has quit (Client Quit)
  107. <computerquip> "fstd: computerquip: have you ever actually implemented a hash table?" You then proceeded to be more offensive by claiming I was being defensive when the conversation was over.
  108. * stefanc_diff (~stefanc_d@cpc97944-croy24-2-0-cust250.19-2.cable.virginm.net) has joined
  109. <fstd> i asked that question not to make a point, but because i actually wondered about that
  110. <fstd> maybe try to not take *everything* as a personal attack?
  111. <fstd> that said, i've missed the 'But it's not practical to use SHA256 for a hash table algorithm' earlier
  112. <fstd> so there's that.
  113. <computerquip> It's not a personal attack until you start directing insult directly towards me
  114. <computerquip> Not sure how that's hard to understand
  115. <computerquip> When I start having to be defensive about what I'm saying before I can even finish with what I'm saying, you're not going to get the full explanation.
  116. <fstd> we seem to have different ideas about what constitutes an insult
  117. <computerquip> I would never use code from fstd because because he's probably never written in C before.
  118. <fstd> computerquip: you need to resist hitting the return key then, when your follow-up message is so vital
  119. <computerquip> ^ how the fuck is that not an insult
  120. <fstd> computerquip: i don't feel insulted by it, for starters
  121. * computerquip walks away because holy shit.
  122. <fstd> ,next
  123. <cantdide> another satisfied customer! NEXT!!
  124. * RebelCoder (~RebelCode@62.208.39.206) has joined
  125. * Mattiaslndstrm has quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
  126. * talmobi has quit (Ping timeout: 240 seconds)
  127. <dorp> computerquip: If somebody said: "UB is a myth, everything is safe" ... and I would respond: "I would rather not use a program written by somebody who thinks that" ... would you still consider that to be an attempt by me to insult that person?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement