AVR C/C++ Collection Classes

C++ Collection classes for AVR platform Version 1.0 release 9/19/2011

A new version of the C++ CCollection library is provided as a true C++ implementation of the Collection library for embedded systems. Although it is compiled using Atmel Studio 6.0 SP2 build 1996 it should run on just about any system with minor modifications. You are free to use it in private or commercial projects but please do not remove my headers and comments. i.e. Give create where credit is due.

Explanation of downloads

  • CCollection.zip - This is a true C++ implementation of Collection, uses on library libCCollection.a and you just need to include the .h file directory in compile and the library directory and CCollection in the link options. Uses the _EXTEND_LL or _EXTEND_ALL definitions to get full functionality, defaults to limited functionality.
  • Collection.zip - C implementation of Collection. Uses _BASIC_ONLY to determine what functions are enabled, defaults to full implementation unless _BASIC_ONLY defined.
  • CCollectionLibrary.zip - C++ implementation of Collection, early version of the AVRStudio and Atmel Studio did not allow for C++ files to be split into cpp and h files so with this implementation you need to include the source in you project. Also uses _BASIC_ONLY to determine what methods are included in the project, defaults to full implementation unless _BASIC_ONLY defined.

The AVR C++ Collection classes are a light weight feature rich implementation of the most popular set of collections used in C++ applications. The download comes with a test harness that was used to unit test the classes. Additionally all classes are well docmented and DoxyGen ready which can be had here.

Although the classes were built for the Mega1280 micro these classes are processor independent and will run on any process with an acceptable memory foot print and using the _BASIC_ONLY symbol reduces the foot print even further by excluding extended methods that you may not use such as Find, Clear and Interate.

The list below outlines the classes contained in the download and a brief explaination and the table that follows is the memory resourced required which includes the gcc toolchain memory management code for malloc and free. All classes except the CBuffer class are dynamic and grow and shrink as needed by the application. The CBuffer class accepts a buffer size with the constructor and does a one time allocation of the buffer and it cannot be changed once instantiated.

  • CStack - Stack/LIFO implementation
  • CQueue - Queue/FIFO using singly forward chaining linked list.
  • CLinkList - Doubly linked list with extended functionality
  • CBuffer - A circular buffer implementation that is suited for use with the AVRs UART.
Memory resources for the CCollection classes
Class Debug Release Debug (Basic) Release (Basic)
CBuffer 1264 866 N/A N/A
CLinkList 2362 1456 1594 1094
CQueue 1730 1102 1062 822
CStack 1298 920 N/A N/A

At present the AVR Studio 5 IDE's C++ support is in BETA and these classes could not be split into .cpp/.h files because they wouldn't link. But as soon as support is in place I will be redoing these and creating a library that may be linked into an application instead of having to include them in with the code.