/[svn]/linuxsampler/trunk/src/common/ArrayList.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/common/ArrayList.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3292 by schoenebeck, Fri May 30 12:48:05 2014 UTC revision 3293 by schoenebeck, Tue Jun 27 22:19:19 2017 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   Copyright (C) 2005 - 2014 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2017 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  *
# Line 22  Line 22 
22  #define __LS_ARRAYLIST_H__  #define __LS_ARRAYLIST_H__
23    
24  #include "Exception.h"  #include "Exception.h"
25    #include <string.h> // for memcpy()
26    
27  namespace LinuxSampler {  namespace LinuxSampler {
28    
# Line 162  namespace LinuxSampler { Line 163  namespace LinuxSampler {
163              }              }
164    
165              /**              /**
166               * Assignment.               * Generalized assignment with size adjustment and deep copy of
167                 * elements. Note that this method/operator re-allocates, so it is
168                 * not appropriate for being used in a real-time context!
169                 *
170                 * @see copyFlatFrom() for real-time safe copying
171               */               */
172              ArrayList& operator=(const ArrayList& list) {              ArrayList& operator=(const ArrayList& list) {
173                  if (this != &list) {                  if (this != &list) {
# Line 172  namespace LinuxSampler { Line 177  namespace LinuxSampler {
177                  return *this;                  return *this;
178              }              }
179    
180                /**
181                 * Real-time safe copying elements (flat, no deep copy) from
182                 * given @a list to this list.
183                 */
184                void copyFlatFrom(const ArrayList& list) {
185                    const int n = (size() < list.size()) ? size() : list.size();
186                    memcpy(pData, list.pData, n * sizeof(T));
187                }
188    
189          private:          private:
190              T*   pData;              T*   pData;
191              int  iSize;              int  iSize;

Legend:
Removed from v.3292  
changed lines
  Added in v.3293

  ViewVC Help
Powered by ViewVC