Template array

  !   Данная информация ΠΏΡ€Π΅Π΄Π½Π°Π·Π½Π°Ρ‡Π΅Π½Π° Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ для IT-спСциалистов ΠΏΠΎ систСмной ΠΈΠ½Ρ‚Π΅Π³Ρ€Π°Ρ†ΠΈΠΈ ΠΌΠΎΠ΄ΡƒΠ»Π΅ΠΉ Π‘Π˜ΠžΠ‘ΠžΠ€Π’-М. (см. Руководства ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Ρ ΠΊ ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½Ρ‹ΠΌ ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚Π°ΠΌ)
Size
   int GetCount() const;
   void SetCount(
           int nNewCount,
           int nGrowBy = -1);
   // with alloc success check (alternatively you may just compare to GetCount())
   bool SetCountIsOk(
           int nNewCount,
           int nGrowBy = -1);
   // bypassing sane limits, will try to alloc any size but malloc may still fail
   bool SetCountBeyondUniversalLimit(
           int nNewCount,
           int nGrowBy = -1);
   // Check if memory allocated
   int GetConsumedMemoryInBytes();
Access
   TYPE GetAt(int iAt) const;
   TYPE GetLast(int nCountMinus = -1) const;
   void SetAt(int iAt, const TYPE& value);
   // Safe access outside of array
   TYPE GetAtOr(int iAt, const TYPE& def) const;
   TYPE GetLastOr(int nCountMinus, const TYPE& def) const;
   // for non ref/ptr projects (Cx, console)
   nullable<TYPE> GetAtOrNull(int iAt) const;
   nullable<TYPE> GetLastOrNull(int nCountMinus = -1) const;
   // read only!
   const TYPE operator [] (int iAt) const;
   // removed to simplify error handling, use SetAt() to change elements instead
   //TYPE& operator [] (int iAt);
Add
   TYPE& Add(const TYPE& value);
   // array fill shortcut mainly to simpify tests
   array<TYPE>& operator << (const TYPE& value);
   void InsertAt(int iAt, const TYPE& value);
   void InsertAt(int iAt, const TYPE& value, int nCount);
   void InsertAt(int nStartIndex, const array& oNewArray);
Remove
   void RemoveAt(int iAt, int nCount = 1);
   void RemoveAll();
   // Filter out items using flexible template
   template<class FILTER>
   void RemoveMatchingTemplate(
           FILTER oFilter);
Duplicate
   void Append(const array& src);
   void AppendBeyondUniversalLimit(const array& src);
   void Copy(const array& src);
Iterate
   bool Iterate(
           out iter& out_i,
           out TYPE& out_value)
           const;
   bool IterateBackwards(
           out iter& out_i,
           out TYPE& out_value)
           const;
   bool IterateKeys(
           out iter& out_i,
           out int& out_key,
           out TYPE& out_value)
           const;
   bool IterateKeysBackwards(
           out iter& out_i,
           out int& out_key,
           out TYPE& out_value)
           const;
Advanced
   // Common sense functions
   void Fill(const TYPE& val);
   void Fill(const TYPE& val, int nStartIndex, int len);
   int Find(const TYPE& val, int nStartIndex = 0) const;
   int FindCount(const TYPE& val) const;
   TYPE FindMin();
   TYPE FindMax();
   // This INCLUDES the last index (which is illogical behaviour)
   TYPE FindMinInRange(
           int iStart,
           int iEnd);
   TYPE FindMaxInRange(
           int iStart,
           int iEnd);
   void ReverseOrder();
   // This INCLUDES the last index (which is illogical behaviour)
   void ReverseOrderInRange(
           int iStart,
           int iEnd);
   void SortAscending();
   void SortDescending();
   template<class SORTER>
   void Sort(
           SORTER& sorter);
   // Generic templateless sorter
   void SortRefs(
           ref<CSorter> rSorter);
   void SortPtrs(
           ref<CSorter> rSorter);
   // do not call direcly!
   void _internal_unsafe_SortWithLowLevelCompareFunction(
           ref<CSorter> rSorter,
           PFN_QsortCallback pfnQsortCallback);
   // Universal square filter
   void RunSquareFilter(
           out array<TYPE>& out_atypeResult,
           int nWindowLength) const;
   void RunSquareFilterOnRange(
           out array<TYPE>& out_atypeResult,
           int nWindowLength,
           int iFirstElement,
           int iLastElement) const;
   // Simple sum value
   TYPE CalcSumFromTo(
           int iFirstElement, // (including iFirst/iLast, saturated if out of bounds)
           int iLastElement,
           TYPE typePadding = TYPE()) // useful for concatenating str
           const;

Π”ΠΎΠ±Π°Π²Π»Π΅Π½ ΠΏΠ°Π΄Π΄ΠΈΠ½Π³ для Π°Π΄Π°ΠΏΡ‚Π°Ρ†ΠΈΠΈ ΠΊ слиянию ΡΡ‚Ρ€ΠΎΠΊ ΡΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ΠΌ. НС Ρ‚ΠΎΠ»ΡŒΠΊΠΎ чисСл. ПолСзно для Π΄Π°ΠΌΠΏΠΎΠ² массивов Π² тСстах

            str sDump = asTest.CalcSumFromTo(0, oo, ", ");
            TESTLOG("", sDump + "\n");
   // Simple average value
   TYPE CalcAverageFromTo(
           int iFirstElement, // (including iFirst/iLast, saturated if out of bounds)
           int iLastElement) const;
   // Fill output array with consecutive value differences
   void CalcDeltas(
           int iFirstElement, // (including iFirst/iLast, saturated if out of bounds)
           int iLastElement,
           out array<TYPE>& out_aResult) const; // result.size := (this->size - 1)
Export/Import
   // Clear and refill from a buffer
   //   May fail if alignment is wrong or on memory alloc.
   // (FOR SIMPLE int/struct TYPES ONLY!)
   bool ImportArrayFromSbuf(
           sbuf sbufSource);
   // Change a number of existing items from a buffer
   //   May fail if index alignment is wrong or on memory alloc.
   //   Will try to grow array.
   // (FOR SIMPLE int/struct TYPES ONLY!)
   bool OverlayArrayFromSbuf(
           int iStartAt,
           sbuf sbufSource);
   // Change a number of existing items from the specified buffer segment
   //   May fail if index alignment is wrong or on memory alloc.
   //   Will try to grow array.
   // (FOR SIMPLE int/struct TYPES ONLY!)
   bool OverlayArrayFromSbufPartial(
           int iArrayStartAt,
           int iItemCount,
           sbuf sbufSource,
           int iInitialBufferOffset);
   // Copy full array into cleared buffer
   //   Can fail on memory alloc.
   // (FOR SIMPLE int/struct TYPES ONLY!)
   bool ExportArrayToSbuf(
           out sbuf& out_sbufTarget);
   // Fill/append a buffer from array items
   //   It can work as append to exising string or create a new one
   //   Can fail on memory alloc.
   //   Will try to grow sbuf.
   // (FOR SIMPLE int/struct TYPES ONLY!)
   bool ExportArrayToSbufPartial(
           int iStartAt,
           int nItemCount,
           out sbuf& out_sbufTarget,
           int iInitialTargetOffset);
Low level
   // Direct Access to the element data (may return NULL)
   const TYPE* _unsafe_GetPointer() const;
   TYPE* _unsafe_GetPointer();
   int _unsafe_GetSizeInBytes();
   // More safe than _unsafe_GetPointer() direct handling
   //   (it does not do SetCount() because you may
   //    want to preset SetCountBeyondUniversalLimit())
   void _unsafe_ImportRawBuffer(
           const TYPE* pSource,
           int nSourceCount);
   // No index verification in release
   TYPE _unsafe_GetAt(int iAt) const;
   void _unsafe_SetAt(int iAt, const TYPE& value);
   TYPE& _unsafe_ElementAt(int iAt);
   // Free removed element memory
   void FreeExtra();

Π­Ρ‚Π° катСгория Π² Π΄Π°Π½Π½Ρ‹ΠΉ ΠΌΠΎΠΌΠ΅Π½Ρ‚ пуста.



Новости