TOP Contributors

  1. MIKROE (2653 codes)
  2. Alcides Ramos (352 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 (136713 times)
  2. FAT32 Library (69924 times)
  3. Network Ethernet Library (55936 times)
  4. USB Device Library (46259 times)
  5. Network WiFi Library (41884 times)
  6. FT800 Library (41150 times)
  7. GSM click (28979 times)
  8. PID Library (26410 times)
  9. mikroSDK (26355 times)
  10. microSD click (25353 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: 1148 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

Static Data Structures

5

Add static data structures to your project.

[Learn More]

DS18X20 One Wire Library

5

Easily add DS18x20 sensor functions to your project.

[Learn More]

AVR Webserver

0

AVR Webserver: Dependencies - FAT32 library, Ethernet library Will allow you to load any size website, including images, css, and js files from SD media. This is my first version, but the example project included will give you a starting point.

[Learn More]