Implement struct TArray and simplify code. (#3291)
* Implement operator[] for TArray and simplify the code.
* fix a build error.
* add a constructor with std::vector input
* fix build error
* update based on code review feedback
Co-authored-by: Weixing Zhang <wezhan@microsoft.com>