具体实现源码没研究,写了几行测试代码,发现和stl的vector差不多,会自动扩容,支持随机存取。
从测试结果来看,自动扩容的机制也和vector一样,如下:
m_array=wyArrayNew(4);
wyArrayPush(m_array,new wyObject());
wyArrayPush(m_array,new wyObject());
wyArrayPush(m_array,new wyObject());
wyArrayPush(m_array,new wyObject());
LOGD("==== length : %d =====",adapter->getLength());
LOGD("==== size : %d =====",adapter->getSize());
wyArrayPush(m_array,new wyObject());
LOGD("==== length : %d =====",adapter->getLength());
LOGD("==== size : %d =====",adapter->getSize());
4,4
5,8