用户操作
[即时聊天] [发私信] [加为好友]
heiyelurenID:heiyeshuwu
892426次访问,排名39好友93人,关注者144
既然决定远行,便只顾风雨兼程。
heiyeshuwu的文章
原创 282 篇
翻译 3 篇
转载 209 篇
评论 517 篇
heiyeluren的公告

联系方式:


访问统计: free hit counter code
FeedSky订阅:
FeedSky订阅
最近评论
heiyeluren:注册发帖后才能下载。。。。不知道论坛咋设置。。。 :-)
kong:注册了也不能下载.....提示您的操作将会导致您的 金钱 低于系统规定的下限值 0
赵舜尧:感谢博主的分享,期待你的“下章接着讲述数据分割和散列方面的内容”
adobe cs4:呃,LAMP经典应用……
俺的
Adobe cs4也是
bluehouse1985:Linux 环境下的多核调试
— Intel + Totalview 强强联合!
目前,在软件开发行业,各种性能优异的调试工具层出不穷。但是,它们中的绝大部分都只支持windows环境。即使能支持linux平台,操作起来也很不方便。因此,对于长期在linux上编写程序的开发人员来说,如何调试就成了一个令人头痛的问题!Intel软件 和 Total……
文章分类
收藏
    相册
    技术图片
    搜索引擎
    ::eYou::
    kevin world
    lewis - 老吕
    qyb - BT的花
    Realzay的blog
    叶金荣
    天堂地狱鬼-dulao5's Blog
    沙漠之周
    狐狸糊涂
    老韩
    與子觀化
    ::Yahoo::
    glemir’s blog
    happy_fish - 分布式文件系统FastDFS
    LinZi's Blog
    Rainx
    stauren
    互联网,请记住我 - 162同学的技术博客
    冰的河
    小蚂蚁同学滴测试博客
    张彪同学
    随网之舞 - kaven的DHTML博客
    风雪之隅
    ::朋友::
    【推荐】中文分类网
    DDR的博客
    kevin world
    miky
    PHPCup.cn论坛
    俺兄弟的blog
    冰河的技术博客:心随风动
    好旅网
    小少的技术博客
    无尘居
    晋陵路人的Blog
    李天华同学滴技术博客
    沙狐部落
    轻量级的editor
    ::网友::
    blankyao同学
    Code & Stock.
    LionD8的Blog
    MooPHP - 轻量级PHP框架
    Phzzy
    张贺同学的博客
    技术大牛老余的博客
    抚琴居
    旋木木同学滴博客
    矛盾网
    程序人生
    邢红瑞的blog
    阿健的博客
    :PHP博客:
    .: Easy style :.
    [琴剑楼]
    CoolCode.cn
    Haohappy的Blog
    Hightman
    iwind的blog
    Javascript开发站
    JD Space
    Nio's Weblog
    Open Source PHP
    PHP面对对象
    SourceForge.net
    trip的专栏
    UGIA.cn
    windix's blog
    Windix's Weblog
    一个藏袍
    俊麟 Michael`s blog
    偶然的blog
    刘敏的blog
    大龄青年的Blog
    廖宇雷的blog
    懒猫开始新生活blog
    某人的栖息地
    王春生的博客
    神仙
    :牛人blog:
    DBA notes
    http://blog.csdn.net/tingya/
    侯捷网站
    孟岩
    搜索引擎研究
    方舟
    王咏刚的BLOG
    竹笋炒肉
    荣耀
    车东[Blog^2]
    透明思考
    陈硕的Blog
    DHTML
    DHTMLGoodies
    FCKEditor
    Google Code
    Google Web Toolkit
    HTML Goodies
    HTML.it
    HTMLAre
    HTMLdog
    JavaScript Kit
    jQuery
    KindEditor
    Prototype
    TinyMCE
    W3 Schools
    Yahoo JavaScript Developer Center
    Yahoo! Developer Network
    Yahoo! UI Library (YUI)
    网页设计师Web标准
    Java国内站
    ChinaJavaWorld.com技术论坛
    IBM developerWorks 中国: Java
    Java中文站
    Java开源大全
    Java爱好者
    JR - Java翻译站
    J道-JDON
    Matrix: 与Java共舞
    中国Java开发网
    中文java技术网
    PHP国内站点
    CSDN PHP论坛
    Discuz!
    FleaPHP
    Google--PHP用户组
    IBM DeveloperWorks
    JavsScript技术讨论
    Nirvana Studio
    OpenPHP.cn
    PHPChina
    TiM Club
    中文 PFC 1.0 手册--PHP5的开发包
    中文 PFC 1.0 手册--PHP5的开发包
    中文PHP网
    太平洋--PHP开发区
    爱MySQL
    超越PHP
    PHP国外站点
    ADOdb
    Agavi Framework
    Cake PHP
    MySQL Performance Blog
    MySQL Performance Blog
    Nonaweb
    PEAR
    PECL
    PECL Windows
    PHP Builder
    PHP Classes
    PHP Classes
    PHP New Download
    PHP Security Consortium
    php.MVC
    php.MVC
    PHPkitchen(OO & MVC)
    phpPatterns
    PHP国外图书下载
    smart template
    Smarty
    SourceForge.net
    Symfony Framework
    Zend
    Zend Framework
    Unix C/C++
    Free Gentux
    周立发的blog(Linux C)
    Unix/Linux
    BSD智库
    ChinaUnix
    FreeBSDChina
    FreeLAMP
    IBM开发者Linux专区
    Linux Byte
    LinuxKit
    LinuxTS
    Linux伊甸园
    Linux技术中坚站
    Linux非常空间
    Love Unix
    NetBSD&OpenBSD中文用户组
    NetBSD中国社区
    Oracle中国用户讨论组
    OurLinux
    Unix中文
    Unix中文
    Unix中文宝库
    中国Linux公社
    中国Unix用户技术论坛
    中文FreeBSD用户组
    永远的Unix
    炎黄角马
    程序设计
    CSDN
    IBM开发者中心
    Microsoft TechNet: 主页
    MSDN 中文网站
    PHP中文站
    Sun技术社区
    中国IT认证实验室--企业应用技术
    中国协议分析网
    喜悦国际村
    太平洋电脑网---开发特区
    实用网站
    veBook(国外大量免费图书下载网站)
    Whois.net
    中国Web信息博物馆
    中国互联网络信息中心whois查询
    服务器系统信息查看
    网络安全
    AnySide.com
    CGI Secutiry
    K-OTik Security Monitoring
    Linux Security
    Packet Storm Security
    PHP Secure
    RFC中文文档索引
    Safemode.org
    SecuriTeam.com
    Security Corporation
    SecurityFocus
    SecurityTracker
    Zone-h (区域黑客,每天公布各国被黑的网站)
    中华安全网
    中国信息安全组织
    国家计算机网络应急处理中心
    安全天使
    安全焦点
    幻影旅团
    绿盟科技
    网络安全评估中心(cnns )
    在线手册
    Apache2.0中文文档
    Beyond Linux From Scratch
    Debian参考手册
    FreeBSD Porter 手册
    FreeBSD使用手册
    Linux C函数中文参考手册
    MySQL 4.1.0 中文参考手册
    NetBSD在线手册
    OpenBSD在线FAQ
    PHP ADODB 1.99版手册中文翻译(Tripc)
    PHP中文手册(国内)
    PHP中文手册(国外)
    PostgreSQL中文文档
    Red Hat Linux 9入门指南
    Red Hat Linux 9安装指南
    Red Hat Linux 9定制手册
    中国OSS技术手册中心
    技术文档手册中心-ChinaUnix
    存档
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    转载 [转]libhash中的哈希函数收藏

    新一篇: 一个PHP图表绘制类 - Chart | 旧一篇: [转]JpGraph简介 --功能超级强大的PHP画图库


    随便贴一个libhash中的hash函数,写的貌似不错,贴出来玩玩。

    hash.h

    /*
     * Australian Public Licence B (OZPLB)
     * 
     * Version 1-0
     * 
     * Copyright (c) 2004 National ICT Australia
     * 
     * All rights reserved. 
     * 
     * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS)
     *               National ICT Australia
     *               
    http://www.ertos.nicta.com.au
     
    */

    #ifndef _HASH_H
    #define _HASH_H

    #include 
    <stdint.h>

    struct hashtable {
            
    struct hashentry **table;
            unsigned 
    int size;
            
    struct hashentry *spares;
    };
        
    struct hashentry {
            
    struct hashentry *next;
            uintptr_t key;
            
    void *value;
    };

    struct hashtable *hash_init (unsigned int size);
    void hash_free (struct hashtable *tablestruct);
    uintptr_t hash_hash(uintptr_t key);
    void *hash_lookup (struct hashtable *tablestruct, uintptr_t key);
    int hash_insert (struct hashtable *tablestruct, uintptr_t key, void *value);
    void hash_remove (struct hashtable *tablestruct, uintptr_t key);

    #endif /* !_HASH_H */

     

    hash.c

    #include <stdint.h>
    #include 
    <stdlib.h>
    #include 
    <assert.h>

    #include 
    "hash.h"

    struct hashtable *
    hash_init (unsigned 
    int size)
    {
            
    struct hashtable *tablestruct;
            
    int counter;

            
    /* Our hash function only works with power-of-2 bucket sizes for speed. */
            assert ((size 
    & (size -1)) == 0);

            tablestruct 
    = malloc (sizeof (struct hashtable)); assert (tablestruct);
            
    if (!tablestruct) {
                    
    return NULL;
            }
            tablestruct
    ->table = malloc (size * sizeof (struct hashentry *));
            
    if (!tablestruct->table) {
                    
    return NULL;
            }
            
    for (counter=0; counter<size; counter++) {
                    tablestruct
    ->table[counter] = NULL;
            }
            assert (tablestruct
    ->table);
            tablestruct
    ->size = size;
            tablestruct
    ->spares = NULL;

            
    return tablestruct;
    }

    /* Ref http://www.concentric.net/~Ttwang/tech/inthash.htm */
    uintptr_t
    hash_hash(uintptr_t key)
    {
    #if (UINTPTR_MAX == UINT32_MAX)
            key 
    += ~(key << 15);
            key 
    ^=  (key >> 10);
            key 
    +=  (key << 3);
            key 
    ^=  (key >> 6);
            key 
    += ~(key << 11);
            key 
    ^=  (key >> 16);
    #elif (UINTPTR_MAX == UINT64_MAX)
            key 
    += ~(key << 32);
            key 
    ^= (key >> 22);
            key 
    += ~(key << 13);
            key 
    ^= (key >> 8);
            key 
    += (key << 3);
            key 
    ^= (key >> 15);
            key 
    += ~(key << 27);
            key 
    ^= (key >> 31);
    #else
    #error unsupported word size
    #endif
            
    //printf ("new key is %d ", key);
            return key;
    }

    void *
    hash_lookup (
    struct hashtable *tablestruct, uintptr_t key)
    {
            uintptr_t hash;
            
    struct hashentry *entry;

            hash 
    = hash_hash (key) & (tablestruct->size - 1);
            
    for (entry = tablestruct->table[hash]; entry != NULL; entry = entry->next) {
                    
    if (entry->key == key) {
                            
    return entry->value;
                    }
            }
            
    return NULL;
    }

    /* Add the key to the hash table. Assumes the key is not already present. */
    int
    hash_insert (
    struct hashtable *tablestruct, uintptr_t key, void *value)
    {
            uintptr_t hash;
            
    struct hashentry *entry;

            hash 
    = hash_hash (key) & (tablestruct->size - 1);
            
    //printf ("bucket is %d ", hash);

            entry 
    = malloc (sizeof (struct hashentry));
            
    if (!entry) {
                    
    return -1;
            }
            entry
    ->key = key;
            entry
    ->value = value;
            entry
    ->next = tablestruct->table[hash];

            tablestruct
    ->table[hash] = entry;
            
    return 0;
    }

    /* Removes the key from the hash table. Does not signal an error if the key
     * was not present. 
    */
    void
    hash_remove (
    struct hashtable *tablestruct, uintptr_t key)
    {
            uintptr_t hash;
            
    struct hashentry *entry, *tmpentry;

            hash 
    = hash_hash (key) & (tablestruct->size - 1);
            entry 
    = tablestruct->table[hash];
            
    /* If this is the first entry then it needs special handling. */
            
    if (entry && entry->key == key) {
                    tmpentry 
    = entry->next;
                    free (entry);
                    tablestruct
    ->table[hash] = tmpentry;
            } 
    else {
                    
    while (entry) {
                            
    if (entry->next && entry->next->key == key) {
                                    tmpentry 
    = entry->next;
                                    entry
    ->next = entry->next->next;
                                    free (tmpentry);
                                    
    break;
                            }
                            entry 
    = entry->next;
                    }
            }
    }

     

    hash_free.c

    #include <stdint.h>
    #include 
    <stdlib.h>

    #include 
    "hash.h"

    void
    hash_free (
    struct hashtable *tablestruct)
    {
            
    int counter;
            
    struct hashentry *entry, *prev;

            
    /* Need to free buckets and table struct and every item in every chain */
            
    for (counter=0; counter<tablestruct->size; counter++) {
                    entry 
    = tablestruct->table[counter];
                    
    while (entry) {
                            prev 
    = entry;
                            entry 
    = entry->next;
                            free (prev);
                    }
            }
            free (tablestruct
    ->table);
            free (tablestruct);
    }

     

    来源:http://ertos.nicta.com.au/software/kenge/libhash/devel/

    更多结果:http://www.google.cn/search?complete=1&hl=zh-CN&q=libhash&meta=

     

    发表于 @ 2007年06月18日 21:38:00|评论(loading...)|收藏

    新一篇: 一个PHP图表绘制类 - Chart | 旧一篇: [转]JpGraph简介 --功能超级强大的PHP画图库

    评论

    #venjiang 发表于2007-11-08 23:07:12  IP: 121.22.215.*
    文章写的都8错.评论少点.
    发表评论  


    登录
    Csdn Blog version 3.1a
    Copyright © heiyeluren