24
if self.first != None:
self.length +=1
current = self.first
while current.next != None:
current = current.next
self.length +=1
return self.length
2.5. Ro’yxat boshiga element qo’shish
8-listingda ro’yxat boshidan teskari tartibda element qo’shish uchun Push
funktsiyasi keltirilgan.
Listing 8. Ro’yxat boshiga element qo’shish uchun funktsiya
void Push(struct node** headRef, int data)
{
struct node* newNode = malloc(sizeof(struct node));
newNode->data = data;
newNode->next = *headRef;
*headRef = newNode;
}
// bu funktsiyaning qo’llanilishiga misol
Do'stlaringiz bilan baham: