What is the fastest method to check if all elements of an array(preferable integer array) are equal. Till now I have been using the following code:

bool check(int array[], int n)
{   
    bool flag = 0;

    for(int i = 0; i < n - 1; i++)      
    {         
        if(array[i] != array[i + 1])
            flag = 1;
    }

    return flag;
}
Edit
Report