我正在实现一个适配器来获取List和Hashmap,并将它们分别转换为可扩展ListView的头和子项。在构造函数的Log语句中,它显示值正在成功传输到本地列表。但随后它突然变为零。
我无法确定哪里出了问题,哪里出了问题。请帮忙。
以下是Adapter类的代码:
array1
答案 0 :(得分:1)
您在打印地图时删除了该项目,
# Sorted (descending) => 810, 810, 738, 738, 90, 82, 82, 10
from queue import PriorityQueue
def karmarkar_karp_partition(arr):
pqueue = PriorityQueue()
for e in arr:
pqueue.put_nowait((-e, e))
for _ in range(len(arr)-1):
_, first = pqueue.get_nowait()
_, second = pqueue.get_nowait()
diff = first - second
pqueue.put_nowait((-diff, diff))
return pqueue.get_nowait()[1]
只需删除它就能正常工作。
public void insertAtIndex(int x, int index){
Element n = new Element();
n.val = x;
if (head == null){ // If the list is empty
head = n; // we insert the Element n as the first element
}
else{
Element h = head; // our current element we are looking at
int currentIndex = 0;
while (h.next!=null && currentIndex < index) { // increment until we reach the correct index
h = h.next; // our Element h becomes the next Element added to the list
currentIndex++;
}
Element tail = h.next; // store the rest of the list in a temp variable, tail
h.next = n; // we've reached the right index and/or the end, so add the element n here
n.next = tail // reattach the tail
}
}
答案 1 :(得分:1)
在您的方法Error:(9, 15) scrutinee is incompatible with pattern type;
found : Seq[A]
required: Array[Int]
case Seq(
中,const lookup = (firstName, prop) => {
const person = contacts.find(p => p.firstName === firstName);
if (!person) {
return 'No such contact';
}
if (!person[prop]) {
return 'No such property';
}
return person[prop];
};
const person = lookup('Kristian', 'likes');
块中的最后一个语句是
printMap()
此语句可能不会导致while
,但会从 it.remove(); // avoids a ConcurrentModificationException
中删除当前条目。所以执行后
Exception
<{1}} HashMap
中的tableList 将为空。