TOP Contributors

  1. MIKROE (2663 codes)
  2. Alcides Ramos (358 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (137078 times)
  2. FAT32 Library (70222 times)
  3. Network Ethernet Library (56094 times)
  4. USB Device Library (46409 times)
  5. Network WiFi Library (42029 times)
  6. FT800 Library (41373 times)
  7. GSM click (29109 times)
  8. mikroSDK (26554 times)
  9. PID Library (26487 times)
  10. microSD click (25483 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
Library

Dynamic List Library

Rating:

5

Author: Richard Lowe

Last Updated: 2013-06-11

Package Version: 1.0.0.0

Category: Other Codes

Downloaded: 1154 times

Followed by: 3 users

License: MIT license  

Dynamic double linked list library that is not only fast but efficient.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Dynamic List Library" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Dynamic List Library" changes.

Do you want to report abuse regarding "Dynamic List Library".

  • Information
  • Comments (0)

Library Blog

Example:


You will need to provide 2 functions to the list.  A DESTROY and FIND function that accepts a void pointer.  The list works with any datatype.

#include "list.h"

const unsigned int HEAP_SIZE = 2048;
DList myList;

DListElmt *findElmt(void *num);
void deleteNum(void *payload);

DListElmt *findElmt(void *num){
     DListElmt *tmpElmt;
     
     if(dlist_size(&myList) == 0)
         return;
     tmpElmt = dlist_head(&myList);
     while(tmpElmt != 0 && (int*)tmpElmt->payload != num)
         tmpElmt = tmpElmt->next;

     return tmpElmt;
}

void deleteNum(void *payload){
     int* tempNum = (int*)payload;
     Free((char*)tempNum, sizeof(int));
}


void main() {

     int i = 0, *num;

     MM_Init();
     dlist_init(&myList, findElmt, deleteNum);

     
     for(i = 0; i<10; i++){
           num = (int*)Malloc(sizeof(int));
           *num = rand();
           dlist_ins_prev(&myList, dlist_head(&myList), num);
     }
     
     dlist_destroy(&myList);

}

ALSO FROM THIS AUTHOR

BarGraph Library

5

BarGraphs are wonderful for visual feedback. This library makes it easy to add one. Based on BarGraph click board.

[Learn More]

RTC 1307 Library

10

Makes easy addition of ds1307 RTC.

[Learn More]

STM DMA Library

15

This is the first of DMA functions that will be available for the ST line of ARM microcontrollers. The idea was born from a forum post. The idea worked so well I made it into a convenient MikroC library. So far.... memory to memory transfers is what is functional

[Learn More]