feat[list]: 添加性能更加高的原生基础类型的固定大小list

This commit is contained in:
godotg
2022-09-23 21:02:53 +08:00
parent 5c3c85bc2a
commit c084e16e14
8 changed files with 1141 additions and 0 deletions
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2020 The zfoo Authors
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.protocol.collection;
import org.junit.Test;
/**
* @author godotg
* @version 3.0
*/
public class ListTest {
@Test
public void testFixedSizeIntList() {
var list = new FixedSizeIntList(3);
list.set(0, 1);
list.set(1, 2);
list.set(2, 3);
for (int i = 0; i < list.size(); i++) {
for (var ele : list) {
// test iterator
}
}
}
@Test
public void testFixedSizeStringList() {
var list = new FixedSizeStringList(3);
list.set(0, "1");
list.set(1, "2");
list.set(2, "3");
for (int i = 0; i < list.size(); i++) {
for (var ele : list) {
// test iterator
}
}
}
}