本文整理了Java中us.ihmc.robotics.lists.YoPreallocatedList.size()
方法的一些代码示例,展示了YoPreallocatedList.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YoPreallocatedList.size()
方法的具体详情如下:
包路径:us.ihmc.robotics.lists.YoPreallocatedList
类名称:YoPreallocatedList
方法名:size
[英]Returns the number of active elements in this list
[中]返回此列表中活动元素的数量
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit
/**
* Returns {@code true} if this list contains no elements.
*
* @return {@code true} if this list contains no elements.
*/
@Override
public boolean isEmpty()
{
return size() == 0;
}
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit
/**
* Sorts the array in place using {@link Arrays::sort}
* @param comparator to determine element ordering
*/
@Override
public void sort(Comparator<? super T> comparator)
{
if(size() == 0)
return;
Arrays.sort(values, 0, size(), comparator);
}
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit
/** {@inheritDoc} */
@Override
public boolean contains(Object o)
{
for (int i = 0; i < size(); i++)
{
if(values[i].equals(o))
{
return true;
}
}
return false;
}
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit
/**
* Returns the elements in this list as array
*
* This method allocates a new array
*
* @return new array of length size();
*/
@Override
public T[] toArray()
{
@SuppressWarnings("unchecked")
T[] array = (T[]) Array.newInstance(clazz, size());
System.arraycopy(values, 0, array, 0, size());
return array;
}
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit
/** {@inheritDoc} */
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (!(obj instanceof List))
return false;
List<?> other = (List<?>) obj;
if (size() != other.size())
return false;
for (int i = 0; i < size(); i++)
{
if (!values[i].equals(other.get(i)))
return false;
}
return true;
}
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit
/** {@inheritDoc} */
@Override
@SuppressWarnings("unchecked")
public <S> S[] toArray(S[] dest)
{
int size = size();
if (dest.length < size)
{
return (S[]) Arrays.copyOf(values, size, dest.getClass());
}
System.arraycopy(values, 0, dest, 0, size);
if (dest.length > size)
dest[size] = null;
return dest;
}
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit
/**
* @return the remaining space in this sequence (capacity() - size())
*/
public int remaining()
{
return capacity() - size();
}
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit
private void rangeCheck(int index)
{
if(index < 0 || index > this.position.getIntegerValue())
{
throw new ArrayIndexOutOfBoundsException("Position is not valid in the list, size is " + size() + ", requested element is " + index);
}
}
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit
@Override
public String toString()
{
String s = "";
s += clazz.getSimpleName();
s += " pos: " + position.getIntegerValue();
s += " [";
for (int i = 0; i < size(); i++)
{
if (i > 0)
s += ", ";
s += values[i].toString();
}
s += "]";
return s;
}
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit-test
YoPreallocatedList<YoInteger> list = new YoPreallocatedList<>(YoInteger.class, "Test", 10, new YoVariableRegistry("Test"));
int currentSize = 10;
while (list.size() < currentSize)
list.add().set(10 + list.size());
list.swap(indexA, indexB);
Collections.swap(expectedList, indexA, indexB);
assertTrue(list.size() == currentSize);
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit-test
while (list.size() < currentSize)
list.add().set(10 + list.size());
expectedList.remove(indexOfRemovedObject);
currentSize--;
assertTrue(list.size() == currentSize);
expectedList.remove(indexOfRemovedObject);
currentSize--;
assertTrue(list.size() == currentSize);
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit-test
@Test(timeout = 30000)
public void testRemoveIndex()
{
int size = 10;
YoPreallocatedList<YoInteger> list = new YoPreallocatedList<>(YoInteger.class, "Test", size, new YoVariableRegistry("Test"));
for (int i = 0; i < size; i++)
{
list.add().set(i);
}
assertTrue(list.remove(8).getValue() == 8);
assertTrue(list.size() == size - 1);
assertTrue(list.remove(4).getValue() == 4);
assertTrue(list.size() == size - 2);
assertTrue(list.remove(2).getValue() == 2);
assertTrue(list.size() == size - 3);
assertTrue(list.remove(size - 4).getValue() == size - 1);
assertTrue(list.size() == size - 4);
}
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit-test
assertTrue(list.size() == finalSize);
for (int i = 0; i < finalSize; i++)
assertTrue(list.size() == finalSize);
for (int i = 0; i < finalSize; i++)
assertTrue(list.size() == finalSize);
for (int i = 0; i < finalSize; i++)
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit-test
@Test(timeout = 30000)
public void testConstructor()
{
YoPreallocatedList<YoDouble> list = new YoPreallocatedList<>(YoDouble.class, "Test", 10, new YoVariableRegistry("Test"));
assertTrue(list.isEmpty());
assertTrue(list.size() == 0);
assertTrue(list.getLast() == null);
}
内容来源于网络,如有侵权,请联系作者删除!