1 2 3 4 5 6 7 8 9 | public void insert( int i, Item item){ assert count + 1 <= capacity; assert i + 1 >= 1 && i + 1 <= capacity; i += 1 ; data[i] = item; indexes[count+ 1 ] = i; count ++; shiftUp(count); } |
老师您好!索引最大堆中,insert方法是把data[i+1]替换为item,那么indexes[]中所存放的i+1所代表的元素不是就变了吗?为什么在 insert中没有对其进行相应的处理?