diff --git a/test_hash.c b/test_hash.c deleted file mode 100644 index de045b7e4..000000000 --- a/test_hash.c +++ /dev/null @@ -1,109 +0,0 @@ -/* -* Copyright (c) 2020 AIIT XUOS Lab -* XiUOS is licensed under Mulan PSL v2. -* You can use this software according to the terms and conditions of the Mulan PSL v2. -* You may obtain a copy of Mulan PSL v2 at: -* http://license.coscl.org.cn/MulanPSL2 -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -* See the Mulan PSL v2 for more details. -*/ -/** - * @brief Priv-shell Command definition - * - * @param _func Command function - * @param _desc Command description - * @param _attr Command attributes if need - */ -#include -#include -// #include -#include -// hash code beginning -#include -#include - -#define HASHSIZE 12 -#define NULLKEY -32768 -typedef struct -{ - int *elem; - int count; -}HashTable; -int m=0; - -//初始化散列表 -int InitHashTable(HashTable *H) -{ - int i; - m=HASHSIZE; - H->count=m; - H->elem=(int*)malloc(m*sizeof(int)); - for(i=0;ielem[i]=NULLKEY; - return 1; -} -//散列函数 -int Hash(int key) -{ - return key%m; -} -//插入关键字进入散列表 -void InsertHash(HashTable *H,int key) -{ - int addr=Hash(key); - while(H->elem[addr]!=NULLKEY) - addr=(addr+1)%m; - H->elem[addr]=key; -} - -//散列表查找关键字 -int SearchHash(HashTable H,int key,int *addr) -{ - *addr=Hash(key); - while(H.elem[*addr]!=key) - { - *addr=(*addr+1)%m; - if(H.elem[*addr]==NULLKEY||*addr==Hash(key)) - { - return -1; - } - } - return *addr; -} - - -extern int FrameworkInit(); -extern void ApplicationOtaTaskInit(void); -int main(void) -{ - - int a[12]={12,67,56,16,25,37,22,29,15,47,48,34}; - HashTable H; - int i; - InitHashTable(&H); - printf("The initial array is as follows:\n"); - for(i=0;i