{"action":"created","issue":{"url":"https://api.github.com/repos/Bazist/HArray/issues/2","repository_url":"https://api.github.com/repos/Bazist/HArray","labels_url":"https://api.github.com/repos/Bazist/HArray/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/Bazist/HArray/issues/2/comments","events_url":"https://api.github.com/repos/Bazist/HArray/issues/2/events","html_url":"https://github.com/Bazist/HArray/issues/2","id":197711848,"number":2,"title":"Wrong delete key (dozen)","user":{"login":"Bazist","id":17147971,"avatar_url":"https://avatars.githubusercontent.com/u/17147971?v=3","gravatar_id":"","url":"https://api.github.com/users/Bazist","html_url":"https://github.com/Bazist","followers_url":"https://api.github.com/users/Bazist/followers","following_url":"https://api.github.com/users/Bazist/following{/other_user}","gists_url":"https://api.github.com/users/Bazist/gists{/gist_id}","starred_url":"https://api.github.com/users/Bazist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bazist/subscriptions","organizations_url":"https://api.github.com/users/Bazist/orgs","repos_url":"https://api.github.com/users/Bazist/repos","events_url":"https://api.github.com/users/Bazist/events{/privacy}","received_events_url":"https://api.github.com/users/Bazist/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-27T14:40:09Z","updated_at":"2016-12-27T23:38:33Z","closed_at":null,"body":"Удаляем ключ 2.\r\n\r\nСюрприз 1: Удалился также и ключ 3!\r\n\r\nСюрприз 2: При попытке вставить ключ 2 обратно получаем SIGSEGV.\r\n\r\n#include \"stdafx.h\"\r\n#include <stdio.h>\r\n#include <math.h>\r\n#include <stdlib.h>\r\n#include <time.h>\r\n#include \"HArrayInt.h\"\r\n#include \"HArrayVarRAM.h\"\r\n \r\nusing namespace std;\r\n \r\nuint32 totalHArrayTime = 0;\r\nuint32 totalDenseTime = 0;\r\nuint32 totalMapTime = 0;\r\nuint32 totalUnorderedMapTime = 0;\r\n \r\nHArrayVarRAM ha;\r\n \r\nulong64 msclock()\r\n{\r\n\treturn (ulong64)clock() * 1000 / CLOCKS_PER_SEC; //in ms\r\n}\r\n \r\nuint32 key(const char* c) {\r\n\tchar* key1 = new char[sizeof(uint32)];\r\n\tmemset(key1,0,sizeof(uint32));\r\n\tstrcpy(key1,c);\r\n\treturn (uint32)(*key1);\r\n}\r\n \r\nvoid search(const char* msg, uint32* key1,uint32* key2) {\r\n\tHArrayFixPair pairs[32];\r\n\tuint32 val = ha.getKeysAndValuesByRange(pairs,sizeof(pairs)/sizeof(HArrayFixPair),key1,key2);\r\n\tprintf(\"%s %d\\n\",msg,val);\r\n\tfor( int i=0; i<val; i++ ) {\r\n\t\tHArrayFixPair p = pairs[i];\r\n\t\tprintf(\"  val %d = \",i);\t\r\n\t\tint n = p.KeyLen;\r\n\t\tfor( int n=0; n<p.KeyLen; n++ ) printf(\" %d\",p.Key[n]);\t\r\n\t\tprintf(\" = %d\\n\",p.Value);\t\r\n\t}\r\n}\r\n \r\nint main()\r\n{\r\n\tprintf(\"Pointer size: %ld\\n\",sizeof(void*));\r\n \r\n\tuint32 key1[] = { 100 };\r\n\tuint32 key2[] = { 100, 200 };\r\n\tuint32 key3[] = { 100, 200, 300 };\r\n \r\n\tha.init(26);\r\n \r\n\tha.insert(key1,sizeof(key1),12345678);\r\n\tha.insert(key2,sizeof(key2),22345678);\r\n\tha.insert(key3,sizeof(key3),32345678);\r\n \r\n\tuint32 ret = ha.getValueByKey(key1, sizeof(key1));\r\n\tprintf(\"%d -> %d\\n\",key1,ret);\r\n \r\n\tret = ha.getValueByKey(key2, sizeof(key2));\r\n\tprintf(\"%d -> %d\\n\",key2,ret);\r\n \r\n\tret = ha.getValueByKey(key3, sizeof(key3));\r\n\tprintf(\"%d -> %d\\n\",key3,ret);\r\n \r\n\tsearch(\"search\",key1,key3);\r\n \r\n\t// delete 2\r\n \r\n\tprintf(\"delete %d\\n\",key2);\r\n\tha.delValueByKey(key2, sizeof(key2), 0);\r\n\tret = ha.getValueByKey(key2, sizeof(key2));\r\n\tprintf(\"%d -> %d\\n\",key2,ret);\r\n \r\n\t// get 3 -> 3 has disappeared too!\r\n \r\n\tret = ha.getValueByKey(key3, sizeof(key3));\r\n\tprintf(\"%d -> %d\\n\",key3,ret);\r\n \r\n\t// re-insert 2\r\n \r\n\tha.insert(key2,sizeof(key2),22345678);\r\n\tret = ha.getValueByKey(key2, sizeof(key2));\r\n\tprintf(\"%d -> %d\\n\",key2,ret);\r\n \r\n\t// get 3 -> may be 3 has resurrected?\r\n \r\n\tret = ha.getValueByKey(key3, sizeof(key3));\r\n\tprintf(\"%d -> %d\\n\",key3,ret);\r\n \r\n\tha.printStat();\r\n\tha.destroy();\r\n \r\n\treturn 0;\r\n};\r\n"},"comment":{"url":"https://api.github.com/repos/Bazist/HArray/issues/comments/269398515","html_url":"https://github.com/Bazist/HArray/issues/2#issuecomment-269398515","issue_url":"https://api.github.com/repos/Bazist/HArray/issues/2","id":269398515,"user":{"login":"Bazist","id":17147971,"avatar_url":"https://avatars.githubusercontent.com/u/17147971?v=3","gravatar_id":"","url":"https://api.github.com/users/Bazist","html_url":"https://github.com/Bazist","followers_url":"https://api.github.com/users/Bazist/followers","following_url":"https://api.github.com/users/Bazist/following{/other_user}","gists_url":"https://api.github.com/users/Bazist/gists{/gist_id}","starred_url":"https://api.github.com/users/Bazist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bazist/subscriptions","organizations_url":"https://api.github.com/users/Bazist/orgs","repos_url":"https://api.github.com/users/Bazist/repos","events_url":"https://api.github.com/users/Bazist/events{/privacy}","received_events_url":"https://api.github.com/users/Bazist/received_events","type":"User","site_admin":false},"created_at":"2016-12-27T23:38:33Z","updated_at":"2016-12-27T23:38:33Z","body":"Fixed."}}
{"actor":{"display_login":"Bazist"}}