Jump to content

Vector type wrapper over arrays and MANY std library algorithm functions.


Recommended Posts

I was messing around with this awhile ago.  I'm not sure if something like this already exists, i looked around didn't see anything.  To anyone who doesn't know what a c++ vector object type is, the easiest way i can describe it is a template thats a wrapper over traditional arrays.  The reason why i began messing with this is bc anyone that uses c++ understands how valuable and useful vector objects are as opposed to standard arrays.  

This link has the names and descriptions of the functions included in this Library (the majority of them are in here) read this link it will change your programming life!!!!!!!!!!!!!!

https://en.cppreference.com/w/cpp/algorithm

HUGE Update.  v0.3        All i can say is that if you don't know what this is for or how to use it.... then you probably have no business owning a computer.

fixed many problems, added probably 50 more functions (No i have not updated the list).  I got rid of some garbage functions that were pointless.  These functions are now fully capable for the most part to work with arrays.  The sizing on some of them may be off here and there bc i just don't have the time to test everything.  To use regular arrays(and return regular arrays) just set $is_vector to false in the parameters.  I also made it so that you can put in reverse ranges on mainly every function and it will automatically handle them by traversing in reverse or simple flipping them.  Also added appropriate safety checks so you should never go out of bounds.  Also added features like if you accidentally send a regular variable to a function that needs a array or vector (if it makes sense to ) it will automatically create the array object and return it.  Obviously if the point of a function is to search or do some other calculations or manipulation on a range it makes no sense to return and empty object.  If it doesn't exist it will just return -1.  If you're  using pushback and forget to create a array object first it will just create it and return it with the data inside.

One bug i have noticed which is very frustrating..... this apparently was a bug i must just be an idiot.  Array Math i truly believe can be deadly.  I think that was the issue i'm slowly dying from array math poisoning. 

EDIT: IT WAS PROBABLY A MISTAKE TO EVEN THINK ABOUT A "VECTOR".  Just added a pointless extra level of complexity.

AS a note not every function in the below picture is currently available.  A large portion of them are even though they may not have the exact name.  I've changed some names so that they make more sense.  Not every function in this library is in this list.  Some i've created on my own.  Some bc one thing led to another.  Some bc i had no choice in order to complete other functions.  Some were made purely for convenience.  These are not dll calls i'm just rewriting them in autoit (or at least my best representation

How it works!!

;create a "vector" object and put stuff in it

$test = _Create_Vector()
for $x=1 to 15
    _Vector_PushBack($test,$x)
Next

;now it has 15 elements from start to finish have a value of 1-15 in order [1]=1 [2]=2 [3]=3 ....[15]=15


;now lets add 999 at element 3

_Vector_Insert($test,3,999)

;an element was added so now theres 16 total [1]=1 [2]=2 [3]=999 [4]=3 [5]=4 .......[16]=15

;add 123 to the front of the object

 _Vector_PushFront($test,123)
 
 ;now it looks like this  [1]=123 [2]=1 [3]=2 [4]=999 [5]=3 .......[17]=15 <~~~note that an object was added

_Vector_PopBack($test)  ;removes last object [1]=123 [2]=1 [3]=2 [4]=999 [5]=3 .......[16]=14 /end

;lets swap the first and last elements

 _Vector_Swap($test,_Vector_Begin($test),_Vector_End($test)) ;[1]=14 [2]=1 [3]=2 [4]=999 [5]=3 [6]=4 .......[16]=123

;lets reverse a range of elements

_Vector_Reverse($test,$is_Vector=True,_Vector_Begin($test)+2,_Vector_Begin($test)+5)

;now it looks like ;[1]=14 [2]=1 [3]=4 [4]=3 [5]=999 [6]=2

;lets find the value 4

local $it=_Vector_Find($test,4) ; $test[$it]=4

;lets create a new vector and fill every element with the number 99

$newV=_Create_Vector(5,99) ;[1]=99 [2]=99 [3]=99 [4]=3 [5]=99

;are they all 99?

$bool=_Vector_All_Of($newV,99) ;returns true

$count=_Vector_Count($newV,99) ;5

$size=_Vector_Size($newV) ; also 5....

;merge this vector with the 1st 5 elements of $test vector

$merged=_Vector_Merge($test,$newV,$is_Vector=True,1,4)

;$merged={ [1]=14 [2]=1 [3]=4 [4]=3 [5]=999 [6]=99 [7]=99 [8]=99 [9]=99 [10]=99 }

;is it unique? (no duplicates) if not then lets make it so

if Not _Vector_Is_Unique($merged) then _Vector_Unique($merged)

;$merged { [1]=14 [2]=1 [3]=4 [4]=3 [5]=999 [6]=99 } /end

;split it into 2 groups
 
$partition=_Vector_Partition($merged,_Vecter_Accumulate($merged)/2) ; result of accumulate was 1120ish... /2 560 ish... 

; $partition[_Vector_Begin($partition)] { [1]=14  [2]=1  [3]= 4  [4]= 3  [5]=99 }

;$partition[_Vector_End($partition)] { [1]=999 } 

_Vector_Permutation_Next($partition[1],True,2,4) ; { [1]=14  [2]=3  [3]= 1  [4]= 4  [5]=99 }

_Vector_Permutation_Next($partition[1],True,2,4) ; { [1]=14  [2]=3  [3]= 4  [4]= 1  [5]=99 } 

_Vector_Permutation_Next($partition[1],True,2,4) ; { [1]=14  [2]=4  [3]= 1  [4]= 3  [5]=99 } 

_Vector_Permutation_Next($partition[1],True,2,4) ; { [1]=14  [2]=4  [3]= 3  [4]= 1  [5]=99 }

_Vector_Permutation_Next($partition[1],True,2,4) ; { [1]=14  [2]=1  [3]= 3  [4]= 4  [5]=99 }

_Vector_Permutation_Next($partition[1],True,2,4) ; { [1]=14  [2]=1  [3]= 4  [4]= 3  [5]=99 }

_Vector_Permutation_Next($partition[1],True,2,4) ; { [1]=14  [2]=3  [3]= 1  [4]= 4  [5]=99 }  <~~~~~true algorithm efficiency NOT brute forced

Based on the Above you can just feel the raw POWER!!!! 

 

If you want to know more about the c++ std library check out this video.  It explains it all.

 

;_Vector_Swap( $vec, $it1, $it2,[ [ $Is_Vector ]  )

;_Vector_Popfront( $vec, [ $Is_Vector ] )

;_Vector_Pushfront( $vec, $data, [ $Is_Vector ] )

;_Vector_Front( $vec, [ $Is_Vector ] )

;_Vector_Size( $vec, [ $Is_Vector ] )

;_Vector_Insert( $vec, $it, $data, [ $Is_Vector ] )

;_Vector_Back( $vec )   

;_Vector_Popback( $vec, [ $Is_Vector ] )

;_Vector_Pushback( $vec, $data, [ $Is_Vecto ] )

;_Vector_rFind( $vec, $data, [ $Is_Vector, $rBegin, $rEnd ] )

;_Vector_Find( $vec, $data, [ $Is_Vector, $begin, $end ] )

;_Vector_rBegin( $vec )

;_Vector_Begin( $vec, [ $Is_Vector ] )

;_Vector_rEnd( $vec, [ $Is_Vector ] )

;_Vector_End( $vec )

;_Display_Vector( $vec )

;_Create_Vector( [ $elements, $data , $Is_Vector ] )

;_Vector_Erase( $vec, $element, [ $Is_Vector ] )

;_Vector_Sort( $vec, [  $ascending, $Is_Vector, $begin,$end ] )

;_Vector_Min( $vec, [ $Is_Vector, $begin ,$end ] )

;_Vector_Max( $vec, [ $Is_Vector, $begin, $end ] )

;_Vector_All_Of( $vec, $data, [ $Is_Vector, $begin , $end ] )

;_Vector_Any_Of( $vec, $data, [ $Is_Vector,$begin ,$end ] )

;_Vector_Is_Unique($vec, $it, [ $Is_Vector, $begin ,$end ] )

;_Vector_Is_Permutation( $vec1, $vec2, [ $Is_Vector ] )

;_Vector_Shuffle( $vec, [ $Is_Vector ] )

;_Vector_BItshift_Right( $vec, $moves , [ $Is_Vector ] )

;_Vector_Bitshift_Left( $vec, $moves , [ $Is_Vector ] )

;_Vector_Rotate( $vec, [  $moves ,$right , $Is_Vector ] )

;_Vector_Find_Next_It( $vec, $it, [ $begin, $end ] )

;_Vector_rFind_Next_It( $vec, $it, [ $rBegin, $rEnd ] )

;_Vector_Find_Next( $vec, $data )

;_Vector_rFind_Next( $vec, $data )

;_Vector_Reverse( $vec, [ $Is_Vector ,$begin , $end ] )

;_Vector_Permutation_Next( $vec,  [ $Is_Vector ] )

;_Vector_Permutation_Prev( $vec,  [ $Is_Vector ] )

;_Vector_String_To_Vec( $string, [ $Is_Vector ] )

;_Vector_Vec_To_String( $vec, [ $Is_Vector ] )

;_Vector_For_Each_Transform( $vec, $function, [ $Is_Vector ] )

;_Vector_Count( $vec , $data, [ $Is_Vector ] )

;_Vector_None_Of( $vec , $data, [ $Is_Vector ] )

;_Vector_For_Each( $vec, $Vfuction, [ $Is_Vector ] )

;_Vector_Is_Sorted( $vec, [ $ascending ,  $Is_Vector ] )

;_Vector_Is_Sorted_Until( $vec, [ $ascending , [ $Is_Vector ] )

;_Vector_Partial_Sort( $vec,  $begin, $end, [ $ascending , $Is_Vector ] )

;_Vector_Min_It( $vec, [ $Is_Vector, $begin ,$end ] )

;_Vector_Max_It( $vec, [ $Is_Vector, $begin ,$end ] )

;_Vector_Is_Adjacent_Unique( $vec, $data, [ $Is_Vector,$begin,$end ] )

;_Vector_Adjacent_Unique( $vec, [ $data, [ $Is_Vector, $begin ,$end ] )

;_Vector_Min_Max( $vec, [ $Is_Vector, $begin ,$end ] )

;_Vector_Min_Max_It( $vec, [ $Is_Vector, $begin , $end ] )

;_Vector_Heap( $vec, [ $Is_Vector, $begin ,$end ] )

;_Vector_All_Of_UPred( $vec, $pFunction, [ $Is_Vector, $begin ,$end ] )

;_Vector_Make_Heap_Pred( $vec, $pFunction, [ $Is_Vector, $begin ,$end ] )

;_Vector_Sort_Quick( $vec, [ $Is_Vector, $begin ,$end ] )

;_Vector_PopHeap( $vec, [ $Is_Vector, $begin  ,$end ] )

;_Vector_PushHeap( $vec, $data, [ $Is_Vector ] )

;_Vector_PushHeap_Pred( $vec, $data, $pFucntion, [ $Is_Vector ] )

;_Vector_SortHeap_Pred( $vec, $pFunction, [ $ascending , $Is_Vector, $begin, $end ] )

;_Vector_Copy_UPred( $vec, $pFunction, [ $Is_Vector, $begin , $end ] )

;_Vector_Sort_Nth_Element( $vec, $it, [ $ascending, $Is_Vector, $begin ,$end ] )

;_Vector_For_Each_Nth($vec, $Vfunction, [ $Is_Vector, $begin , $end ] )

;_Vector_Merge_Sort($vec1, $vec2, [  $Is_Vector, $begin1 , $end1 ,$begin2 , $end2 ] )

;_Vector_Merge( $vec1, $vec2, [ $Is_Vector, $begin1 , $end1 , $begin2 , $end2 ] )

;_Vector_Merge_Sort_Quick( $vec1, $vec2, [ $Is_Vector, $begin1 ,$end1 ,$begin2 , $end2 ] )

;_Vector_Merge_Sort_Pred( $vec1, $vec2, $pFunction, [ $Is_Vector, $begin1 , $end1 , $begin2 , $end2 ] )

;_Create_Vector_Random_Nums( [ $elements ,$min ,max ,$flag ,$Is_Vector ] )

;_Vector_Is_Merge( $collection, $vec1, $vec2, [ $Is_Vector, $begin1 ,$end1 ,$begin2 , $end2 ] )

;_Vector_Unique( $vec , $data , [ $Is_Vector, $begin , $end ] )

;_Vector_For_Each_Transform_Nth( $vec, $function, [ $Is_Vector, $begin ,$end ] )

;_Vector_Is_It_Inbounds( $vec , $it, [ $Is_Vector ] )

;_Vector_Any_Of_UPred( $vec, $pFunction, [ $Is_Vector, $begin, $end ] )

;_Vector_Find_All( $vec, $data, [ $Is_Vector , $begin , $Is_Vector),$end ] )

;_Vector_Find_All_UPred( $vec, $pFunction, [ $Is_Vector, $begin ,$end ] )  ;BOOL UPred(*it)

;_Vector_None_Of_UPred( $vec, $pFunction, [ $Is_Vector ,$begin ,$end ] )  

; _Create_Vector_Random_Letters( [ $elements ,$uppercase ,$upper_and_lower ,$Is_Vector ] )

;_Create_Vector_Random_Strings( [ $elements, $min_length, $max_lenghth, $only_letters, $uppercase, $upper_and_lower, $Is_Vector ] )

Every parameter encased in square brackets is OPTIONAL ..... I will add detailed descriptions to these functions as time allows.  The list is so big I almost need to hire someone....

I havent even had time to really sort the list in a way that makes sense its just in the order that i've been writing them.  

Last but not least don't let the overwhelmingly large amount of parameters in some functions scare you!! lol the mass majority of these functions are designed to loop through the whole array automatically, the majority of the extra parameters are to control ranges of the arrays that are being passed to the function.  
 

 

The only other thing that i can say is that this is a coding style within itself.  It definitely took me some time to get used to it but old habits die hard.  I will say that I'm way better for it.  

 

 

 

vector v0.35.au3

list.png

Edited by markyrocks
UPDATE v0.35
Link to post
Share on other sites

I added like 10-12 functions.  Mind you i'm mainly just going off of memory as far as useful functions that i've used in the past, so they're kinda out of order.  I'm planning on adding in Find_Next, rFind_Next, more bitshift operations, a next permutation function and a function that determines if a vector is equal to elements contained in another vector.  If anyone has any useful ideas let em rip.

Edited by markyrocks
Link to post
Share on other sites

So check it, I added another 8-10 functions.  Going slower as the complexity rises.

I added in a _Vector_For_Each_Transform() function and i figured i would add an example as to how something like this works for those unfamiliar.  

so the idea is if you have a specific procedure that you want to perform on every element of an array type object.  Sure you could just create a for loop and do whatever you wanted to do.  But using the above mentioned function is slightly more convenient and makes things a lil easier to read and understand what is happening later provided the function name makes sense.  

So for this example i'll just create an empty vector and set the elements to 1,2,3,4

$test = _Create_Vector()

for $x=1 to 4
    _Vector_PushBack($test,$x)
Next

then i want to add every element to itself and replace the element with that value... so i call for each using my helper function y_plus_y()

_Vector_For_Each_Transform($test,y_plus_y)

func y_plus_y($y)
    return $y+$y
EndFunc

so originally $test elements would have been 1,2,3,4

after the Transform call $test would be 2,4,6,8.

 From this small example you can start to see the benefits of working within a system like this.  I basically created and empty array bc its dynamic i can easily add or subtract elements. I easily add 4 elements as needed and set their values then i looped though and changed every element without breaking a sweat or even having to think about the size of the object at all... 

edit: I made an executive decision and changed the name officially to _Vector_For_Each_Transform() 

Edited by markyrocks
bc im an idiot
Link to post
Share on other sites

This is the last time I'm going to bump this post.  I realize that the whole idea of a vector was kinda pointless and added an unnecessary extra level of complexity...hence $is_vector.....

Anyways I think I was more interested in the style than the data type.  So i may weed that out of there altogether, when i run out of other stuff to do.  So anyways the point of the bump.  

The point is that I added like 30 or 40 more functions, deleted some pointless ones and fixed the ones that were just not working as the original developers intended.

As far as i can tell they're all mainly functional.  I'm sure there's a few bugs in there that i missed.  I tried to briefly test each function but some that are essentially clones of other functions with small differences i may have over looked.  I'm getting pretty good at writing algorithms otherwise i wouldn't have tried something like this.

Just to be clear i'm not just looking at the c++ source and rewriting it.  For some functions that i wasn't sure of what the point was or how a specific thing was accomplished i did look at a couple of them to just get a clue.  But for the most part i've been reading the function descriptions (if i don't know already what something does) and then just coding it in the what i believe to be an efficient manner.

Link to post
Share on other sites

I just do not know .... what to say... 🤥

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * for other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2021-10-18

Link to post
Share on other sites
22 hours ago, markyrocks said:

This is the last time I'm going to bump this post.  I realize that the whole idea of a vector was kinda pointless and added an unnecessary extra level of complexity..

I'm sure it felt like a good idea at the the time you started it . It may come in handy for someone if fully functional.

And you are not bumping, you just sharing, and if anyone finds a bug and share the finding it'll better the UDF.

So, thanks for sharing :)

Link to post
Share on other sites
On 11/11/2020 at 1:53 AM, argumentum said:

I'm sure it felt like a good idea at the the time you started it . It may come in handy for someone if fully functional.

And you are not bumping, you just sharing, and if anyone finds a bug and share the finding it'll better the UDF.

So, thanks for sharing :)

I'm getting there just posted a HUGE UPDATE.  Details on that at the top.  Part of the issue is that some of these functions or groups of functions i was just flat out unfamiliar with and really wasn't sure about the intention so i just kinda hacked something together that I thought was legit but i'm really digging in and running those unknown sections down.

Last night i was working on the "heap" functions.  I really had no clue what it was about 24 hrs ago.  Now that i've figured it out I definitely understand the rational behind it and that a "heap" is probably the most efficient sort method imaginable.  I was fighting to optimize my sort function b4 i figured out what a heap does and the ridiculous level of efficiency.  Like OMG i recommend anyone who doesn't know to check it out.  The heap_sort function i made sorted 10000 random numbers in an array basically as fast as the built in _array_sort().  On this 5 year old laptop it took like 5 seconds.  I spent the last few hrs tearing my hair out trying to make a "heap_display" function so that i had a sample to show off that its actually working as intended.  I actually think I might be able to optimize that sort further using bitand/bitor trick that i saw awhile back.  Apparently this trick allows you to take 2 bit values and swap them without using a 3rd variable.  Its not even that complicated, i just don't remember it off the top of my head.  So anyways check it out.  This is a picture of the sorted sample heap.  The numbers that repeat at the tops of the triangles are the "nodes" I left it that way to have a representation of what connects to what.  Im just pumped.  You have no idea the struggle i had to make the function just to display the thing.

I think that i just had an epiphany.  

now that i really just started thinking about what a vector is... I know this sounds so dumb that after all this effort that I just started putting my finger on the

POINT of it.  

Ya I just Had some serious revelations as to what exactly it means to be a vector and what that means in terms of memory operations why they exist and why they're faster...

Think about it in terms of a loop that adds thousands of elements to an array.  So everytime you add something the array gets redim and its only given a certain amount of buffer by the os so more than likely every couple calls to redim (or even every call bc redim may just initialize another variable and do a copy  operation from the first to the 2nd) as the allotted block fills the os has to keep finding different places for it and copying and moving it all around the planet behind the scenes. So that all being said a vector gets initialized with say 10 extra elements plus whatever buffer allocated by the os.  So if i decide to keep adding the same previous thousands of elements I can already add 10 b4 i even start rolling into any buffer listen to what i just said .  That means that memory operations will happen 10x less.... will that result in a 10x speedup?  who knows but maybe if you keep listening it might result in an even faster speedup.  The other difference is theres a special variable (Special variable....more like private class member variables....) that keeps track of the begin and the end and other data in c++'s case probably actully stores a **p smart pointer to the actual element especially if each element is big its quicker to jump over to traverse an array of pointers that are significantly smaller than potentially much bigger elements.  This all seems entirely possible in autoit.  So again with the speedup with limiting memory movements..... 

let this blow your mind say i have a 10 element array that i keep adding or subtracting elements here and that bc the data is irrelevant and the sizeing messes up coordination with other arrays in loops i'm dealing with etc.    So memory operations in that regard would almost be eliminated entirely.  I can say that with absolute certainty bc if i need to "delete" something it just just tossed into the waste basket behind the "end" and (remember the extra the allocated elements)  the "end" decrements, then as the new data gets added to the back (or possibly front with a front buffer of extra elements) the data in the trash heap just gets overwritten and its completely pointless to "destroy" the element... with that bein said thats why when you call vector.erase(it) on a element the iterator  becomes a hand grenade.  It almost has to be that way bc actually being able to dereference that iterator would be undefined behavior bc theres no guarantee that it would contain the intended data and ++it just points to a different item in the trash pile aswell.... The return of vector.erase() is the next iterator after the deleted element b4 its moved.  the other interesting thing here to consider when dealing with an array of **p to keep track of elements in a data type is that they don't even have to be sequential you can have 10 over here 20 over there 50 in a different location it doesn't matter if you're traversing a list of pointers all the blocks combined can be on the surface be one object and the person thats using the data type wouldn't know and definitely wouldn't care as long as it works.  Actually this all kinda leads me down the line of thinking that moving elements around in a vector isn't even the data itself moving its just the **p's being shuffled around and it doesn't really even matter what order the actual data is in as long as the pointers are in the correct order and that's what you're traversing anyways.  I'd be will to bet my last dollar that in the vector library theres a overloaded

[N] operator that just basically makes it so when a number is passed in square brackets the return of that is just  (vec.begin()+N).  something like that.

 Dammit am I having some good ideas.  Heres another one even an array of **P don't need to be in one block the last block in the chain could just be a 

***p to the next **p in the chain.  Dammit my mind is blown.  I'm so tired i'm almost hallucinating about this shit.  It also just occurred to me that determining the begin and ends of an "object"  is probably a bitset count  ......0001011011010100000000 bit array representation of the memory with buffer on both sides.  element positions correspond to the true elements  would be held in another vector of iterator class objects that point to the actual data wherever the hell it may be.  With classes all the moving parts can updated themselves relatively seamlessly.  I'm not a big fan of classes, i'm more of a struct guy but.... theyre basically the same thing. very minor difference...looking at that bit string leaving gaps actually makes it easier to add data in later bc you may only have to shift a few elements around vs having to shift an entire array...... ideas... they are a flowing.

actually it doesn't even matter what the initial order of the data is as long as the element where it lives is recorded and saved in another array and kept in an order in their based on its position in the upper levels..in a sense recording and ordering an element based on a number in an array farther down the line is essentially a pointer to that element....there it was i broke the language ... its on now

 

                                                        

12.png

Edited by markyrocks
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...