mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
fix: Clean up of code examples in CONTRIBUTING to follow guidelines. (#1063)
This commit is contained in:
parent
f4fe0c6f5b
commit
4ed75018e3
@ -59,7 +59,7 @@ We are very happy that you consider implementing algorithms and data structures
|
|||||||
|
|
||||||
#include
|
#include
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace <check from other files in this repo>
|
* @namespace <check from other files in this repo>
|
||||||
*/
|
*/
|
||||||
namespace name {
|
namespace name {
|
||||||
@ -67,42 +67,44 @@ namespace name {
|
|||||||
/**
|
/**
|
||||||
* Class documentation
|
* Class documentation
|
||||||
*/
|
*/
|
||||||
class cls_name{
|
class class_name {
|
||||||
private:
|
private:
|
||||||
int var1; ///< short info of this variable
|
int variable; ///< short info of this variable
|
||||||
char *msg; ///< short info
|
char *message; ///< short info
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// other members also documented as below
|
// other members also documented as below
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function documentation
|
* Function documentation
|
||||||
* @tparam T this is a one-line info about T
|
* @tparam T this is a one-line info about T
|
||||||
* @param param1 on-line info about param1
|
* @param param1 on-line info about param1
|
||||||
* @param param2 on-line info about param2
|
* @param param2 on-line info about param2
|
||||||
* @returns `true` if ...
|
* @returns `true` if ...
|
||||||
* @returns `false` if ...
|
* @returns `false` if ...
|
||||||
*/
|
*/
|
||||||
template<class T>
|
template<class T>
|
||||||
bool func(int param1, T param2) {
|
bool func(int param1, T param2) {
|
||||||
// function statements here
|
// function statements here
|
||||||
if(/*something bad*/)
|
if (/*something bad*/) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test function */
|
/** Test function */
|
||||||
void test() {
|
static void test() {
|
||||||
/* some statements */
|
/* desciptions of the following test */
|
||||||
assert(func(...) == ...); // this ensures that the algorithm works as expected
|
assert(func(...) == ...); // this ensures that the algorithm works as expected
|
||||||
|
|
||||||
// can have multiple checks
|
// can have multiple checks
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Main function */
|
/** Main function */
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
test(); // execute the tests
|
||||||
// code here
|
// code here
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -110,7 +112,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
#### New File Name guidelines
|
#### New File Name guidelines
|
||||||
- Use lowercase words with ``"_"`` as separator
|
- Use lowercase words with ``"_"`` as separator
|
||||||
- For instance
|
- For instance
|
||||||
```
|
```
|
||||||
MyNewCppClass.CPP is incorrect
|
MyNewCppClass.CPP is incorrect
|
||||||
my_new_cpp_class.cpp is correct format
|
my_new_cpp_class.cpp is correct format
|
||||||
@ -119,7 +121,7 @@ my_new_cpp_class.cpp is correct format
|
|||||||
- File name validation will run on docker to ensure the validity.
|
- File name validation will run on docker to ensure the validity.
|
||||||
- If an implementation of the algorithm already exists and your version is different from that implemented, please use incremental numeric digit as a suffix. For example, if `median_search.cpp` already exists in the `search` folder and you are contributing a new implementation, the filename should be `median_search2.cpp` and for a third implementation, `median_search3.cpp`.
|
- If an implementation of the algorithm already exists and your version is different from that implemented, please use incremental numeric digit as a suffix. For example, if `median_search.cpp` already exists in the `search` folder and you are contributing a new implementation, the filename should be `median_search2.cpp` and for a third implementation, `median_search3.cpp`.
|
||||||
|
|
||||||
#### New Directory guidelines
|
#### New Directory guidelines
|
||||||
- We recommend adding files to existing directories as much as possible.
|
- We recommend adding files to existing directories as much as possible.
|
||||||
- Use lowercase words with ``"_"`` as separator ( no spaces or ```"-"``` allowed )
|
- Use lowercase words with ``"_"`` as separator ( no spaces or ```"-"``` allowed )
|
||||||
- For instance
|
- For instance
|
||||||
|
Loading…
Reference in New Issue
Block a user