示例#1
0
static const char *_rb_tree_advance_frag_match(QSP_ARG_DECL  Frag_Match_Info * fmi_p, int direction )
{
	Item *ip;

	// there may be no items!?
	assert( fmi_p != NULL );

	if( direction == CYC_FORWARD ){
		if( CURR_FRAG(fmi_p) == LAST_FRAG(fmi_p) )
			return NULL;
		else {
			SET_CURR_FRAG(fmi_p, rb_successor_node( CURR_RBT_FRAG(fmi_p) ) );
			assert( CURR_FRAG(fmi_p) != NULL );
		}
	} else {
		if( CURR_FRAG(fmi_p) == FIRST_FRAG(fmi_p) )
			return NULL;
		else {
			SET_CURR_FRAG(fmi_p,rb_predecessor_node( CURR_RBT_FRAG(fmi_p) ));
			assert( CURR_FRAG(fmi_p) != NULL );
		}
	}
	ip = RB_NODE_ITEM( CURR_RBT_FRAG(fmi_p) );
	return ITEM_NAME(ip);
}
示例#2
0
static void search_list_for_fragment(List *lp, Frag_Match_Info *fmi_p, const char *frag)
{
	int n;
	Node* np;

// we might assert the this frag match is associated with a list container
// but we get here from a list-specific function so should be safe...
// famous last words?

	lp = _alpha_sort(DEFAULT_QSP_ARG  lp);	// BUG should sort in-place???

	np = QLIST_HEAD(lp);

	n = (int) strlen(frag);
	SET_CURR_FRAG(fmi_p, NULL);	// default
	SET_FIRST_FRAG(fmi_p, NULL);
	SET_LAST_FRAG(fmi_p, NULL);

	while( np != NULL ){
		const Item *ip;
		int compVal;

		ip = NODE_DATA(np);
		compVal = strncmp( frag, ITEM_NAME(ip), n );
		if( compVal == 0 ){
			// We have found the first node that is a match,
			// but we want also determine the last...
			SET_CURR_FRAG(fmi_p, np);
			SET_FIRST_FRAG(fmi_p, np);
			SET_LAST_FRAG(fmi_p, np);
			np = NODE_NEXT(np);
			while( np != NULL ){
				ip = NODE_DATA(np);
				compVal = strncmp( frag, ITEM_NAME(ip), n );
				if( compVal != 0 )
					return;
				SET_LAST_FRAG(fmi_p, np);
				np = NODE_NEXT(np);
			}
			return;
		}
		np = NODE_NEXT(np);
	}
}
示例#3
0
static void the_iy_ax(cst_utterance *u)
{
    const cst_item *i;
    const char *word;

    for (i = UTT_REL_HEAD(u, SEGMENT); i; i = item_next(i))
    {
	if (cst_streq("ax", ITEM_NAME(i)))
	{
	    word = ffeature_string(i,"R:"SYLSTRUCTURE".P.P.name");
	    if (cst_streq("the", word)
		&& cst_streq("+", ffeature_string(i,"n."PH_VC)))
		    item_set_string(i, "name", "iy");
	}

    }
}
示例#4
0
文件: rbtree.c 项目: nasa/QuIP
int rb_delete_item(qrb_tree *tree_p, Item *ip)
{
	return rb_delete_key(tree_p,ITEM_NAME(ip));
}