Search code examples
c++arraysdeque

Changing from arrays TO struct containing arrays


I am changing my code so it would fit me better .

I had:

deque<array<array<int,4>,4>> visited;

Now I have :

deque<New_Array> visited;

where New_Array is:

struct New_Array {
    array<array<int,4>,4> pinak;
    int h;
}Jim;

my array is like this:

array<array<int,4>,4> myarray;

The problem is that I have a else-if function like this:

else if (find(visited.begin(), visited.end(), myarray)==visited.end())

This function checks if an array is in the visited stack-deque. If it is not then the else-function works. But now, the visited deque will have to contain structs ,not arrays . How can I transform this function to work with the new containers of the deque?

I made this change so each array could be connected with a number(h). I need to check the array , I dont care about the number.

EDIT:

error C2678: binary '==' : no operator found which takes a left-hand operand of type 'New_Array' (or there is no acceptable conversion)


Solution

  • If I read your question correctly, what you need to do is define an equality operator for your struct. Then the Find can use that operator in its search.