c - Numbering Elements in a Linked List of structs -


I am trying to write a task that takes a logical form that is a linked list of strokes. One of the elements of these strokes is a value to accumulate a situation, for instance the structure is # 3 for element 3. The list that comes in is not in the order. I want to go through each element in the linked list and I want to set the price based on that sequence. How do i do this

  Nodt number strikes (nodt * temporary) {int i; I = 0; While (temp! = NULL) {temp-> Struct.struct_order = i; Temporary = temp-> Next; I ++; } Return temporary; }   

This is not going to clearly cut it, but this is what I have so far received. Apart from this, to clarify, I am adding elements, adding elements, removing elements. Every time it matters that anything changes in the line order, I want to call a function to straighten them. This allows me to change the pointers of linked list structures whenever I want to make changes.

typedef struct nodeT {struct node * next; Int struct_order; ...} NodeT; Zero fill_idx (NodeT * first) {int idx; Nodtie * node; For (node ​​= first, idx = 0; node; node = node-> next, ++ idx) {node-> Straight_order = idx; }}

Symmetry, with a little loop:

  zero fill_idx (NodeT * first) {int idx = 0; Nodt * node = first; While (node) {node-> Straight_order = idx; Node = node-> next; ++ IDX; }}    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -