Main Page Class List Class Members

- Main Page
- User's Guide
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# sdk/extensions/authoring/source/VHACD/inc/vhacdCircularList.h

Go to the documentation of this file.

    00001 /* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
    00002  All rights reserved.
    00003
    00004
    00005  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    00006
    00007  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    00008
    00009  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    00010
    00011  3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
    00012
    00013  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00014  */
    00015 #pragma once
    00016 #ifndef VHACD_CIRCULAR_LIST_H
    00017 #define VHACD_CIRCULAR_LIST_H
    00018 #include <stdlib.h>
    00019 namespace VHACD {
    00021 template <typename T>
    00022 class CircularListElement {
    00023 public:
    00024     T& GetData() { return m_data; }
    00025     const T& GetData() const { return m_data; }
    00026     CircularListElement<T>*& GetNext() { return m_next; }
    00027     CircularListElement<T>*& GetPrev() { return m_prev; }
    00028     const CircularListElement<T>*& GetNext() const { return m_next; }
    00029     const CircularListElement<T>*& GetPrev() const { return m_prev; }
    00031     CircularListElement(const T& data) { m_data = data; }
    00032     CircularListElement(void) {}
    00034     ~CircularListElement(void) {}
    00035 private:
    00036     T m_data;
    00037     CircularListElement<T>* m_next;
    00038     CircularListElement<T>* m_prev;
    00039
    00040     CircularListElement(const CircularListElement& rhs);
    00041 };
    00043 template <typename T>
    00044 class CircularList {
    00045 public:
    00046     CircularListElement<T>*& GetHead() { return m_head; }
    00047     const CircularListElement<T>* GetHead() const { return m_head; }
    00048     bool IsEmpty() const { return (m_size == 0); }
    00049     size_t GetSize() const { return m_size; }
    00050     const T& GetData() const { return m_head->GetData(); }
    00051     T& GetData() { return m_head->GetData(); }
    00052     bool Delete();
    00053     bool Delete(CircularListElement<T>* element);
    00054     CircularListElement<T>* Add(const T* data = 0);
    00055     CircularListElement<T>* Add(const T& data);
    00056     bool Next();
    00057     bool Prev();
    00058     void Clear()
    00059     {
    00060         while (Delete())
    00061             ;
    00062     };
    00063     const CircularList& operator=(const CircularList& rhs);
    00065     CircularList()
    00066     {
    00067         m_head = 0;
    00068         m_size = 0;
    00069     }
    00070     CircularList(const CircularList& rhs);
    00072     ~CircularList(void) { Clear(); };
    00073 private:
    00074     CircularListElement<T>* m_head;
    00075     size_t m_size;
    00076 };
    00077 }
    00078 #include "vhacdCircularList.inl"
    00079 #endif // VHACD_CIRCULAR_LIST_H

Copyright © 2015-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com