// FTTVector - [2020-04-13 11:57:47]
#ifndef _TTVECTOR_H_
#define _TTVECTOR_H_

#include "common.h"

/*

0016D974 TTVector<TNMNeighbour>::~TTVector()
00168EA8 TTVector<TNMNeighbour>::Insert(TNMNeighbour)

0016D9A2 TTVector<TNMTri>::~TTVector()
00168D00 TTVector<TNMTri>::Insert(TNMTri)

0016D992 TTVector<fpoint2<14u>>::~TTVector()
00169786 TTVector<fpoint2<14u>>::Insert(fpoint2<14u>)
001696DE TTVector<fpoint2<14u>>::Append(TTVector<fpoint2<14u>> const&)

0016D984 TTVector<uchar>::~TTVector()
0016970C TTVector<uchar>::Append(TTVector<uchar> const&)
0016972A TTVector<uchar>::Insert(uchar)
*/

template <typename T>
class TTVector {
public:
  TTVector() {
    pBuf_0 = nullptr;
    dTotal_4 = 0;
    udInsertPos_8 = 0;
  };

  ~TTVector() {
    if (pBuf_0 != nullptr)
      delete[] pBuf_0;
  };

  void Append(TTVector<T> const& other) {
    for (int i = 0; i < other.udInsertPos_8; ++i)
      Insert(other.pBuf_0[i]);
  }

  void Insert(T a) {
    T* pDat = nullptr;
    if (dTotal_4) {
      // 00169734
      if (udInsertPos_8 == dTotal_4) {
        // 0016973E
        int dr0 = dTotal_4 * 2;
        pDat = new T[dTotal_4 * 2];
        memcpy(pDat, pBuf_0, sizeof(T) * dTotal_4);
        delete[] pBuf_0;
        pBuf_0 = pDat;
        dTotal_4 = dTotal_4 * 2;
        // pr7 = ???
      } else {
        // loc_16977A
        pDat = pBuf_0;
      }
    } else {
      // loc_169762
      dTotal_4 = 1;
      pBuf_0 = new T[dTotal_4];
      pDat = pBuf_0;
    }
    // loc_16977C
    pDat[udInsertPos_8] = a;
    udInsertPos_8++;
  }

  T* pBuf_0;
  int dTotal_4;
  uint udInsertPos_8;
  //int field_c;
};

#endif  //_FTTVECTOR_H_