1#ifndef UTIL_LIST_ARRAY_H
2#define UTIL_LIST_ARRAY_H
11#include <util/containers/Array.h>
12#include <util/containers/Node.h>
13#include <util/containers/List.h>
14#include <util/misc/Memory.h>
29 template <
typename Data>
79 assert(i < capacity_);
81 return nodes_[i].data();
93 assert(i < capacity_);
95 return nodes_[i].data();
147 template <
typename Data>
160 template <
typename Data>
164 Memory::deallocate< Node<Data> >(nodes_, capacity_);
167 Memory::deallocate< List<Data> >(lists_, nList_);
177 template <
typename Data>
181 capacity_ = capacity;
185 Memory::allocate< Node<Data> >(nodes_, capacity_);
188 Memory::allocate< List<Data> >(lists_, nList_);
189 for (i=0; i < nList_; ++i) {
190 lists_[i].initialize(nodes_, capacity_);
200 template <
typename Data>
210 template <
typename Data>
217 return *(lists_ + i);
226 template <
typename Data>
233 return *(lists_ + i);
242 template <
typename Data>
247 assert(i < capacity_);
249 return *(nodes_ + i);
255 template <
typename Data>
260 UTIL_THROW(
"nodes_ is allocated but lists_ is not");
264 for (
int i=0; i < nList_ ; ++i) {
265 if (!lists_[i].isValid()){
273 UTIL_THROW(
"nodes_ is not allocated but lists_ is");
An array of objects that are accessible by one or more linked List objects.
Node< Data > & node(int i)
Return reference to node number i.
List< Data > & list(int i)
Return a reference to a specific List.
void allocate(int capacity, int nList)
Allocate arrays of Node and List objects.
virtual ~ListArray()
Destructor.
int capacity() const
Return allocated size of underlying array of nodes.
bool isValid() const
Return true if the ListAray is valid, or throw an exception.
int nList() const
Get the number of associated linked lists.
Data & operator[](int i)
Return data for node element i.
Linked list class template.
Linked List Node, class template.
File containing preprocessor macros for error handling.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Utility classes for scientific computation.