linked-list

Observable LinkedList

纵然是瞬间 提交于 2019-12-01 19:32:50
问题 In my WPF app, I have an ItemsControl whose items values are dependant upon the previous item displayed . The ViewModel is an audio file split into parts of variable length, and i need to display it in such manner, with a DateTime displayed on the right, and that's what i need to calculate (I only know each part's length, i need to calculate the actual time it starts and ends, and the position on the ItemsControl). -- ---- ------------ -- -------------------- My first approach was to use an

Observable LinkedList

大憨熊 提交于 2019-12-01 18:33:53
In my WPF app, I have an ItemsControl whose items values are dependant upon the previous item displayed . The ViewModel is an audio file split into parts of variable length, and i need to display it in such manner, with a DateTime displayed on the right, and that's what i need to calculate (I only know each part's length, i need to calculate the actual time it starts and ends, and the position on the ItemsControl). -- ---- ------------ -- -------------------- My first approach was to use an ObservableCollection<MyviewModel> but soon enough some horrors occured : 5-way multibinding in which's

Java two equal signs in one statement? [duplicate]

拜拜、爱过 提交于 2019-12-01 18:19:55
This question already has an answer here: Java - Order of Operations - Using Two Assignment Operators in a Single Line 4 answers Can someone help me understand what the following code does and what the line with two equal sign does? How does something equal to something equal to something work in this constructor? public More ...LinkedList() { header.next = header.previous = header; } Here is the link to the website where I saw this and I'm trying to figure it out: http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/LinkedList.java#LinkedList.0header Read

comparison of Linkedlist over arraylist [duplicate]

放肆的年华 提交于 2019-12-01 18:11:31
This question already has an answer here: When to use LinkedList over ArrayList in Java? 32 answers I understood that LinkedList is implemented as a double linked list. Its performance on add and remove is better than Arraylist , but worse on get and set methods. Does that mean I should choose LinkedList over Arraylist for inserting? I wrote a small test and found ArrayList is faster in inserting. Then how does linked list faster than ArrayList ? Please refer the below example which I have done. import java.util.Date; import java.util.LinkedList; import java.util.List; public class

LinkedList iterator remove [duplicate]

跟風遠走 提交于 2019-12-01 18:11:17
Possible Duplicate: Efficient equivalent for removing elements while iterating the Collection private LinkedList flights; .... public void clear(){ ListIterator itr = flights.listIterator(); while(itr.hasNext()){ flights.remove(itr.next()); } } .... Exception in thread "main" java.util.ConcurrentModificationException at java.util.LinkedList$ListItr.checkForComodification(Unknown Source) at java.util.LinkedList$ListItr.next(Unknown Source) at section1.FlightQueue.clear(FlightQueue.java:44) at section1.FlightTest001.main(FlightTest001.java:22) Whats wrong with it? cant at all understand why the

Circular LinkedList in Java

懵懂的女人 提交于 2019-12-01 18:09:51
I am brushing up on my data structures by reading a book and one of the questions it asks is to build a circular Single Linked List by not using "first" & "last" pointers, but rather allow access to it by using one reference "current". I am not sure I understand the question, I always thought I needed at least either first or last. Here is my implementation but it has "first", not sure how to get around it. Can you please comment on how I can adjust my code to eliminate reliance on first? class Link { public int iData; public Link next; public Link(int id) { // constructor iData = id; } public

LinkedList iterator remove [duplicate]

拟墨画扇 提交于 2019-12-01 17:21:13
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Efficient equivalent for removing elements while iterating the Collection private LinkedList flights; .... public void clear(){ ListIterator itr = flights.listIterator(); while(itr.hasNext()){ flights.remove(itr.next()); } } .... Exception in thread "main" java.util.ConcurrentModificationException at java.util.LinkedList$ListItr.checkForComodification(Unknown Source) at java.util.LinkedList$ListItr.next(Unknown

Printing my linked list in reverse order in C++

£可爱£侵袭症+ 提交于 2019-12-01 16:57:57
So I'm fairly new to C++ and today I decided to sit down and understand how linked lists work. I'm having a lot of fun doing it so far, but I've encountered a problem when trying to print my linked list in reverse order (not reverse the order of the linked list!) Also, I wanted to do this without having a double linked list: #include <iostream> #include <string> using namespace std; class LinkedList { public: LinkedList() { head = NULL; } void addItem(string x) { if(head == NULL) { head = new node(); head->next = NULL; head->data = x; } else { node* temp = head; while(temp->next != NULL) temp

comparison of Linkedlist over arraylist [duplicate]

帅比萌擦擦* 提交于 2019-12-01 16:57:47
问题 This question already has answers here : When to use LinkedList over ArrayList in Java? (32 answers) Closed 5 years ago . I understood that LinkedList is implemented as a double linked list. Its performance on add and remove is better than Arraylist , but worse on get and set methods. Does that mean I should choose LinkedList over Arraylist for inserting? I wrote a small test and found ArrayList is faster in inserting. Then how does linked list faster than ArrayList ? Please refer the below

Circular LinkedList in Java

自古美人都是妖i 提交于 2019-12-01 16:37:20
问题 I am brushing up on my data structures by reading a book and one of the questions it asks is to build a circular Single Linked List by not using "first" & "last" pointers, but rather allow access to it by using one reference "current". I am not sure I understand the question, I always thought I needed at least either first or last. Here is my implementation but it has "first", not sure how to get around it. Can you please comment on how I can adjust my code to eliminate reliance on first?