[go-nuts] Re: Extending an array 'The right way'. Guidence needed!

2019-10-17 Thread Stuart Davies
Luis Thanks for you comments. I agree the limit for 'i' should be defined by the length of the smaller array. However in the loop, 'i' is always less than p.LineCount and p.LineCount would never be more than the array size. I could have used if p.LineCount = len(p.Offsets) But >= felt more co

[go-nuts] Re: Extending an array 'The right way'. Guidence needed!

2019-10-16 Thread Luis Furquim
Em terça-feira, 15 de outubro de 2019 07:16:35 UTC-3, Stuart Davies escreveu: > > > if p.LineCount >= len(p.Offsets) { > newLen := p.LineCount + 50 > sb := make([]int64, newLen) > for i := 0; i < p.LineCount; i++ { > sb[i] = p.Offsets[i] > } > p.Offsets = sb > } > > N

[go-nuts] Re: Extending an array 'The right way'. Guidence needed!

2019-10-15 Thread Stuart Davies
Thanks. The copy command was the thing I missed. It does exactly what I need and I can control the extension of the backing array with fine detail. I assume the copy command is implemented efficiently but even if it just loops it is a packaged process and will have been optomised by the Go devs

Re: [go-nuts] Re: Extending an array 'The right way'. Guidence needed!

2019-10-15 Thread Marvin Renich
* thatipelli santhosh [191015 08:07]: > Hi Marvin, > > I am curious to know if we approx 10 ( we don't know exact amount of > slice entries) add to slice. Slice will grow based on our size of data > and underlying array size but doing this create multiple underlying arrays > (more memory re

[go-nuts] Re: Extending an array 'The right way'. Guidence needed!

2019-10-15 Thread Stuart Davies
Ok I will have a rethink. Is there a way I can control the expansion. I do not want to double the storage each time. I want to be able to control and limit the growth if necessary. Thanks for the assistance. I will re-read the article. On Tuesday, 15 October 2019 11:16:35 UTC+1, Stuart Davies

Re: [go-nuts] Re: Extending an array 'The right way'. Guidence needed!

2019-10-15 Thread thatipelli santhosh
Hi Marvin, I am curious to know if we approx 10 ( we don't know exact amount of slice entries) add to slice. Slice will grow based on our size of data and underlying array size but doing this create multiple underlying arrays (more memory resource utilization, processing). In such case, wha

Re: [go-nuts] Re: Extending an array 'The right way'. Guidence needed!

2019-10-15 Thread Marvin Renich
P.S. If you are still having trouble after reading the responses to your query, use the go playground (https://play.golang.org/) to create a simple program that demonstrates what you are trying, and post the link you get from clicking the "Share" button, and explain what you would like the output t

Re: [go-nuts] Re: Extending an array 'The right way'. Guidence needed!

2019-10-15 Thread Marvin Renich
[When you are replying to someone else's message, reply to that message, not your original message. Your reply lost the context of the message to which you were replying (Jan Mercl's).] * Stuart Davies [191015 07:24]: > My goal is to contain a list of integers that may extend to possibly a > co

[go-nuts] Re: Extending an array 'The right way'. Guidence needed!

2019-10-15 Thread Stuart Davies
My goal is to contain a list of integers that may extend to possibly a couple of thousand entries. Initial size is 100. Extensions add 50 entries at a time. I declared the array initially with: make([]int64, 100). I tried using the Append function but could not Append past the 100 entries. Th