// SPDX-License-Identifier: Apache-2.0
// Copyright 2025 Bubble Sort Implementation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef BUBBLE_SORT_H
#define BUBBLE_SORT_H

#include <vector>
#include <iostream>

/**
 * BubbleSort class provides implementation of the bubble sort algorithm
 * with various sorting options and utilities.
 */
class BubbleSort {
public:
    // Lifecycle
    BubbleSort();
    ~BubbleSort();

    // Operations
    void SortArray(std::vector<int>& rArray);
    void SortArrayDescending(std::vector<int>& rArray);
    void SortArrayOptimized(std::vector<int>& rArray);
    
    // Accessors
    int GetComparisonCount() const;
    int GetSwapCount() const;
    bool IsSorted(const std::vector<int>& rArray) const;
    
    // Utilities
    void PrintArray(const std::vector<int>& rArray) const;
    void ResetCounters();

private:
    // Attributes
    int mComparisonCount;
    int mSwapCount;
    
    // Helper methods
    void SwapElements(int& rFirst, int& rSecond);
    bool IsAscendingSorted(const std::vector<int>& rArray) const;
    bool IsDescendingSorted(const std::vector<int>& rArray) const;
};

#endif // BUBBLE_SORT_H