且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

圆形的ArrayList(扩展ArrayList的)

更新时间:2023-11-29 16:18:10

你能不能获得ArrayList中,并沿着这些线路覆盖了get(INT指数)方法:

Can't you derive from ArrayList and override the the get(int index) method along those lines:

@Override
public E get(int index)
{
    if(index < 0)
        index = index + size();

    return super.get(index);
}

我是什么失踪?

请注意,此实现不会(分别与正面和负面的指数,有点像Python)的折叠任意索引到您的有效索引范围,但只允许你正确地从左右两侧解决您的清单。

Note that this implementation would not fold arbitrary indices into your valid index range but only allow you to properly address your list from both the left and right sides (with positive and negative indices respectively, a bit like in Python).