Array2D.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. /*=============================================================================
  16. Array2D.h:
  17. =============================================================================*/
  18. #pragma once
  19. template <class T>
  20. class Array2D : public TArray<T>
  21. {
  22. public:
  23. typedef int32 size_type;
  24. typedef T reference;
  25. Array2D(size_type in_sizeX, size_type in_sizeY)
  26. : TArray<T>()
  27. , m_sizeX(in_sizeX)
  28. , m_sizeY(in_sizeY)
  29. {
  30. TArray<T>::Init(0, in_sizeX * in_sizeY);
  31. }
  32. Array2D(size_type in_sizeX, size_type in_sizeY, T in_defaultValue)
  33. : TArray<T>()
  34. , m_sizeX(in_sizeX)
  35. , m_sizeY(in_sizeY)
  36. {
  37. TArray<T>::Init(in_defaultValue, in_sizeX * in_sizeY);
  38. }
  39. inline reference& operator() (size_type in_x, size_type in_y)
  40. {
  41. return At(in_x, in_y);
  42. }
  43. inline const reference& operator() (size_type in_x, size_type in_y) const
  44. {
  45. return At(in_x, in_y);
  46. }
  47. inline reference& At(size_type in_x, size_type in_y)
  48. {
  49. return TArray<T>::GetData()[in_y*m_sizeX + in_x];
  50. }
  51. inline const reference& At(size_type in_x, size_type in_y) const
  52. {
  53. return TArray<T>::GetData()[in_y*m_sizeX + in_x];
  54. }
  55. size_type m_sizeX;
  56. size_type m_sizeY;
  57. };