diff --git a/En_words b/En_words index 67943eb..170f90a 100644 --- a/En_words +++ b/En_words @@ -1181,7 +1181,6 @@ aftermarket aftermath aftermost afternoon -afternoon's afternoons after-sale aftersale @@ -1307,7 +1306,6 @@ agressive agribusiness agribusinesses agric -agric. agricultural agriculturalist agriculturally @@ -1472,7 +1470,6 @@ akc akimbo akin al -al. alabama alabamian alabaster @@ -1858,13 +1855,10 @@ alveolar alveolus always aly -a.m -a.m. am ama amah amain -amalg. amalgam amalgamate amalgamated @@ -2826,7 +2820,6 @@ appetizing appetizingly appian appl -appl. applaud applauder applauders @@ -2920,7 +2913,6 @@ approvement approving approvingly approx -approx. approximate approximately approximating @@ -3195,7 +3187,6 @@ armour armoured armpit armrest -arm's arms armstrong army @@ -3962,7 +3953,6 @@ avast avatar avaunt ave -ave. avenge avenged avenger @@ -6783,12 +6773,9 @@ churl churlish churn chute -c.i.a. cia cicada cider -c.i.f -c.i.f. cif cigar cigarette @@ -6843,8 +6830,6 @@ circumvent circumvention circus cirrhosis -c.i.s -c.i.s. cis cistern citadel @@ -7070,7 +7055,6 @@ clutch clutter cnn co -co. coach coachman coacting @@ -7138,7 +7122,6 @@ coco cocoa coconut cocoon -c.o.d. cod coddle code @@ -7867,7 +7850,6 @@ conjuncture conjurer conk conn -conn. connate connatural connect @@ -8335,7 +8317,6 @@ coronet coroutine coroutining corp -corp. corporal corporate corporation @@ -8343,7 +8324,6 @@ corporative corporeal corporeality corposant -corp.'s corps corpse corpsman @@ -9884,7 +9864,6 @@ depriving deprocedure deproceduring dept -dept. depth depth-first deputation @@ -10857,11 +10836,8 @@ dj dlimly dmv do -d.o.b -d.o.b. dob doc -doc. docile dock docked @@ -10869,7 +10845,6 @@ docker docket docking dockyard -docs. doctor doctoral doctorate @@ -11059,7 +11034,6 @@ doze dozen dp dpb -dr. drab drabness drachma @@ -11203,7 +11177,6 @@ dry-dock dryer dryly dryness -d.t.'s dual dual-head dual-headed @@ -11361,7 +11334,6 @@ dysprosium dystrophy dysurea ea -ea. each eager eagerly @@ -11539,8 +11511,6 @@ effrontery effulgent effusion effusive -e.g -e.g. eg egalitarian egg @@ -11850,7 +11820,6 @@ encircle encircled encirclement encl -encl. enclave enclose enclosed @@ -12172,7 +12141,6 @@ equiprobable equitable equitably equity -equiv. equivalence equivalent equivalent-to @@ -12255,7 +12223,7 @@ espouse espoused espousing espy -esq. +esq esquire essay essayist @@ -12290,7 +12258,6 @@ estuary et eta etc -etc. etcetera etch etched @@ -13081,7 +13048,6 @@ feces feckless fecund fed -fed. federal federalism federalist @@ -13242,7 +13208,6 @@ fifty fifty-fifty fifty/fifty fig -fig. fight fighter fighter-bomber @@ -13250,7 +13215,6 @@ fighter-pilot fighting figment figs -figs. figurative figuratively figure @@ -13653,8 +13617,6 @@ fmt foal foam foamy -f.o.b -f.o.b. fob focal foci @@ -14131,7 +14093,6 @@ frying frying-pan fsb ft -ft. ftc fuchsia fuchsin @@ -14703,7 +14664,6 @@ glycerin glycerine glycogen glycol -g.m. gmt gnarl gnarled @@ -16168,9 +16128,7 @@ however howitzer howl howsoever -h.p. hq -hrs. hub hubbub hubcap @@ -16420,8 +16378,6 @@ idol idolator idolize idyllic -i.e -i.e. ie ier if @@ -16474,7 +16430,6 @@ illumination illusion illusive illusory -illust. illustrate illustrated illustrating @@ -16733,7 +16688,6 @@ inauguration inauspicious inborn inc -inc. incalculable incandescence incandescent @@ -16849,7 +16803,6 @@ inconvenient inconvertible inconvincible incoordination -incorpor. incorporate incorporated incorporation @@ -16876,7 +16829,6 @@ incriminate incriminated incriminating incriminatory -inc.'s incubate incubated incubating @@ -17074,7 +17026,6 @@ influential influenza influx info -info. infological inform informal @@ -17918,7 +17869,6 @@ jowl joy joystick jr -jr. jubilant jubilee judaic @@ -18234,7 +18184,6 @@ labors labour labourite labours -labs. labware labyrinth labyrinthine @@ -19149,7 +19098,6 @@ loyal loyalty lozenge ltd -ltd. lubricant lubricate lubricated @@ -19531,7 +19479,6 @@ maple mapped mapping mar -mar. marabou maraschino marasmus @@ -19719,7 +19666,6 @@ mayonnaise mayor maze mazurka -m.b.a. mbo mbp mbyte @@ -20007,7 +19953,6 @@ mexico mezzanine mezzo-soprano mfg -mfg. mg mgm mgmt @@ -20373,7 +20318,6 @@ mockingbird mock-up mockup mod -mod. modal modality mode @@ -20712,16 +20656,12 @@ mozambique mpg mph mr -mr. mrs -mrs. ms -ms. msc msdos msds mtn -mtn. much much-needed mucilage @@ -21055,7 +20995,6 @@ nazi nazism nba ndearment -n.e. neal neanderthal near @@ -21315,7 +21254,6 @@ nixon nizhniy nlrb no -no. noah noahcian noahcic @@ -21662,9 +21600,6 @@ nuts nutter nutty nuzzle -n.w. -n.y -n.y. ny nylon nymph @@ -21823,7 +21758,6 @@ octopus octree ocular oculist -o.d. odd oddest oddity @@ -21921,8 +21855,6 @@ oilseed oilspill oily ointment -o.k -o.k. okapi okay oklahoma @@ -22597,7 +22529,6 @@ oxygenation oy oyster oz -oz. ozocerite ozone pa @@ -23988,7 +23919,6 @@ phasemeter phaseout phasic phasing -ph.d pheasant phenol phenomena @@ -24447,9 +24377,6 @@ pizzeria pizzicato pkg pkwy -p.&l. -p.l. -p/l placable placard placarder @@ -24678,7 +24605,6 @@ plowing plowman plowshare ploy -p.&l.s. pluck pluckily pluckiness @@ -24734,21 +24660,17 @@ pluvial ply plymouth plywood -p.m -p.m. pm pneumatic pneumatically pneumatically-operated pneumonia pneumonitis -p.o. poa poach poached poacher poaching -p.o.box pochard pock pocked @@ -25253,7 +25175,6 @@ pouter pouting poverty poverty-stricken -p.o.w. pow powder powdered @@ -25936,7 +25857,6 @@ productive productiveness productivity prof -prof. profanation profanatory profane @@ -26440,7 +26360,6 @@ psychotically psychotropic psychrophyl pt -pt. ptarmigan pterodactyl ptolemaic @@ -27865,7 +27784,6 @@ refutable refutation refute reg -reg. regain regal regale @@ -28700,7 +28618,6 @@ rio riot rioter riotous -r.i.p. rip ripcord ripe @@ -28796,7 +28713,6 @@ rogers roget rogue roguish -r.o.i. roi roil role @@ -30114,7 +30030,6 @@ scythe scythian sdcl sdr -s.e. sea seabed seabird @@ -32681,7 +32596,6 @@ smut smuts smuttiness smutty -s.n. snack snack-bar snaffle @@ -33186,7 +33100,6 @@ soothingly soothsayer soothsaying sooty -s.o.p sop soph sophia @@ -33494,7 +33407,6 @@ spearmint spearmints speary spec -spec. special specialist speciality @@ -33899,7 +33811,6 @@ spotty spousal spouse spout -spp. sprain sprained spraining @@ -33984,7 +33895,6 @@ spy spyglass spying sq -sq. squab squabble squabbler @@ -34084,8 +33994,6 @@ ssgt ssts ssw st -st. -st.- stab stabbed stabbing @@ -34702,7 +34610,6 @@ stitch stitched stitchery stitching -st.-john's-wort stoa stoat stochastic @@ -34840,9 +34747,6 @@ stowaway stowed stower stowing -st.peterburg -st.-petersburg -st.petersburg str strabismus strabotomy @@ -36208,8 +36112,6 @@ suzerainty svelte sverige svga -s.w -s.w. swab swaddle swaddling @@ -36889,7 +36791,6 @@ teaspoon teaspoonful teat tech -tech. techie technetium technic @@ -37341,7 +37242,6 @@ theosophical theosophically theosophist theosophy -ther. therapeutic therapeutical therapeutically @@ -39212,7 +39112,6 @@ ubiquity ucla uconn udder -u.f.o. ufo uganda ugandan @@ -39287,7 +39186,6 @@ umlaut umpire umpteen umpteenth -u.n. unabashed unabashedly unabated @@ -40705,11 +40603,7 @@ ursa ursine urticaria uruguay -u.s -u.s. us -u.s.a -u.s.a. usa usability usable @@ -40732,13 +40626,10 @@ user-friendly username users uses -u.s.gal usher usherette using usm -u.s.-soviet -u.s.s.r ussr usual usually @@ -40750,7 +40641,6 @@ usurpation usurped usurper usury -u.s.w.s utah utensil utensils @@ -40778,7 +40668,6 @@ uxorious uxoriousness uzbek va -va. vacancy vacant vacate @@ -41312,8 +41201,6 @@ vow vowel voxel voyage -v.p -v.p. vs vtvm vulcan @@ -41781,7 +41668,6 @@ webs web-server webster wed -wed. wedding wedge wedlock diff --git a/hashtest.c b/hashtest.c index f70b0e3..be70fd0 100644 --- a/hashtest.c +++ b/hashtest.c @@ -15,28 +15,25 @@ * along with this program. If not, see . */ -// RUN: gcc -lusefull_macros hashtest.c -o hashtest && time ./hashtest En_words -// check hashes for all words in given dictionary and show words with similar hashes - #include #include #include #define ALLOCSZ (5000) +#define DJB2 -//#if 0 +#if defined DJB2 // djb2 http://www.cse.yorku.ca/~oz/hash.html static uint32_t hash(const char *str){ uint32_t hash = 5381; uint32_t c; while((c = (uint32_t)*str++)) hash = ((hash << 5) + hash) + c; - // hash = hash * 19 + c; + //hash = hash * 31 + c; //hash = hash * 33 + c; return hash; } -//#endif -#if 0 +#elif defined SDBM static uint32_t hash(const char *str){ // sdbm uint32_t hash = 5381; uint32_t c; @@ -44,6 +41,19 @@ static uint32_t hash(const char *str){ // sdbm hash = c + (hash << 6) + (hash << 16) - hash; return hash; } +#elif defined JENKINS +uint32_t hash(const char *str){ + uint32_t hash = 0, c; + while((c = (uint32_t)*str++)){ + hash += c; + hash += (hash << 10); + hash ^= (hash >> 6); + } + hash += (hash << 3); + hash ^= (hash >> 11); + hash += (hash << 15); + return hash; +} #endif @@ -53,8 +63,9 @@ typedef struct{ } strhash; static int sorthashes(const void *a, const void *b){ - strhash *h1 = (strhash*)a, *h2 = (strhash*)b; - return strcmp(h1->str, h2->str); + register uint32_t h1 = ((strhash*)a)->hash, h2 = ((strhash*)b)->hash; + if(h2 > h1) return h2 - h1; + else return -((h1 - h2)); } int main(int argc, char **argv){