mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-27 02:01:07 +00:00
feat[list]: 添加性能更加高的原生基础类型的固定大小list
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user