[dali_1.9.25] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / public-api / common / dali-vector.h
1 #ifndef DALI_VECTOR_H
2 #define DALI_VECTOR_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <cstddef>
23 #include <algorithm>
24 #include <cstdint> // uint32_t
25
26 // INTERNAL INCLUDES
27 #include <dali/public-api/common/dali-common.h>
28 #include <dali/public-api/common/type-traits.h>
29 #include <dali/public-api/math/math-utils.h>
30
31 /**
32  * @brief For DALi internal use, asserts are enabled in debug builds.
33  *
34  * For Application use, asserts can be enabled manually.
35  * @SINCE_1_0.0
36  */
37 #if defined( DEBUG_ENABLED )
38 #define ENABLE_VECTOR_ASSERTS
39 #endif
40
41 #if defined( ENABLE_VECTOR_ASSERTS )
42 #define DALI_ASSERT_VECTOR(cond) DALI_ASSERT_ALWAYS(cond)
43 #else
44 #define DALI_ASSERT_VECTOR(cond)
45 #endif
46
47 namespace Dali
48 {
49 /**
50  * @addtogroup dali_core_common
51  * @{
52  */
53
54 /**
55  * @brief Base class to handle the memory of simple vector.
56  *
57  * Memory layout is such that it has two std::size_t to hold the count
58  * and capacity of the vector. VectorBase::mData is adjusted so that it points to the
59  * beginning of the first real item so that iterating the items is quick.
60  * @SINCE_1_0.0
61  */
62 class DALI_CORE_API VectorBase
63 {
64 public: // Typedefs
65
66   typedef std::size_t SizeType;
67
68 protected: // Construction
69
70   /**
71    * @brief Default constructor. Does not allocate space.
72    * @SINCE_1_0.0
73    */
74   VectorBase();
75
76   /**
77    * @brief Destructor.
78    *
79    * Does not release the space. Derived class needs to call Release.
80    * Not virtual as this should not be called directly and we do not want
81    * a vtable for this class as it would unnecessarily increase size.
82    * @SINCE_1_0.0
83    */
84   ~VectorBase();
85
86 public: // API
87
88   /**
89    * @brief This method is inlined as it's needed frequently for Vector::End() iterator.
90    *
91    * @SINCE_1_0.0
92    * @return The count of elements in this vector
93    */
94   SizeType Count() const
95   {
96     SizeType items = 0u;
97     if( mData )
98     {
99       SizeType* metadata = reinterpret_cast< SizeType* >( mData );
100       items = *(metadata - 1u);
101     }
102     return items;
103   }
104
105   /**
106    * @brief Gets the count of elements in this vector.
107    * @SINCE_1_0.0
108    * @return The count of elements in this vector
109    */
110   SizeType Size() const
111   {
112     return Count();
113   }
114
115   /**
116    * @brief @ return if the vector is empty.
117    * @SINCE_1_0.0
118    * @return True if the count of elements is empty
119    */
120   bool Empty() const
121   {
122     return Count() == 0u;
123   }
124
125   /**
126    * @brief Gets the capacity of this vector.
127    * @SINCE_1_0.0
128    * @return The capacity of this vector
129    */
130   SizeType Capacity() const;
131
132   /**
133    * @brief Releases the data.
134    *
135    * Does not call destructors on objects held.
136    * @SINCE_1_0.0
137    */
138   void Release();
139
140 protected: // for Derived classes
141
142   /**
143    * @brief Helper to set the count.
144    *
145    * @SINCE_1_0.0
146    * @param[in] count Number of elements in the vector
147    */
148   void SetCount( SizeType count );
149
150   /**
151    * @brief Reserves space in the vector.
152    *
153    * @SINCE_1_0.0
154    * @param[in] count Count of elements to reserve
155    * @param[in] elementSize Size of a single element
156    */
157   void Reserve( SizeType count, SizeType elementSize );
158
159   /**
160    * @brief Copy a vector.
161    *
162    * @SINCE_1_0.0
163    * @param[in] vector Vector to copy from
164    * @param[in] elementSize Size of a single element
165    */
166   void Copy( const VectorBase& vector, SizeType elementSize );
167
168   /**
169    * @brief Swaps the contents of two vectors.
170    *
171    * @SINCE_1_0.0
172    * @param[in] vector Vector to swap with
173    */
174   void Swap( VectorBase& vector );
175
176   /**
177    * @brief Erases an element.
178    *
179    * Does not change capacity.
180    * @SINCE_1_0.0
181    * @param[in] address Address to erase from
182    * @param[in] elementSize Size to erase
183    * @pre Last element cannot be erased as there is nothing to move.
184    */
185   void Erase( char* address, SizeType elementSize );
186
187   /**
188    * @brief Erases a range of elements.
189    *
190    * Does not change capacity.
191    * @SINCE_1_0.0
192    * @param[in] first Address to the first element to be erased
193    * @param[in] last Address to the last element to be erased
194    * @param[in] elementSize Size of one of the elements to be erased
195    * @return Address pointing to the next element of the last one
196    */
197   char* Erase( char* first, char* last, SizeType elementSize );
198
199   /**
200    * @brief Copies a number of bytes from \e source to \e destination.
201    *
202    * \e source and \e destination must not overlap.
203    *
204    * @SINCE_1_0.0
205    * @param[in] destination Pointer to the destination address
206    * @param[in] source Pointer to the source address
207    * @param[in] numberOfBytes The number of bytes to be copied
208    */
209   void CopyMemory( char* destination, const char* source, size_t numberOfBytes );
210
211 private:
212
213   // not copyable as it does not know the size of elements
214   VectorBase( const VectorBase& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0
215   VectorBase& operator=( const VectorBase& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0
216
217   // not movable as this is handled by deriving classes
218   VectorBase( VectorBase&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25
219   VectorBase& operator=( VectorBase&& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_9.25
220
221 protected: // Data
222
223   void* mData; ///< Pointer to the data.
224
225 };
226
227 /// @cond internal
228 /**
229  * @brief Vector algorithm variant for trivial types.
230  *
231  * Trivial types do not need destructor or copy constructor called.
232  * @SINCE_1_0.0
233  */
234 template< bool IsTrivial >
235 class VectorAlgorithms : public VectorBase
236 {
237 protected: // API for deriving classes
238
239   typedef VectorBase::SizeType SizeType;
240
241   /**
242    * @brief Empty constructor.
243    * @SINCE_1_0.0
244    */
245   VectorAlgorithms()
246   { }
247
248   /**
249    * @brief Empty destructor.
250    * @SINCE_1_0.0
251    */
252   ~VectorAlgorithms()
253   { }
254
255   /**
256    * @brief Copy vector contents.
257    *
258    * @SINCE_1_0.0
259    * @param[in] rhs VectorBase object to copy from
260    * @param[in] elementSize Size of the content
261    */
262   void Copy( const VectorBase& rhs, SizeType elementSize )
263   {
264     if( rhs.Capacity() > 0u )
265     {
266       VectorBase::Copy( rhs, elementSize );
267     }
268     else
269     {
270       VectorBase::Release();
271     }
272   }
273
274   /**
275    * @brief Reserves space in the vector.
276    *
277    * @SINCE_1_0.0
278    * @param[in] count Count of elements to reserve
279    * @param[in] elementSize Size of a single element
280    */
281   void Reserve( SizeType count, SizeType elementSize )
282   {
283     VectorBase::Reserve( count, elementSize );
284   }
285
286   /**
287    * @brief Resizes the vector. Does not change capacity.
288    *
289    * @SINCE_1_0.0
290    * @param[in] count Count to resize to
291    * @param[in] elementSize Size of a single element
292    */
293   void Resize( SizeType count, SizeType elementSize )
294   {
295     // reserve will copy old elements as well
296     Reserve( count, elementSize );
297   }
298
299   /**
300    * @brief Clears the contents.
301    *
302    * For simple types, nothing to do.
303    * @SINCE_1_0.0
304    */
305   void Clear()
306   {
307     if( mData )
308     {
309       VectorBase::SetCount( 0u );
310     }
311   }
312
313   /**
314    * @brief Releases the vector.
315    * @SINCE_1_0.0
316    */
317   void Release()
318   {
319     VectorBase::Release();
320   }
321
322   /**
323    * @brief Erases an element. Does not change capacity.
324    *
325    * @SINCE_1_0.0
326    * @param[in] address Address to erase from
327    * @param[in] elementSize Size to erase
328    */
329   void Erase( uint8_t* address, SizeType elementSize )
330   {
331     VectorBase::Erase( reinterpret_cast< char* >( address ), elementSize );
332   }
333
334   /**
335    * @brief Erases a range of elements. Does not change capacity.
336    *
337    * @SINCE_1_0.0
338    * @param[in] first Address to the first element to be erased
339    * @param[in] last Address to the last element to be erased
340    * @param[in] elementSize Size of one of the elements to be erased
341    * @return Address pointing to the next element of the last one
342    */
343   uint8_t* Erase( uint8_t* first, uint8_t* last, SizeType elementSize )
344   {
345     return reinterpret_cast< uint8_t* >( VectorBase::Erase( reinterpret_cast< char* >( first ), reinterpret_cast< char *>( last ), elementSize ) );
346   }
347
348   /**
349    * @brief Inserts the given elements into the vector.
350    *
351    * @SINCE_1_0.0
352    * @param[in] at Address where to insert the elements into the vector
353    * @param[in] from Address to the first element to be inserted
354    * @param[in] to Address to the last element to be inserted
355    * @param[in] elementSize Size of one of the elements to be inserted
356    */
357   void Insert( uint8_t* at, uint8_t* from, uint8_t* to, SizeType elementSize )
358   {
359     const SizeType size = to - from;
360     const SizeType count = Count();
361     const SizeType newCount = count + size / elementSize;
362
363     if( newCount > Capacity() )
364     {
365       // Calculate the at offset as the pointer is invalid after the Reserve() call.
366       std::size_t offset = at - reinterpret_cast<uint8_t*>( mData );
367
368       // need more space
369       Reserve( NextPowerOfTwo( static_cast<uint32_t>( newCount ) ), elementSize ); // reserve enough space to store at least the next power of two elements of the new required size.
370
371       // Set the new at pointer.
372       at = reinterpret_cast<uint8_t*>( mData ) + offset;
373     }
374     // set new count first as otherwise the debug assert will hit us
375     SetCount( newCount );
376
377     // Move current items to a new position inside the vector.
378     CopyMemory( reinterpret_cast< char* >( at + size ),
379                 reinterpret_cast< const char* >( at ),
380                 ( reinterpret_cast<uint8_t*>( mData ) + count * elementSize ) - at );
381
382     // Copy the given items.
383     CopyMemory( reinterpret_cast< char* >( at ), reinterpret_cast< const char* >( from ), size );
384   }
385 };
386 /// @endcond
387
388 /// @cond internal
389 /**
390  * @brief Vector algorithm variant for complex types.
391  *
392  * Not yet supported so will lead to compile error
393  * as constructor and destructor are private.
394  * TODO add support for this variant.
395  * @SINCE_1_0.0
396  */
397 template<>
398 class VectorAlgorithms< false > : public VectorBase
399 {
400 private:
401   VectorAlgorithms()
402   { }
403   ~VectorAlgorithms()
404   { }
405 };
406 /// @endcond
407
408 /**
409  * @brief Vector class with minimum space allocation when it's empty.
410  *
411  * @SINCE_1_0.0
412  * @param type The type of the data that the vector holds
413  */
414 template< class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true >
415 class Vector : public VectorAlgorithms< IsTrivialType >
416 {
417 public: // API
418
419   /**
420    * @brief Type definitions.
421    * @SINCE_1_0.0
422    */
423   typedef VectorBase::SizeType SizeType; ///< Size type @SINCE_1_0.0
424   typedef T* Iterator;  ///< Most simple Iterator is a pointer @SINCE_1_0.0
425   typedef const T* ConstIterator; ///< Const iterator @SINCE_1_0.0
426   typedef T  ItemType; ///< Item type @SINCE_1_0.0
427
428   /**
429    * @brief Enumeration for BaseType.
430    * @SINCE_1_0.0
431    */
432   enum
433   {
434     BaseType = IsTrivialType ///< @SINCE_1_0.0
435   };
436
437   /**
438    * @brief Default constructor. Does not allocate any space.
439    * @SINCE_1_0.0
440    */
441   Vector()
442   { }
443
444   /**
445    * @brief Destructor. Releases the allocated space.
446    * @SINCE_1_0.0
447    */
448   ~Vector()
449   {
450     Release();
451   }
452
453   /**
454    * @brief Copy constructor.
455    *
456    * @SINCE_1_0.0
457    * @param[in] vector Vector to copy from
458    */
459   Vector( const Vector& vector )
460   {
461     // reuse copy assignment
462     operator=( vector );
463   }
464
465   /**
466    * @brief Default move constructor.
467    *
468    * @SINCE_1_9.25
469    * @param[in] vector Vector to move
470    */
471   Vector( Vector&& vector )
472   {
473     // reuse move assignment
474     operator=( std::move( vector ) );
475   }
476
477   /**
478    * @brief Assignment operator.
479    *
480    * @SINCE_1_0.0
481    * @param[in] vector Vector to assign from
482    * @return Reference to self for chaining
483    */
484   Vector& operator=( const Vector& vector )
485   {
486     if( this != &vector )
487     {
488       VectorAlgorithms<BaseType>::Copy( vector, sizeof( ItemType ) );
489     }
490     return *this;
491   }
492
493   /**
494    * @brief Default move assignment operator.
495    *
496    * @SINCE_1_9.25
497    * @param[in] vector Vector to move
498    */
499   Vector& operator=( Vector&& vector )
500   {
501     if( this != &vector )
502     {
503       if( VectorBase::mData )
504       {
505         Release();
506       }
507       VectorBase::mData = vector.mData;
508       vector.mData = nullptr;
509     }
510     return *this;
511   }
512
513   /**
514    * @brief Iterator to the beginning of the data.
515    * @SINCE_1_0.0
516    * @return Iterator to the beginning of the data
517    */
518   Iterator Begin() const
519   {
520     ItemType* address = reinterpret_cast<ItemType*>( VectorBase::mData );
521     return address;
522   }
523
524   /**
525    * @brief Iterator to the end of the data (one past last element).
526    * @SINCE_1_0.0
527    * @return Iterator to the end of the data (one past last element)
528    */
529   Iterator End() const
530   {
531     ItemType* address = reinterpret_cast<ItemType*>( VectorBase::mData );
532     address += VectorBase::Count();
533     return address;
534   }
535
536   /**
537    * Support for C++11 Range-based for loop: for( item : container ).
538    * @SINCE_1_2.60
539    * @return The start iterator
540    */
541   Iterator begin() const
542   {
543     return Begin();
544   }
545
546   /**
547    * Support for C++11 Range-based for loop: for( item : container ).
548    * @SINCE_1_2.60
549    * @return The end iterator
550    */
551   Iterator end() const
552   {
553     return End();
554   }
555
556   /**
557    * @brief Subscript operator.
558    * @SINCE_1_0.0
559    * @param[in] index Index of the element
560    * @return Reference to the element for given index
561    * @pre Index must be in the vector's range.
562    */
563   ItemType& operator[]( SizeType index )
564   {
565     // reuse the const version
566     return const_cast< ItemType& >( const_cast< const Vector< ItemType >& >( *this )[ index ] );
567   }
568
569   /**
570    * @brief Subscript operator.
571    * @SINCE_1_0.0
572    * @param[in] index Index of the element
573    * @return Reference to the element for given index
574    * @pre Index must be in the vector's range.
575    */
576   const ItemType& operator[]( SizeType index ) const
577   {
578     DALI_ASSERT_VECTOR( VectorBase::mData && "Vector is empty" );
579     DALI_ASSERT_VECTOR( index < VectorBase::Count() && "Index out of bounds" );
580     ItemType* address = reinterpret_cast<ItemType*>( VectorBase::mData );
581     address += index;
582     return *address;
583   }
584
585   /**
586    * @brief Pushes back an element to the vector.
587    *
588    * The underlying storage may be reallocated to provide space.
589    * If this occurs, all pre-existing pointers into the vector will
590    * become invalid.
591    *
592    * @SINCE_1_0.0
593    * @param[in] element Element to be added
594    */
595   void PushBack( const ItemType& element )
596   {
597     const SizeType count = VectorBase::Count();
598     const SizeType newCount = count + 1u;
599     const SizeType capacity = VectorBase::Capacity();
600     if( newCount > capacity )
601     {
602       // need more space
603       Reserve( newCount << 1u ); // reserve double the current count
604     }
605     // set new count first as otherwise the debug assert will hit us
606     VectorBase::SetCount( newCount );
607     operator[]( count ) = element;
608   }
609
610   /**
611    * @brief Inserts an element to the vector.
612    *
613    * Elements after \e at are moved one position to the right.
614    *
615    * The underlying storage may be reallocated to provide space.
616    * If this occurs, all pre-existing pointers into the vector will
617    * become invalid.
618    *
619    * @SINCE_1_0.0
620    * @param[in] at Iterator where to insert the elements into the vector
621    * @param[in] element An element to be added
622    * @pre Iterator at must be in the vector's range ( Vector::Begin(), Vector::End() ).
623    */
624   void Insert( Iterator at, const ItemType& element )
625   {
626     DALI_ASSERT_VECTOR( ( at <= End() ) && ( at >= Begin() ) && "Iterator not inside vector" );
627     const SizeType size = sizeof( ItemType );
628     uint8_t* address = const_cast<uint8_t*>( reinterpret_cast<const uint8_t*>( &element ) );
629     VectorAlgorithms<BaseType>::Insert( reinterpret_cast< uint8_t* >( at ),
630                                         address,
631                                         address + size,
632                                         size );
633   }
634
635   /**
636    * @brief Inserts the given elements into the vector.
637    *
638    * Elements after \e at are moved the number of given elements positions to the right.
639    *
640    * The underlying storage may be reallocated to provide space.
641    * If this occurs, all pre-existing pointers into the vector will
642    * become invalid.
643    *
644    * @SINCE_1_0.0
645    * @param[in] at Iterator where to insert the elements into the vector
646    * @param[in] from Iterator to the first element to be inserted
647    * @param[in] to Iterator to the last element to be inserted
648    * @pre Iterator \e at must be in the vector's range ( Vector::Begin(), Vector::End() ).
649    * @pre Iterators \e from and \e to must be valid iterators.
650    * @pre Iterator \e from must not be grater than Iterator \e to.
651    *
652    */
653   void Insert( Iterator at, Iterator from, Iterator to )
654   {
655     DALI_ASSERT_VECTOR( ( at <= End() ) && ( at >= Begin() ) && "Iterator not inside vector" );
656     DALI_ASSERT_VECTOR( ( from <= to ) && "from address can't be greater than to" );
657
658     if( from == to )
659     {
660       // nothing to copy.
661       return;
662     }
663
664     VectorAlgorithms<BaseType>::Insert( reinterpret_cast< uint8_t* >( at ),
665                                         reinterpret_cast< uint8_t* >( from ),
666                                         reinterpret_cast< uint8_t* >( to ),
667                                         sizeof( ItemType ) );
668   }
669
670   /**
671    * @brief Reserves space in the vector.
672    *
673    * Reserving less than current Capacity is a no-op.
674    * @SINCE_1_0.0
675    * @param[in] count Count of elements to reserve
676    */
677   void Reserve( SizeType count )
678   {
679     VectorAlgorithms<BaseType>::Reserve( count, sizeof( ItemType ) );
680   }
681
682   /**
683    * @brief Resizes the vector. Does not change capacity.
684    *
685    * @SINCE_1_0.0
686    * @param[in] count Count to resize to
687    */
688   void Resize( SizeType count )
689   {
690     ItemType item = ItemType();
691     Resize(count, item);
692   }
693
694   /**
695    * @brief Resizes the vector. Does not change capacity.
696    *
697    * @SINCE_1_0.0
698    * @param[in] count Count to resize to
699    * @param[in] item An item to insert to the new indices
700    */
701   void Resize( SizeType count, const ItemType& item )
702   {
703     const SizeType oldCount = VectorBase::Count();
704     if( count <= oldCount )
705     {
706       // getting smaller so just set count
707       VectorBase::SetCount( count );
708     }
709     else
710     {
711       // remember how many new items get added
712       SizeType newItems = count - oldCount;
713       Reserve( count );
714       for( ; newItems > 0u; --newItems )
715       {
716         PushBack( item );
717       }
718     }
719   }
720
721   /**
722    * @brief Erases an element.
723    *
724    * Does not change capacity. Other elements get moved.
725    *
726    * @SINCE_1_0.0
727    * @param[in] iterator Iterator pointing to the item to remove
728    * @return Iterator pointing to next element
729    * @pre Iterator \e iterator must be within the vector's range ( Vector::Begin(), Vector::End() - 1 ).
730    *
731    */
732   Iterator Erase( Iterator iterator )
733   {
734     DALI_ASSERT_VECTOR( (iterator < End()) && (iterator >= Begin()) && "Iterator not inside vector" );
735     if( iterator < ( End() - 1u ) )
736     {
737       VectorAlgorithms<BaseType>::Erase( reinterpret_cast< uint8_t* >( iterator ), sizeof( ItemType ) );
738     }
739     else
740     {
741       // just remove the element
742       Remove( iterator );
743     }
744     return iterator;
745   }
746
747   /**
748    * @brief Erases a range of elements.
749    *
750    * Does not change capacity. Other elements get moved.
751    *
752    * @SINCE_1_0.0
753    * @param[in] first Iterator to the first element to be erased
754    * @param[in] last Iterator to the last element to be erased
755    *
756    * @return Iterator pointing to the next element of the last one
757    * @pre Iterator \e first must be in the vector's range ( Vector::Begin(), Vector::End() ).
758    * @pre Iterator \e last must be in the vector's range ( Vector::Begin(), Vector::End() ).
759    * @pre Iterator \e first must not be grater than Iterator \e last.
760    *
761    */
762   Iterator Erase( Iterator first, Iterator last )
763   {
764     DALI_ASSERT_VECTOR( ( first <= End() ) && ( first >= Begin() ) && "Iterator not inside vector" );
765     DALI_ASSERT_VECTOR( ( last <= End() ) && ( last >= Begin() ) && "Iterator not inside vector" );
766     DALI_ASSERT_VECTOR( ( first <= last ) && "first iterator greater than last" );
767
768     Iterator nextElement;
769
770     if( last == End() )
771     {
772       // Erase up to the end.
773       VectorBase::SetCount( VectorBase::Count() - ( last - first ) );
774       nextElement = End();
775     }
776     else
777     {
778       nextElement = reinterpret_cast<Iterator>( VectorAlgorithms<BaseType>::Erase( reinterpret_cast< uint8_t* >( first ),
779                                                                                    reinterpret_cast< uint8_t* >( last ),
780                                                                                    sizeof( ItemType ) ) );
781     }
782
783     return nextElement;
784   }
785
786   /**
787    * @brief Removes an element.
788    *
789    * Does not maintain order. Swaps the element with end and
790    * decreases size by one.  This is much faster than Erase so use
791    * this in case order does not matter. Does not change capacity.
792    *
793    * @SINCE_1_0.0
794    * @param[in] iterator Iterator pointing to the item to remove
795    * @pre Iterator \e iterator must be in the vector's range ( Vector::Begin(), Vector::End() - 1 ).
796    *
797    */
798   void Remove( Iterator iterator )
799   {
800     DALI_ASSERT_VECTOR( (iterator < End()) && (iterator >= Begin()) && "Iterator not inside vector" );
801
802     Iterator last = End() - 1u;
803     if( last > iterator )
804     {
805       std::swap( *iterator, *last );
806     }
807     VectorBase::SetCount( VectorBase::Count() - 1u );
808   }
809
810   /**
811    * @brief Swaps the contents of two vectors.
812    *
813    * @SINCE_1_0.0
814    * @param[in] vector Vector to swap with
815    */
816   void Swap( Vector& vector )
817   {
818     VectorBase::Swap( vector );
819   }
820
821   /**
822    * @brief Clears the contents of the vector. Keeps its capacity.
823    * @SINCE_1_0.0
824    */
825   void Clear()
826   {
827     VectorAlgorithms<BaseType>::Clear();
828   }
829
830   /**
831    * @brief Releases the memory that the vector holds.
832    * @SINCE_1_0.0
833    */
834   void Release()
835   {
836     VectorAlgorithms<BaseType>::Release();
837   }
838 };
839
840 /**
841  * @}
842  */
843 } // namespace Dali
844
845 #endif // DALI_VECTOR_H