Please explain this code for fast input.

May 15, 2015 at 6:56am
The code is too large, so I'm posting the link.
http://www.codechef.com/viewsolution/1553773

Please explain the code outside int main() i.e class Fastinput line-by-line, if possible or mention any website/link to go through. (:
May 15, 2015 at 7:58am
The code is too large

You might get some more replies if you ask more specific questions and maybe post some small code segments in here.
May 15, 2015 at 8:11am
Okay mutexe (:
Plz explain the code after defining the terms like dataOffset, buffer, uint32_t etc. (assuming that they are commonly used terms)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
public:
        size_t m_dataOffset;
        FastInput() {
                        m_dataOffset = 0;
                        m_dataSize = 0;
                        m_v = 0x80000000;
                }
                uint32_t ReadNext() {
                        if (m_dataOffset == m_dataSize) {
                                int r = read(0, m_buffer, sizeof(m_buffer));
                                if (r <= 0) return m_v;
                                m_dataOffset = 0;
                                m_dataSize = 0;
                                int i = 0;
                                if (m_buffer[0] < '0') {
                                        if (m_v != 0x80000000) {
                                                m_data[m_dataSize++] = m_v;
                                                m_v = 0x80000000;
                                        }
                                        for (; (i < r) && (m_buffer[i] < '0'); ++i);
                                }
                                for (; i < r;) {
                                        if (m_buffer[i] >= '0') {
                                                m_v = m_v * 10 + m_buffer[i] - 48;
                                                ++i;
                                        } else {
                                                m_data[m_dataSize++] = m_v;
                                                m_v = 0x80000000;
                                                for (i = i + 1; (i < r) && (m_buffer[i] < '0'); ++i);
                                        }
                                }
                        }
                        return m_data[m_dataOffset++];
                }
May 15, 2015 at 9:39am
ReadNext() returns an unsigned long integer:
http://www.nongnu.org/avr-libc/user-manual/group__avr__stdint.html

it looks like it's reading data from a socket? (line 10), then it seems to be populating your m_v variable from the newly populated buffer.

Topic archived. No new replies allowed.