亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? hash_modify.c

?? 簡單的hash計算的類。實現了hash計算
?? C
字號:
/* Copyright 2000-2004 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.

 * split from apache for general usage by Yankee
 * use system malloc instead of apr_pool ,although it is not so effiecient but suitable for small
 * scale usage.
*/

//#include "apr_private.h"

//#include "apr_general.h"
//#include "apr_pools.h"

#include "hash_modify.h"

//#if APR_HAVE_STDLIB_H
#include <stdlib.h>
//#endif
//#if APR_HAVE_STRING_H
#include <string.h>
//#endif


/*
 * The internal form of a hash table.
 *
 * The table is an array indexed by the hash of the key; collisions
 * are resolved by hanging a linked list of hash entries off each
 * element of the array. Although this is a really simple design it
 * isn't too bad given that pools have a low allocation overhead.
 */

typedef struct apr_hash_entry_t apr_hash_entry_t;

struct apr_hash_entry_t {
    apr_hash_entry_t *next;
    unsigned int      hash;
    const void       *key;
    apr_ssize_t       klen;
    const void       *val;
};

/*
 * Data structure for iterating through a hash table.
 *
 * We keep a pointer to the next hash entry here to allow the current
 * hash entry to be freed or otherwise mangled between calls to
 * apr_hash_next().
 */
struct apr_hash_index_t {
    apr_hash_t         *ht;
    apr_hash_entry_t   *this, *next;
    unsigned int        index;
};

/*
 * The size of the array is always a power of two. We use the maximum
 * index rather than the size so that we can use bitwise-AND for
 * modular arithmetic.
 * The count of hash entries may be greater depending on the chosen
 * collision rate.
 */
struct apr_hash_t {
    apr_pool_t          *pool;
    apr_hash_entry_t   **array;
    apr_hash_index_t     iterator;  /* For apr_hash_first(NULL, ...) */
    unsigned int         count, max;
};

#define INITIAL_MAX 15 /* tunable == 2^n - 1 */


/*
 * Hash creation functions.
 */

static apr_hash_entry_t **alloc_array(apr_hash_t *ht, unsigned int max)
{
   return malloc(ht->pool, sizeof(*ht->array) * (max + 1));
}

apr_hash_t * apr_hash_make(void)
{
    apr_hash_t *ht;
    ht =malloc(pool, sizeof(apr_hash_t));
    ht->pool = pool;
    ht->count = 0;
    ht->max = INITIAL_MAX;
    ht->array = alloc_array(ht, ht->max);
    return ht;
}


/*
 * Hash iteration functions.
 */

apr_hash_index_t * apr_hash_next(apr_hash_index_t *hi)
{
    hi->this = hi->next;
    while (!hi->this) {
        if (hi->index > hi->ht->max)
            return NULL;

        hi->this = hi->ht->array[hi->index++];
    }
    hi->next = hi->this->next;
    return hi;
}

apr_hash_index_t * apr_hash_first(apr_pool_t *p, apr_hash_t *ht)
{
    apr_hash_index_t *hi;
    if (p)
        hi = malloc(p, sizeof(*hi));
    else
        hi = &ht->iterator;

    hi->ht = ht;
    hi->index = 0;
    hi->this = NULL;
    hi->next = NULL;
    return apr_hash_next(hi);
}

void apr_hash_this(apr_hash_index_t *hi,
                                const void **key,
                                apr_ssize_t *klen,
                                void **val)
{
    if (key)  *key  = hi->this->key;
    if (klen) *klen = hi->this->klen;
    if (val)  *val  = (void *)hi->this->val;
}


/*
 * Expanding a hash table
 */

static void expand_array(apr_hash_t *ht)
{
    apr_hash_index_t *hi;
    apr_hash_entry_t **new_array;
    unsigned int new_max;

    new_max = ht->max * 2 + 1;
    new_array = alloc_array(ht, new_max);
    for (hi = apr_hash_first(NULL, ht); hi; hi = apr_hash_next(hi)) {
        unsigned int i = hi->this->hash & new_max;
        hi->this->next = new_array[i];
        new_array[i] = hi->this;
    }
    ht->array = new_array;
    ht->max = new_max;
}

/*
 * This is where we keep the details of the hash function and control
 * the maximum collision rate.
 *
 * If val is non-NULL it creates and initializes a new hash entry if
 * there isn't already one there; it returns an updatable pointer so
 * that hash entries can be removed.
 */

static apr_hash_entry_t **find_entry(apr_hash_t *ht,
                                     const void *key,
                                     apr_ssize_t klen,
                                     const void *val)
{
    apr_hash_entry_t **hep, *he;
    const unsigned char *p;
    unsigned int hash;
    apr_ssize_t i;

    /*
     * This is the popular `times 33' hash algorithm which is used by
     * perl and also appears in Berkeley DB. This is one of the best
     * known hash functions for strings because it is both computed
     * very fast and distributes very well.
     *
     * The originator may be Dan Bernstein but the code in Berkeley DB
     * cites Chris Torek as the source. The best citation I have found
     * is "Chris Torek, Hash function for text in C, Usenet message
     * <27038@mimsy.umd.edu> in comp.lang.c , October, 1990." in Rich
     * Salz's USENIX 1992 paper about INN which can be found at
     * <http://citeseer.nj.nec.com/salz92internetnews.html>.
     *
     * The magic of number 33, i.e. why it works better than many other
     * constants, prime or not, has never been adequately explained by
     * anyone. So I try an explanation: if one experimentally tests all
     * multipliers between 1 and 256 (as I did while writing a low-level
     * data structure library some time ago) one detects that even
     * numbers are not useable at all. The remaining 128 odd numbers
     * (except for the number 1) work more or less all equally well.
     * They all distribute in an acceptable way and this way fill a hash
     * table with an average percent of approx. 86%.
     *
     * If one compares the chi^2 values of the variants (see
     * Bob Jenkins ``Hashing Frequently Asked Questions'' at
     * http://burtleburtle.net/bob/hash/hashfaq.html for a description
     * of chi^2), the number 33 not even has the best value. But the
     * number 33 and a few other equally good numbers like 17, 31, 63,
     * 127 and 129 have nevertheless a great advantage to the remaining
     * numbers in the large set of possible multipliers: their multiply
     * operation can be replaced by a faster operation based on just one
     * shift plus either a single addition or subtraction operation. And
     * because a hash function has to both distribute good _and_ has to
     * be very fast to compute, those few numbers should be preferred.
     *
     *                  -- Ralf S. Engelschall <rse@engelschall.com>
     */
    hash = 0;
    if (klen == APR_HASH_KEY_STRING) {
        for (p = key; *p; p++) {
            hash = hash * 33 + *p;
        }
        klen = p - (const unsigned char *)key;
    }
    else {
        for (p = key, i = klen; i; i--, p++) {
            hash = hash * 33 + *p;
        }
    }

    /* scan linked list */
    //????
    for (hep = &ht->array[hash & ht->max], he = *hep;
         he; hep = &he->next, he = *hep) {
        if (he->hash == hash
            && he->klen == klen
            && memcmp(he->key, key, klen) == 0)
            break;
    }
    if (he || !val)
        return hep;

    /* add a new entry for non-NULL values */
    he = malloc(ht->pool, sizeof(*he));
    he->next = NULL;
    he->hash = hash;
    he->key  = key;
    he->klen = klen;
    he->val  = val;
    *hep = he;
    ht->count++;
    return hep;
}

apr_hash_t * apr_hash_copy(apr_pool_t *pool,
                                        const apr_hash_t *orig)
{
    apr_hash_t *ht;
    apr_hash_entry_t *new_vals;
    unsigned int i, j;

    ht = apr_palloc(pool, sizeof(apr_hash_t) +
                    sizeof(*ht->array) * (orig->max + 1) +
                    sizeof(apr_hash_entry_t) * orig->count);
    ht->pool = pool;
    ht->count = orig->count;
    ht->max = orig->max;
    ht->array = (apr_hash_entry_t **)((char *)ht + sizeof(apr_hash_t));

    new_vals = (apr_hash_entry_t *)((char *)(ht) + sizeof(apr_hash_t) +
                                    sizeof(*ht->array) * (orig->max + 1));
    j = 0;
    for (i = 0; i <= ht->max; i++) {
        apr_hash_entry_t **new_entry = &(ht->array[i]);
        apr_hash_entry_t *orig_entry = orig->array[i];
        while (orig_entry) {
            *new_entry = &new_vals[j++];
            (*new_entry)->hash = orig_entry->hash;
            (*new_entry)->key = orig_entry->key;
            (*new_entry)->klen = orig_entry->klen;
            (*new_entry)->val = orig_entry->val;
            new_entry = &((*new_entry)->next);
            orig_entry = orig_entry->next;
        }
        *new_entry = NULL;
    }
    return ht;
}

void * apr_hash_get(apr_hash_t *ht,
                                 const void *key,
                                 apr_ssize_t klen)
{
    apr_hash_entry_t *he;
    he = *find_entry(ht, key, klen, NULL);
    if (he)
        return (void *)he->val;
    else
        return NULL;
}

void apr_hash_set(apr_hash_t *ht,
                               const void *key,
                               apr_ssize_t klen,
                               const void *val)
{
    apr_hash_entry_t **hep;
    hep = find_entry(ht, key, klen, val);
    if (*hep) {
        if (!val) {
            /* delete entry */
            *hep = (*hep)->next;
            --ht->count;
        }
        else {
            /* replace entry */
            (*hep)->val = val;
            /* check that the collision rate isn't too high */
            if (ht->count > ht->max) {
                expand_array(ht);
            }
        }
    }
    /* else key not present and val==NULL */
}

unsigned intapr_hash_count(apr_hash_t *ht)
{
    return ht->count;
}

apr_hash_t* apr_hash_overlay(apr_pool_t *p,
                                          const apr_hash_t *overlay,
                                          const apr_hash_t *base)
{
    return apr_hash_merge(p, overlay, base, NULL, NULL);
}

apr_hash_t *apr_hash_merge(apr_pool_t *p,
                                         const apr_hash_t *overlay,
                                         const apr_hash_t *base,
                                         void * (*merger)(apr_pool_t *p,
                                                     const void *key,
                                                     apr_ssize_t klen,
                                                     const void *h1_val,
                                                     const void *h2_val,
                                                     const void *data),
                                         const void *data)
{
    apr_hash_t *res;
    apr_hash_entry_t *new_vals = NULL;
    apr_hash_entry_t *iter;
    apr_hash_entry_t *ent;
    unsigned int i,j,k;


    res = malloc(p, sizeof(apr_hash_t));
    res->pool = p;
    res->count = base->count;
    res->max = (overlay->max > base->max) ? overlay->max : base->max;
    if (base->count + overlay->count > res->max) {
        res->max = res->max * 2 + 1;
    }
    res->array = alloc_array(res, res->max);
    if (base->count + overlay->count) {
        new_vals =  malloc(p, sizeof(apr_hash_entry_t) *
                              (base->count + overlay->count));
    }
    j = 0;
    for (k = 0; k <= base->max; k++) {
        for (iter = base->array[k]; iter; iter = iter->next) {
            i = iter->hash & res->max;
            new_vals[j].klen = iter->klen;
            new_vals[j].key = iter->key;
            new_vals[j].val = iter->val;
            new_vals[j].hash = iter->hash;
            new_vals[j].next = res->array[i];
            res->array[i] = &new_vals[j];
            j++;
        }
    }

    for (k = 0; k <= overlay->max; k++) {
        for (iter = overlay->array[k]; iter; iter = iter->next) {
            i = iter->hash & res->max;
            for (ent = res->array[i]; ent; ent = ent->next) {
                if ((ent->klen == iter->klen) &&
                    (memcmp(ent->key, iter->key, iter->klen) == 0)) {
                    if (merger) {
                        ent->val = (*merger)(p, iter->key, iter->klen,
                                             iter->val, ent->val, data);
                    }
                    else {
                        ent->val = iter->val;
                    }
                    break;
                }
            }
            if (!ent) {
                new_vals[j].klen = iter->klen;
                new_vals[j].key = iter->key;
                new_vals[j].val = iter->val;
                new_vals[j].hash = iter->hash;
                new_vals[j].next = res->array[i];
                res->array[i] = &new_vals[j];
                res->count++;
                j++;
            }
        }
    }
    return res;
}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩视频在线第一区| 欧美经典一区二区| 久久夜色精品一区| 亚洲激情图片一区| 蜜桃视频在线观看一区二区| 一本色道a无线码一区v| 精品欧美一区二区久久| 亚洲电影一级片| 99国产精品久久久久久久久久久| 欧美r级在线观看| 亚洲成人动漫av| 91浏览器在线视频| 国产欧美日韩久久| 99久久精品国产精品久久| 久久综合久久综合亚洲| 视频一区二区中文字幕| 在线看不卡av| 亚洲精品中文字幕在线观看| 成人丝袜高跟foot| 中文子幕无线码一区tr| 国产在线国偷精品产拍免费yy | 一区二区三区**美女毛片| 国内精品久久久久影院薰衣草| 欧美日韩久久不卡| 亚洲国产欧美在线| 欧美视频精品在线观看| 亚洲免费观看高清完整版在线 | 欧美三级一区二区| 亚洲欧美韩国综合色| 99热精品一区二区| 国产精品久久久久一区二区三区 | 91丨九色丨蝌蚪富婆spa| 国产欧美日韩在线视频| 国产成人精品亚洲777人妖 | ...xxx性欧美| 久久这里只精品最新地址| 狂野欧美性猛交blacked| 日韩欧美一级特黄在线播放| 琪琪一区二区三区| 日韩精品一区二区三区在线观看| 久久精品国产亚洲a| 精品日韩一区二区| 国产成人午夜高潮毛片| 国产精品国模大尺度视频| 91性感美女视频| 性感美女久久精品| 日韩亚洲电影在线| 国产丶欧美丶日本不卡视频| 国产精品第五页| 欧美日韩一卡二卡| 开心九九激情九九欧美日韩精美视频电影| 欧美成人bangbros| 国产精品1区2区3区| 亚洲人成影院在线观看| 欧美日本一道本| 捆绑紧缚一区二区三区视频| 国产无一区二区| 91成人网在线| 另类欧美日韩国产在线| 国产精品久久久久一区| 欧美日韩另类一区| 国产在线乱码一区二区三区| 亚洲色图视频免费播放| 欧美一区二区三区人| 成人黄色国产精品网站大全在线免费观看 | 国产99久久久国产精品潘金| 亚洲欧美日韩国产中文在线| 欧美妇女性影城| 国产成人午夜视频| 亚洲成a人v欧美综合天堂下载 | 国产一区二区三区| 亚洲精品视频一区二区| 精品少妇一区二区三区在线视频| 成人va在线观看| 免费看欧美女人艹b| 自拍偷自拍亚洲精品播放| 91精品国产91久久综合桃花| 成人一区二区三区视频在线观看 | 国产精品第五页| 日韩欧美色电影| 在线观看欧美日本| 国产成人精品免费视频网站| 午夜成人免费电影| **欧美大码日韩| 久久精品在线免费观看| 欧美一区二区三区视频| 日本韩国精品在线| jizz一区二区| 精品一区二区三区免费观看| 午夜欧美视频在线观看 | 99久久精品99国产精品| 精品系列免费在线观看| 午夜精品久久久久久久99樱桃 | 久久精品在线免费观看| 欧美一区二区三区日韩| 欧美三级韩国三级日本三斤| 9i看片成人免费高清| 国产99久久久国产精品免费看| 青草国产精品久久久久久| 亚洲福中文字幕伊人影院| 亚洲精品日日夜夜| 欧美激情综合五月色丁香小说| 欧美mv日韩mv国产网站app| 88在线观看91蜜桃国自产| 色哟哟国产精品| 色婷婷综合久色| 91蜜桃传媒精品久久久一区二区| 成人国产精品免费观看视频| 国产精品一区在线| 国产精品一区专区| 国产一区二区导航在线播放| 久久99精品久久久久久动态图 | 自拍偷拍欧美精品| 综合欧美亚洲日本| 亚洲欧美成人一区二区三区| 日韩美女视频19| 一区精品在线播放| 中文字幕一区二区三区精华液| 国产精品乱码一区二三区小蝌蚪| 国产日韩欧美精品在线| 亚洲国产精品二十页| 亚洲国产精品ⅴa在线观看| 亚洲国产精品高清| 18成人在线观看| 亚洲国产日韩一区二区| 午夜不卡av免费| 裸体一区二区三区| 国产激情视频一区二区三区欧美| 国产成人福利片| 色综合久久中文综合久久牛| 欧美一a一片一级一片| 91麻豆精品国产91久久久资源速度 | 国产综合色产在线精品| 高清在线成人网| 91免费看`日韩一区二区| 欧美日韩一级黄| 久久久蜜桃精品| 亚洲乱码国产乱码精品精98午夜| 亚洲va欧美va人人爽| 国内精品国产三级国产a久久| 国产不卡视频在线播放| 欧美亚洲动漫另类| 日韩片之四级片| 国产精品毛片大码女人| 偷拍日韩校园综合在线| 国产精品夜夜嗨| 欧美视频一区二区三区在线观看| 日韩精品一区二区三区swag| 中文字幕乱码日本亚洲一区二区| 一区二区三区小说| 国产美女一区二区三区| 91传媒视频在线播放| 亚洲电影一区二区三区| 国产在线一区观看| 欧美在线999| 国产日产欧美一区二区三区| 亚洲一区二区在线免费看| 国产在线精品免费av| 欧美日韩综合在线免费观看| 国产亚洲欧美中文| 日日夜夜免费精品| 成人三级在线视频| 精品少妇一区二区三区日产乱码 | 久久婷婷久久一区二区三区| 一区二区三区丝袜| 国产精品一级二级三级| 欧美日韩1234| 亚洲精品综合在线| 成人网在线播放| 精品国产3级a| 午夜精品久久久久久久蜜桃app| voyeur盗摄精品| 久久久精品tv| 久久国产精品免费| 欧美少妇一区二区| 国产精品成人免费在线| 久草热8精品视频在线观看| 欧美三级一区二区| 亚洲精品综合在线| 99麻豆久久久国产精品免费| 久久网站热最新地址| 九色综合国产一区二区三区| 欧美日韩免费在线视频| 一区二区三区精密机械公司| 成a人片亚洲日本久久| 国产亚洲福利社区一区| 久久精品噜噜噜成人av农村| 欧美精品一级二级三级| 亚洲国产wwwccc36天堂| 91成人国产精品| 亚洲乱码中文字幕综合| 91一区在线观看| 亚洲欧美偷拍另类a∨色屁股| 福利一区二区在线观看| 国产日韩精品视频一区| 韩国女主播成人在线观看| 精品国产乱码久久久久久影片| 麻豆精品一区二区综合av| 亚洲欧洲精品一区二区精品久久久| 国产精品一区二区久久不卡 |