-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the DynamicArray class to replace the original DynArray class. …
…undone.
- Loading branch information
Showing
5 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2024 AQ authors, All Rights Reserved. | ||
# This program is licensed under the AQ License. You can find the AQ license in | ||
# the root directory. | ||
|
||
cmake_minimum_required(VERSION 3.10) | ||
|
||
include_directories(${PROJECT_SOURCE_DIR}) | ||
|
||
set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_array.cc) | ||
|
||
add_library(AqCompilerDynamicArray STATIC ${SOURCES}) | ||
|
||
target_link_libraries(AqCompilerDynamicArray PRIVATE AqDebugger) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright 2024 AQ authors, All Rights Reserved. | ||
// This program is licensed under the AQ License. You can find the AQ license in | ||
// the root directory. | ||
|
||
#include "compiler/dynamic_array/dynamic_array.h" | ||
|
||
// Wait development. | ||
namespace Aq {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2024 AQ authors, All Rights Reserved. | ||
// This program is licensed under the AQ License. You can find the AQ license in | ||
// the root directory. | ||
|
||
#ifndef AQ_COMPILER_DYNAMIC_ARRAY_DYNAMIC_ARRAY_H_ | ||
#define AQ_COMPILER_DYNAMIC_ARRAY_DYNAMIC_ARRAY_H_ | ||
|
||
#include "compiler/compiler.h" | ||
|
||
// Wait development. | ||
namespace Aq { | ||
template <typename ArrayType> | ||
class Compiler::DynamicArray { | ||
public: | ||
DynamicArray(); | ||
~DynamicArray(); | ||
|
||
DynamicArray(const DynamicArray&); | ||
DynamicArray(DynamicArray&&) noexcept; | ||
DynamicArray& operator=(const DynamicArray&); | ||
DynamicArray& operator=(DynamicArray&&) noexcept; | ||
|
||
ArrayType& operator[](std::size_t index); | ||
const ArrayType& operator[](std::size_t index) const; | ||
|
||
ArrayType& at(std::size_t index); | ||
const ArrayType& at(std::size_t index) const; | ||
|
||
void push_back(const ArrayType& value); | ||
void push_back(ArrayType&& value); | ||
void insert(std::size_t index, const ArrayType& value); | ||
void insert(std::size_t index, ArrayType&& value); | ||
|
||
void pop_back(); | ||
void erase(std::size_t index); | ||
void clear(); | ||
|
||
std::size_t size() const; | ||
std::size_t capacity() const; | ||
|
||
void resize(std::size_t new_size); | ||
void reserve(std::size_t new_capacity); | ||
|
||
private: | ||
ArrayType* array_; | ||
std::size_t capacity_; | ||
std::size_t size_; | ||
}; | ||
} | ||
|
||
#endif |