src/stdlib/sequence.c
/*===============================================
 * hinsseq -- Insert new element at sequence head
 *=============================================*/
- Insert new element at sequence head
- Insert new element at sequence head
SEQUENCE
hinsseq (SEQUENCE seq,   
         ELEMENT el)     
{
	INT i, n;
	ELEMENT *old = Data(seq);
	if ((n = Size(seq)) == Max(seq)) {
		ELEMENT *new = (ELEMENT *) stdalloc(sizeof(ELEMENT)*
		    (n + Inc(seq)));
		for (i = n; i > 0; --i)
 			new[i] = old[i-1];
		stdfree(old);
		Data(seq) = old = new;
		Max(seq) += Inc(seq);
	}
	else
		for (i = n; i > 0; --i)
			old[i] = old[i-1];
	old[0] = el;
	Size(seq)++;
	return seq;
}
SEQUENCE hinsseq ( SEQUENCE seq , ELEMENT el ) { INT i , n ; ELEMENT * old = Data ( seq ) ; if ( ( n = Size ( seq ) ) == Max ( seq ) ) { ELEMENT * new = ( ELEMENT * ) stdalloc ( sizeof ( ELEMENT ) * ( n + Inc ( seq ) ) ) ; for ( i = n ; i > 0 ; -- i ) new [ i ] = old [ i - 1 ] ; stdfree ( old ) ; Data ( seq ) = old = new ; Max ( seq ) += Inc ( seq ) ; } else for ( i = n ; i > 0 ; -- i ) old [ i ] = old [ i - 1 ] ; old [ 0 ] = el ; Size ( seq ) ++ ; return seq ; }
hinsseq -- Insert new element at sequence head
hinsseq -- Insert new element at sequence head
/* sequence */ /* element */