These are chat archives for Ruhrpottpatriot/GW2.NET

10th
Oct 2015
Steven Liekens
@StevenLiekens
Oct 10 2015 16:31
@Ruhrpottpatriot are you good with algorithms?
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:31
Yup
Steven Liekens
@StevenLiekens
Oct 10 2015 16:31
the computersciency ones
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:31
ohj
those
Steven Liekens
@StevenLiekens
Oct 10 2015 16:31
wow that was fast
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:31
^^
ok
those algos
Somewhat
Steven Liekens
@StevenLiekens
Oct 10 2015 16:31
don't worry I'm not gonna ask you to write a quicksort
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:31
QS is easy^^
especially in Haskell
so what's it about
Steven Liekens
@StevenLiekens
Oct 10 2015 16:32
just gonna ask if you've ever written a circular buffer
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:32
nope
why?
Steven Liekens
@StevenLiekens
Oct 10 2015 16:32
I need one
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:32
in C#?
Steven Liekens
@StevenLiekens
Oct 10 2015 16:32
yeah
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:33
tried something like a LinkedList for that?
I mean that's totally basic
but it should work
Steven Liekens
@StevenLiekens
Oct 10 2015 16:33
the buffer is fixed size
linkedlist sounds overkill
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:34
yeah
hm
Steven Liekens
@StevenLiekens
Oct 10 2015 16:34
I basically need a byte[] array and a way to remember how full the buffer is and where it begins or ends
it doesn't need to shrink or grow, ever
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:34
hmm
Steven Liekens
@StevenLiekens
Oct 10 2015 16:35
the part that I'm stuck on is keeping track of where the head and tail are
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:35
Write your "own" Array class with two additional properties Start and End
We can safely assume that you always append after the last item
so we have no empty spaces
Steven Liekens
@StevenLiekens
Oct 10 2015 16:36
problem is when head == tail, is the buffer full or empty?
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:37
Full, when the Length property equals the Size
otherwise empty
Steven Liekens
@StevenLiekens
Oct 10 2015 16:40
I'm trying to understand this solution https://en.wikipedia.org/wiki/Circular_buffer#Mirroring
it seems like it has the most advantages
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:41
Personally, I'd use a fill count
That should be the most easy to implement
Steven Liekens
@StevenLiekens
Oct 10 2015 16:41
wiki says it's not thread safe
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:42
yeah
Steven Liekens
@StevenLiekens
Oct 10 2015 16:42
which is a requirement
for me
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:42
hmm
Steven Liekens
@StevenLiekens
Oct 10 2015 16:42
and I suck at writing thread synchronization
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:42
hehe
yeah me too
Steven Liekens
@StevenLiekens
Oct 10 2015 16:43
I just need to understand what the article says damn it
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 16:43
yeah
I try that too
it's a bit weird
it's c++ but you should get the gist
maybe that's a better resource
Steven Liekens
@StevenLiekens
Oct 10 2015 17:18
ok so the mirroring thing is way easier than wikipedia describes it
just gotta flip a bit every time a read or write operation wraps around the end of the array
if the head and tail are the same, the buffer is full when the bit is 1
otherwise it's empty
Robert Logiewa
@Ruhrpottpatriot
Oct 10 2015 21:17
oh
well that is really easy
So the move to HttpClient goes along well
but it's much work
Since there are a lot of changes under the hood