Time for action – using STL containers
Let's now replace raw arrays with standard STL containers by following these steps:
- Open the
jni/GraphicsManager.hpp
header and include the headers:Vector
, which defines an STL container encapsulating C arrays (with a few more interesting features such as dynamic resizing)Map
, which encapsulates the equivalent of a Java HashMap (that is, an associative array)
Then, remove the
textureResource
member in theTextureProperties
structure. Use amap
container instead of a raw array formTextures
(prefixed with thestd
namespace). The first parameter is the key type and the second the value type.Finally, replace all the other raw arrays with a
vector
, as shown in the following:... #include <android_native_app_glue.h> ...
Get Android NDK Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.