// FTTList - [2020-04-13 11:57:47]
#ifndef _FTTLIST_H_
#define _FTTLIST_H_

#include "common.h"

/*
001A4A88 FTTList<FTTAtlasGeneratorNode *>::FTTList(uint)
001A4B00 FTTList<FTTAtlasGeneratorNode *>::~FTTList()
001A4B32 FTTList<FTTAtlasGeneratorNode *>::~FTTList()
001A4B40 FTTList<FTTAtlasGeneratorNode *>::Clear()
001A4B7C FTTList<FTTAtlasGeneratorNode *>::InsertHead(FTTAtlasGeneratorNode *)
001A4BBE FTTList<FTTAtlasGeneratorNode *>::PopHead()

00198D74 FTTList<TEdgeGroup>::FTTList(uint)
001991BE FTTList<TEdgeGroup>::Iterator::operator*()
001991FE FTTList<TEdgeGroup>::Remove(FTTList<TEdgeGroup>::Iterator,bool)
001996E8 FTTList<TEdgeGroup>::Clear()
00199CD8 FTTList<TEdgeGroup>::~FTTList()
001A499A FTTList<TEdgeGroup>::Iterator::operator++()
001A49A2 FTTList<TEdgeGroup>::Iterator::operator!=(FTTList<TEdgeGroup>::Iterator const&)
001A49AE FTTList<TEdgeGroup>::Iterator::operator->()
001A4E04 FTTList<TEdgeGroup>::~FTTList()
001A5A28 FTTList<TEdgeGroup>::InsertTail(TEdgeGroup const&)
001A5AC4 FTTList<TEdgeGroup>::Node::operator=(FTTList<TEdgeGroup>::Node&&)

001F9124 FTTList<TEventInfo>::FTTList(uint)
001F8C3C FTTList<TEventInfo>::~FTTList()
001F9112 FTTList<TEventInfo>::~FTTList()
001F9068 FTTList<TEventInfo>::Iterator::operator!=(FTTList<TEventInfo>::Iterator const&)
001F9074 FTTList<TEventInfo>::Iterator::operator*()
001F9078 FTTList<TEventInfo>::Iterator::operator++()
001F90DC FTTList<TEventInfo>::Clear()
001F9120 FTTList<TEventInfo>::Iterator::operator->()
001F91E8 FTTList<TEventInfo>::InsertTail(TEventInfo const&)
001F9284 FTTList<TEventInfo>::Node::operator=(FTTList<TEventInfo>::Node&&)
001F92D6 FTTList<TEventInfo>::Remove(FTTList<TEventInfo>::Iterator,bool)

001C64AC FTTList<TShadowAABB *>::FTTList(uint)
001C6660 FTTList<TShadowAABB *>::FTTList(FTTList<TShadowAABB *> const&)
001C648C FTTList<TShadowAABB *>::~FTTList()
001C3C7C FTTList<TShadowAABB *>::~FTTList()
001C6456 FTTList<TShadowAABB *>::Clear()
001C6700 FTTList<TShadowAABB *>::swap(FTTList<TShadowAABB *>&,FTTList<TShadowAABB *>&)
001C673A FTTList<TShadowAABB *>::InsertTail(TShadowAABB * const&)
001C6780 FTTList<TShadowAABB *>::PopHead()

001C37D0 FTTList<TShadowAABB>::FTTList(uint)
001C6534 FTTList<TShadowAABB>::FTTList(FTTList<TShadowAABB> const&)
001C3CA0 FTTList<TShadowAABB>::~FTTList()
001C649E FTTList<TShadowAABB>::~FTTList()
001C40EC FTTList<TShadowAABB>::operator=(FTTList<TShadowAABB> const&)
001C5D38 FTTList<TShadowAABB>::Iterator::operator!=(FTTList<TShadowAABB>::Iterator const&)
001C6154 FTTList<TShadowAABB>::Remove(FTTList<TShadowAABB>::Iterator,bool)
001C61F0 FTTList<TShadowAABB>::Clear()
001C67B0 FTTList<TShadowAABB>::InsertTail(TShadowAABB const&)
001C6854 FTTList<TShadowAABB>::swap(FTTList<TShadowAABB>&,FTTList<TShadowAABB>&)
001C5D44 FTTList<TShadowAABB>::Iterator::operator*()
001C614A FTTList<TShadowAABB>::Iterator::operator++()
001C649A FTTList<TShadowAABB>::Iterator::operator->()
*/

template <typename T>
class FTTList {
public:
  struct FTTList_Node {
    T node;
    FTTList_Node *next;
  };

  typedef void (*fun_notity_clear)(T *);

  class Iterator {
  public:
    // 001C5D38 001F9068
    bool operator!=(Iterator const &other) {
      return pNode_4 != other.pNode_4;
    };

    // 001C5D44
    FTTList_Node *operator*() {
      return pNode_4;
    };

    // 001C614A
    void operator++() {
      pNode_4 = pNode_4->next;
    };

    // 001C649A
    FTTList_Node *operator->() {
      return pNode_4;
    };

    int i_0;
    FTTList_Node *pNode_4;
  };

  // 001C37D0 001C64AC
  FTTList(uint count) {
    // 001C37E6
    if (count) {
      FTTList_Node *r6_pNodeList = new FTTList_Node[count];
      field_4 = r6_pNodeList;  //: 001C3822   STRD.W R6, R6, [R4,#4]
      field_8 = r6_pNodeList;

      int r1_dCount = count;
      // 001C3826
      for (int r1 = 0; r1 != count; r1++) {  // loc_1C3836
        r6_pNodeList[r1].next = &r6_pNodeList[r1 + 1];
      }

      // 001C383A
      r6_pNodeList[count - 1].next = nullptr;
    } else {
      // loc_1C3846
      field_4 = nullptr;
      field_8 = nullptr;
    }

    // loc_1C3852
    count_C = count;

    field_10 = nullptr;  // 001C3862   VST1.32         {D16-D17}, [R0]
    field_14 = nullptr;
    pFun_18 = nullptr;
    use_count_1C = 0;
  };

  // 001C6534 001C6660
  FTTList(FTTList<T> const &other) {
    pFun_18 = other.pFun_18;
    count_C = other.count_C;
    use_count_1C = other.field_1C;
    if (other.count_C) {
      // 001C6680
      field_8 = new FTTList_Node[other.count_C];
      field_4 = &field_8[other.field_4 - other.field_8];

      // 001C66AC
      if (other.field_10 != nullptr) {
        // 001C66AE
        field_10 = &field_8[other.field_10 - other.field_8];
      } else {
        field_10 = nullptr;
      }

      // loc_1C66B4
      if (other.field_14 != nullptr) {
        // 001C66BA
        field_14 = &field_8[other.field_14 - other.field_8];
      } else {
        // loc_1C66C2
        field_14 = nullptr;
      }

      // loc_1C66C4
      for (int dr0 = 0; dr0 < count_C; dr0++) {  // loc_1C66F2
        // loc_1C66CA
        field_8[dr0].node = other.field_8[dr0].node;
        if (other.field_8[dr0].next != nullptr) {
          field_8[dr0].next = &field_8[other.field_8[dr0].next - other.field_8];
        } else {
          field_8[dr0].next = nullptr;
        }
      }
      // loc_1C66F8
    }
  };

  virtual ~FTTList(){

  };

  // 001C61F0
  void Clear() {
    FTTList_Node *r5_pNode = field_10;
    // 001C61F6

    while (r5_pNode != nullptr) {  // loc_1C621C
      // loc_1C61F8
      FTTList_Node *r6_pNodeNext = r5_pNode->next;
      // 001C61FE
      if (pFun_18 != nullptr) {
        pFun_18(&r5_pNode->node);
      }

      // loc_1C6204
      if (field_8 != nullptr) {
        r5_pNode->next = field_4;  // 001C620A
        field_4 = r5_pNode;
      } else {
        delete r5_pNode;
      }
      r5_pNode = r6_pNodeNext;
    }

    field_10 = nullptr;
    field_14 = nullptr;
    use_count_1C = 0;
  };

  // 001C673A
  void InsertTail(T *const &a2) {
    FTTList_Node *v6_field_4 = nullptr;
    FTTList_Node *v7_field_4 = nullptr;
    FTTList_Node *v7_field_4_next = nullptr;
    T *v8 = nullptr;
    if (field_8) {
      v6_field_4 = (FTTList_Node *)field_4;
      v7_field_4 = (FTTList_Node *)field_4;
      v7_field_4_next = field_4->next_4;
      v8 = (T *)v7_field_4->next_4;
      field_4 = (T *)field_4->next_4;
      v8->field_0 = 0.0;
      v6_field_4->node = 0;
    } else {
      v6_field_4 = new FTTList_Node;
      v8 = v6_field_4->next;
    }

    v6_field_4->node = a2;
    field_14 = v6_field_4;
    use_count_1C++;
  };

  // 001C6154
  void Remove(FTTList<T>::Iterator it, bool b2) {
    if (field_10 != it.pNode_4) {
      // 001C6160
    } else {
      // loc_1C61AC
      if (pFun_18 != nullptr) {
      }
    }
    return --use_count_1C;
  };

  // 001A4B7C
  void InsertHead(T) {
  };

  // 001A4BBE
  T PopHead() {
    return nullptr;
  };

  FTTList_Node *field_4;
  FTTList_Node *field_8;
  int count_C;
  FTTList_Node *field_10;
  FTTList_Node *field_14;
  fun_notity_clear pFun_18;  //函数指针
  int use_count_1C;
};

#endif  //_FTTLIST_H_