thank you so much for reply
let me explain more
first my search is Breadth first search
if the algorithm find the goal it will break the While and everything is fine
but at the moment no result has found (that means the queue is empty)
i have a matrix like this :
[1,2; 1,3 ; 1,5 ; 3,8 ; 5,10]
i input 1 by hand for the first number in queue
it searches the 1 in my matrix (only the first column) we have 3 ones in our first column
so it add 2 , 3 , 5 to the queue
after finish searching in my matrix it deletes the first one (q.removeFirst()
and gets the first one so now is 2
loop repeats until we are at 10 and no goal found yet
so at this line :
q.removeFirst();
temp=q.getFirst();
it removes 10 and tries to get first item which is nothing/null and that's when error happens
so what i want to do after that is turn a flag 1 and come out of my while loop
if i use poll method instead of these
q.removeFirst();
temp=q.getFirst();
lines everything could work fine , saddly matlab gives me this error for it
Undefined function 'pollFirst' for input arguments of type 'double'.
Error in TestFInal2 (line 102)
pollFirst(temp)
EDIT : problem solved , i just added a break in while
so it breaks the while NOT the whole code
btw i was stuck at in in weeks
i have another problem its about graph should i make another thread ?