1 |
/*************************************************************************** |
/*************************************************************************** |
2 |
* * |
* * |
3 |
* Copyright (C) 2005 Christian Schoenebeck * |
* Copyright (C) 2005, 2006 Christian Schoenebeck * |
4 |
* * |
* * |
5 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
6 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
21 |
#ifndef __LS_ARRAYLIST_H__ |
#ifndef __LS_ARRAYLIST_H__ |
22 |
#define __LS_ARRAYLIST_H__ |
#define __LS_ARRAYLIST_H__ |
23 |
|
|
24 |
#include "LinuxSamplerException.h" |
#include "Exception.h" |
25 |
|
|
26 |
namespace LinuxSampler { |
namespace LinuxSampler { |
27 |
|
|
61 |
/** |
/** |
62 |
* Remove the given element at \a iPosition from the list. |
* Remove the given element at \a iPosition from the list. |
63 |
* |
* |
64 |
* @throws LinuxSamplerException - if \a iPosition is out of range |
* @throws Exception - if \a iPosition is out of range |
65 |
*/ |
*/ |
66 |
void remove(int iPosition) throw (LinuxSamplerException) { |
void remove(int iPosition) throw (Exception) { |
67 |
if (iPosition < 0 || iPosition >= iSize) |
if (iPosition < 0 || iPosition >= iSize) |
68 |
throw LinuxSamplerException("ArrayList::remove(): index out of range"); |
throw Exception("ArrayList::remove(): index out of range"); |
69 |
if (iSize == 1) clear(); |
if (iSize == 1) clear(); |
70 |
else if (pData) { |
else if (pData) { |
71 |
T* pNewArray = new T[iSize - 1]; |
T* pNewArray = new T[iSize - 1]; |
83 |
/** |
/** |
84 |
* Remove the given \a element from the list. |
* Remove the given \a element from the list. |
85 |
* |
* |
86 |
* @throws LinuxSamplerException - if \a element could not be found |
* @throws Exception - if \a element could not be found |
87 |
*/ |
*/ |
88 |
void remove(const T& element) { |
void remove(const T& element) { |
89 |
remove(find(element)); |
remove(find(element)); |
103 |
/** |
/** |
104 |
* Returns the index of the given \a element on the list. |
* Returns the index of the given \a element on the list. |
105 |
* |
* |
106 |
* @throws LinuxSamplerException - if \a element could not be found |
* @throws Exception - if \a element could not be found |
107 |
*/ |
*/ |
108 |
int find(const T& element) { |
int find(const T& element) { |
109 |
for (int i = 0; i < iSize; i++) |
for (int i = 0; i < iSize; i++) |
110 |
if (pData[i] == element) return i; |
if (pData[i] == element) return i; |
111 |
throw LinuxSamplerException("ArrayList::find(): could not find given element"); |
throw Exception("ArrayList::find(): could not find given element"); |
112 |
} |
} |
113 |
|
|
114 |
/** |
/** |