|
| 1 | +This is an automatic translation, may be incorrect in some places. See sources and examples! |
| 2 | + |
| 3 | +# Stack |
| 4 | +Library for convenient work with arrays of any type of data type STD :: vector or arrays in js |
| 5 | +- Static and dynamic implementation (with reallock) |
| 6 | +- Adding and receiving from both ends, insert and removal |
| 7 | + |
| 8 | +## compatibility |
| 9 | +Compatible with all arduino platforms (used arduino functions) |
| 10 | + |
| 11 | +## Content |
| 12 | +- [initialization] (#init) |
| 13 | +- [use] (#usage) |
| 14 | +- [Example] (# Example) |
| 15 | +- [versions] (#varsions) |
| 16 | +- [installation] (# Install) |
| 17 | +- [bugs and feedback] (#fedback) |
| 18 | + |
| 19 | +<a id="init"> </a> |
| 20 | + |
| 21 | +## initialization |
| 22 | +`` `CPP |
| 23 | +// External buffer |
| 24 | +Stackext <typeename t> (); |
| 25 | +Stackext <typeename t> (t* arr, size_t capacity, size_t length = 0); |
| 26 | + |
| 27 | +// Dynamic buffer |
| 28 | +Stack <Typename T> (SIZE_T SIZE = 0); |
| 29 | + |
| 30 | +// Static buffer |
| 31 | +Stackt <Typename T, Size_t Size> (); |
| 32 | +`` ` |
| 33 | + |
| 34 | +<a id="usage"> </a> |
| 35 | + |
| 36 | +## Usage |
| 37 | +`` `CPP |
| 38 | +// connect the buffer (only for stackext) |
| 39 | +VOID SetBuffer (T* Arr, Size_t Capacy, Size_t Length = 0); |
| 40 | + |
| 41 | +// reserve memory in the number of elements (only for Stack) |
| 42 | +Bool Reserve (Size_T SIZE); |
| 43 | + |
| 44 | +// Add to the end |
| 45 | +Bool Push (const t & val); |
| 46 | +Bool Operator+= (Consta T & Val); |
| 47 | + |
| 48 | +// get from the end and delete |
| 49 | +T Pop (); |
| 50 | + |
| 51 | +// read from the end without deleting |
| 52 | +T peek (); |
| 53 | + |
| 54 | +// Add to the beginning |
| 55 | +Bool Shift (const t & val); |
| 56 | + |
| 57 | +// get from the beginning and delete |
| 58 | +T Unshift (); |
| 59 | + |
| 60 | +// read from the beginning without deleting |
| 61 | +T unpeek (); |
| 62 | + |
| 63 | +// Delete the element.Negative - from the end |
| 64 | +Bool Remove (int IDX); |
| 65 | + |
| 66 | +// insert the element to the index (the Length () index is allowed) |
| 67 | +Bool Insert (Intx, Const T&D); |
| 68 | + |
| 69 | +// add another array to the end |
| 70 | +Bool Concat (Constation Stackext <t> & st); |
| 71 | +Bool Operator+= (Const Stackext <t> & ST); |
| 72 | + |
| 73 | +// Fill in the value (on capacity) |
| 74 | +VOID Fill (const t & val); |
| 75 | + |
| 76 | +// initialize, call designers (on capacity) |
| 77 | +VOID Init (); |
| 78 | + |
| 79 | +// Clean (set length 0) |
| 80 | +Void Clear (); |
| 81 | + |
| 82 | +// there is a place to add |
| 83 | +Bool Canadd (); |
| 84 | + |
| 85 | +// amount of elements |
| 86 | +Size_t Length (); |
| 87 | + |
| 88 | +// capacity, elements |
| 89 | +Size_t Capacy (); |
| 90 | + |
| 91 | +// Get an element under the index.Negative - from the end |
| 92 | +T&Get (int IDX); |
| 93 | + |
| 94 | +// Get an element under the index.Negative - from the end |
| 95 | +T & operator [] (int IDX); |
| 96 | + |
| 97 | +// Mastery pointer |
| 98 | +const t* ptr (); |
| 99 | +`` ` |
| 100 | + |
| 101 | +<a id="EXAMPLE"> </a> |
| 102 | + |
| 103 | +## Example |
| 104 | +The rest of the examples look at ** Examples **! |
| 105 | +`` `CPP |
| 106 | +Stack <Char> ST1; |
| 107 | +ST1.push ('A'); |
| 108 | +ST1.push ('B'); |
| 109 | +ST1.push ('c'); |
| 110 | +While (st1.length ()) serial.print (st1.pop ());// CBA |
| 111 | +Serial.println (); |
| 112 | + |
| 113 | +Stackt <char, 10> ST2; |
| 114 | +ST2.shift ('1'); |
| 115 | +ST2.shift ('2'); |
| 116 | +ST2.shift ('3'); |
| 117 | +ST2.shift ('4'); |
| 118 | +ST2.shift ('5'); |
| 119 | +for (int i = 0; i <st2.length (); i ++) serial.print (ST2 [i]);// 54321 |
| 120 | +Serial.println (); |
| 121 | + |
| 122 | +Char Buf [5]; |
| 123 | +Stackext <khar> st3 (BUF, 5); |
| 124 | +ST3.PUSH ('A'); |
| 125 | +ST3.PUSH ('B'); |
| 126 | +ST3.push ('c'); |
| 127 | +ST3.PUSH ('D'); |
| 128 | +ST3.push ('E'); |
| 129 | + |
| 130 | +ST2 += ST3; |
| 131 | +for (int i = 0; i <st2.length (); i ++) serial.print (ST2 [i]);// 54321abcde |
| 132 | +Serial.println (); |
| 133 | + |
| 134 | +Stack <float> ST4 (3); |
| 135 | +ST4.Fill (3.14); |
| 136 | +ST4 [0] = 1234.56; |
| 137 | +for (int i = 0; i <st4.length (); i ++) serial.println (ST4 [i]);// 1234.56/3.14/3.14 |
| 138 | +`` ` |
| 139 | + |
| 140 | +<a id="versions"> </a> |
| 141 | + |
| 142 | +## versions |
| 143 | +- V1.0 |
| 144 | + |
| 145 | +<a id="install"> </a> |
| 146 | + |
| 147 | +## Installation |
| 148 | +- The library can be found by the name ** stack ** and installed through the library manager in: |
| 149 | + - Arduino ide |
| 150 | + - aRduino ide v2 |
| 151 | + - Platformio |
| 152 | +- [download library] (https://github.com/gyverlibs/stack/archive/refs/heads/main.zip). Zip archive for manual installation: |
| 153 | + - unpack and put in * C: \ Program Files (X86) \ Arduino \ Libraries * (Windows X64) |
| 154 | + - unpack and put in * C: \ Program Files \ Arduino \ Libraries * (Windows X32) |
| 155 | + - unpack and put in *documents/arduino/libraries/ * |
| 156 | + - (Arduino id) Automatic installation from. Zip: * sketch/connect the library/add .Zip library ... * and specify downloaded archive |
| 157 | +- Read more detailed instructions for installing libraries [here] (https://alexgyver.ru/arduino-first/#%D0%A3%D1%81%D1%82%D0%B0%BD%D0%BE%BE%BE%BED0%B2%D0%BA%D0%B0_%D0%B1%D0%B8%D0%B1%D0%BB%D0%B8%D0%BE%D1%82%D0%B5%D0%BA) |
| 158 | + |
| 159 | +### Update |
| 160 | +- I recommend always updating the library: errors and bugs are corrected in the new versions, as well as optimization and new features are added |
| 161 | +- through the IDE library manager: find the library how to install and click "update" |
| 162 | +- Manually: ** remove the folder with the old version **, and then put a new one in its place.“Replacement” cannot be done: sometimes in new versions, files that remain when replacing are deleted and can lead to errors! |
| 163 | + |
| 164 | +<a id="feedback"> </a> |
| 165 | +## bugs and feedback |
| 166 | +Create ** Issue ** when you find the bugs, but better immediately write to the mail [alex@alexgyver.ru] (mailto: alex@alexgyver.ru) |
| 167 | +The library is open for refinement and your ** pull Request ** 'ow! |
| 168 | + |
| 169 | +When reporting about bugs or incorrect work of the library, it is necessary to indicate: |
| 170 | +- The version of the library |
| 171 | +- What is MK used |
| 172 | +- SDK version (for ESP) |
| 173 | +- version of Arduino ide |
| 174 | +- whether the built -in examples work correctly, in which the functions and designs are used, leading to a bug in your code |
| 175 | +- what code has been loaded, what work was expected from it and how it works in reality |
| 176 | +- Ideally, attach the minimum code in which the bug is observed.Not a canvas of thousands of lines, but the minimum code |
0 commit comments