⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vindex.c

📁 SVMcfg: Learns a weighted context free grammar from examples. Training examples (e.g. for natural la
💻 C
字号:
/* vindex.c  -- Vectors of si_index
 *
 * Mark Johnson, 22nd May 1997
 */

#include <string.h>
#include "vindex.h"
#include "mmm.h"
#include "hash-templates.h"

vindex 
make_vindex(const size_t n)
{
  vindex v = MALLOC(sizeof(struct vindex));
  v->e = MALLOC(n*sizeof(si_index));
  return v;
}

static size_t 
vindex_hash(const vindex v)
{
  int      i;
  unsigned h = 0, g;
  for (i=v->n-1; i>=0; i--) {
    h = (h << 4) + v->e[i];
    if ((g = h&0xf0000000)) {
      h = h ^ (g >> 24);
      h = h ^ g;
    }}
  return h;
}

static int 
vindex_cmp(const vindex v1, const vindex v2)
{
  if (v1->n==v2->n)
    return memcmp(v1->e, v2->e, v1->n*sizeof(si_index));
  else {
    if (v1->n<v2->n)
      return -1;
    else
      return +1;
  }}

static vindex 
vindex_copy(const vindex v)
{
  vindex v1 = MALLOC(sizeof(struct vindex));
  v1->n = v->n;
  v1->e = MALLOC(v1->n*sizeof(si_index));
  memcpy(v1->e, v->e, v1->n*sizeof(si_index));
  return v1;
}

void 
vindex_free(vindex v)
{
  FREE(v->e);
  FREE(v);
}

HASH_CODE_ADD(vihashl, vindex, long, vindex_hash, vindex_cmp, 
	      vindex_copy, vindex_free, 0, NO_OP)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -