Esempio n. 1
0
/* Adds a link to the front of the deque

	param: 	q		pointer to the deque
	param: 	val		value for the link to be added
	pre:	q is not null
	post:	a link storing val is added to the front of the deque
*/
void addFrontCirListDeque(struct cirListDeque *q, TYPE val)
{
	/* DONE: you must write this */	 
	assert(q != 0);

	_addLinkAfter(q, q->Sentinel, val);
}
Esempio n. 2
0
/* Adds a link to the back of the deque

	param: 	q		pointer to the deque
	param: 	val		value for the link to be added
	pre:	q is not null
	post:	a link storing val is added to the back of the deque
*/
void addBackCirListDeque (struct cirListDeque *q, TYPE val) 
{
	/* FIXME: you must write this */	 
       assert(q != 0);

       _addLinkAfter(q, q->Sentinel->prev, val);
   
}
Esempio n. 3
0
/* Adds a link to the front of the deque

	param: 	q		pointer to the deque
	param: 	val		value for the link to be added
	pre:	q is not null
	post:	a link storing val is added to the front of the deque
*/
void addFrontCirListDeque(struct cirListDeque *q, TYPE val)
{
	//make sure q is not null
	assert(!EQ(q, 0));

	//add link to the front of the list by adding it after the sentinel
	_addLinkAfter(q, q->Sentinel, val);	 
}
Esempio n. 4
0
/* Adds a link to the back of the deque

	param: 	q		pointer to the deque
	param: 	val		value for the link to be added
	pre:	q is not null
	post:	a link storing val is added to the back of the deque
*/
void addBackCirListDeque (struct cirListDeque *q, TYPE val) 
{
	//make sure q is not null
	assert(!EQ(q, 0));	 

	//add link after the link to the left of the Sentinal accessed by prev
	_addLinkAfter(q, q->Sentinel->prev, val);
}
Esempio n. 5
0
/* Adds a link to the front of the deque

	param: 	q		pointer to the deque
	param: 	val		value for the link to be added
	pre:	q is not null
	post:	a link storing val is added to the front of the deque
*/
void addFrontCirListDeque(struct cirListDeque *q, TYPE val)
{
	/* FIXME: you must write this */
        assert(q != 0);  

       // Can Use 'Add After' when passing Sentinel
       _addLinkAfter(q, q->Sentinel, val);

}
Esempio n. 6
0
/* Adds a link to the front of the deque
    param: q - pointer to the deque
    param: val - value for the link to be added
    pre:   q is not null
    post:  a link storing val is added to the front of the deque
*/
void addFrontCirListDeque( struct cirListDeque *q, TYPE val )
{
    /* Update information about q itself */
    q->size += 1;

    /* Create a new link with the value */
    struct DLink *newLnk = _createLink( val );

    /* Update pointers of new link */
    _addLinkAfter( q, q->Sentinel, newLnk );
}
Esempio n. 7
0
/* Adds a link to the front of the deque

	param: 	q		pointer to the deque
	param: 	val		value for the link to be added
	pre:	q is not null
	post:	a link storing val is added to the front of the deque
*/
void addFrontCirListDeque(struct cirListDeque *q, TYPE val)
{
	/* FIXME: you must write this */
//    struct DLink* newLink = malloc(sizeof(struct DLink));
//    newLink->value = val;
    assert(q != 0);
    _addLinkAfter(q, q->Sentinel, val);
    
//    q->Sentinel->next->prev = newLink;
//    newLink->prev = q->Sentinel;
//    newLink->next = q->Sentinel->next;
//    q->Sentinel->next = newLink;

}
Esempio n. 8
0
/* Adds a link to the front of the deque

	param: 	q		pointer to the deque
	param: 	val		value for the link to be added
	pre:	q is not null
	post:	a link storing val is added to the front of the deque
*/
void addFrontCirListDeque(struct cirListDeque *q, TYPE val)
{
	struct DLink * lnk = _createLink(val);
	if (isEmptyCirListDeque(q))
	{
		/* if q is currently empty, the added link becomes the only link in the deque */
	  	lnk->next = lnk;
		lnk->prev = lnk;
		q->size++;
		/* change last to the newly added link */
		q->last = lnk;
	}
	else
		_addLinkAfter(q, q->last, lnk);
}
/* Adds a link to the front of the deque

	param: 	q pointer to the deque
	param: 	val	value for the link to be added
	pre:	q is not null
	post:	a link storing val is added to the front of the deque
*/
void addFrontCirListDeque(struct cirListDeque *q, TYPE val){
     assert(q != NULL);
     _addLinkAfter(q, q->Sentinel, val);
}
/* Adds a link to the back of the deque

	param: 	q		pointer to the deque
	param: 	val		value for the link to be added
	pre:	q is not null
	post:	a link storing val is added to the back of the deque
*/
void addBackCirListDeque (struct cirListDeque *q, TYPE val) {
	assert(q != NULL);
	_addLinkAfter(q, q->Sentinel->prev, val);
}
Esempio n. 11
0
/* Adds a link to the front of the deque

	param: 	q		pointer to the deque
	param: 	val		value for the link to be added
	pre:	q is not null
	post:	a link storing val is added to the front of the deque
*/
void addFrontCirListDeque(struct cirListDeque *q, TYPE val)
{
    _addLinkAfter(q, q->Sentinel, val);
}
Esempio n. 12
0
/* Adds a link to the back of the deque

	param: 	q		pointer to the deque
	param: 	val		value for the link to be added
	pre:	q is not null
	post:	a link storing val is added to the back of the deque
*/
void addBackCirListDeque (struct cirListDeque *q, TYPE val)
{
    _addLinkAfter(q, q->Sentinel->prev, val);
}
Esempio n. 13
0
/* Adds a link to the front of the deque

	param: 	q		pointer to the deque
	param: 	val		value for the link to be added
	pre:	q is not null
	post:	a link storing val is added to the front of the deque
*/
void addFrontCirListDeque(struct cirListDeque *q, TYPE val)
{
    /* FIXME: you must write this */
    /* q is not null is checked in _addLinkAfter */
    _addLinkAfter(q, q->Sentinel, val);
}