tags:

views:

158

answers:

5
p^.rlink=q
q^.llink=p
+3  A: 

When caret (^) appears after a pointer variable it dereferences the pointer, that is, it returns the value stored at the memory address held by the pointer. So in your case I suppose that p is a pointer to a record that has rlink property and q is a pointer to a record that has llink property. These properties are also pointers to the same structure, because p and q are then assigned to them. I suppose that this structure represents a binary tree data type with left and right nodes.

Darin Dimitrov
+1 on the general answer, but I would assume that to be a doubly linked list and the update of pointers after adding a node. Note that `p^.rlink^.llink` is actually `p` which is a propertly found in doubly linked lists and not trees.
David Rodríguez - dribeas
A: 

The ^'s follow a pointer, and the . access a member of a record. So these lines are probably rearranging the links in a graph of some kind.

dmckee
+5  A: 

The pascal operator ^. is similar to operator -> in C and C++.

It dereferences the pointer (in your case, p should be defined as var p: ^type) and accesses a variable in the record, in this case, rlink and llink.

LiraNuna
A: 

p and q appear to be pointers. They point to a record variables which have respectively (or probably both), a rlink and llink (guessing right link and left link).

This snippet is probably used in the context of a graph or maybe a linked list of sorts.

The caret (^) operator, in Pascal, is the dereference opertator which enables one to access the variable content not the the pointer.

The direct equivalent in C language would be

(p*).rlink=q
(q*).llink=p

but of course this would typically be expressed as

p->rlink=q
q->llink=p

with C's -> operator which does a deferencing and member access in one step.

mjv
+3  A: 

A likely possibility is that p and q are elements in a doubly-linked list, often called a bi-directional linked list. Those two statements are attaching them together, with p on the "left" and q on the "right". An equivalent in C/C++ would be:

p->rlink = q;
q->llink = p;
Bob Murphy