~ubuntu-branches/debian/stretch/bitcoin/stretch

« back to all changes in this revision

Viewing changes to src/prevector.h

  • Committer: Package Import Robot
  • Author(s): Anthony Towns
  • Date: 2016-10-21 17:13:13 UTC
  • mfrom: (1.3.2)
  • Revision ID: package-import@ubuntu.com-20161021171313-7eu2ltpbk0xag3q1
Tags: 0.13.0-0.1
* Non-maintainer upload.
* New upstream release.
* Allow compilation with gcc/g++ 6. (Closes: Bug#835963)
* Additional fixes for openssl 1.1 compatibility. (See Bug#828248)
* Check if -latomic is needed (it is on mips*).
* Remove reproducible build patch, since leveldb build system is
  no longer used in 0.13. (See Bug#791834)
* Update description since the blockchain is much more than "several GB"
  now. (Closes: Bug#835809)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) 2015 The Bitcoin Core developers
 
2
// Distributed under the MIT software license, see the accompanying
 
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
 
4
 
1
5
#ifndef _BITCOIN_PREVECTOR_H_
2
6
#define _BITCOIN_PREVECTOR_H_
3
7
 
294
298
    }
295
299
 
296
300
    void resize(size_type new_size) {
297
 
        while (size() > new_size) {
298
 
            item_ptr(size() - 1)->~T();
299
 
            _size--;
 
301
        if (size() > new_size) {
 
302
            erase(item_ptr(new_size), end());
300
303
        }
301
304
        if (new_size > capacity()) {
302
305
            change_capacity(new_size);
364
367
    }
365
368
 
366
369
    iterator erase(iterator pos) {
367
 
        (*pos).~T();
368
 
        memmove(&(*pos), &(*pos) + 1, ((char*)&(*end())) - ((char*)(1 + &(*pos))));
369
 
        _size--;
370
 
        return pos;
 
370
        return erase(pos, pos + 1);
371
371
    }
372
372
 
373
373
    iterator erase(iterator first, iterator last) {
392
392
    }
393
393
 
394
394
    void pop_back() {
395
 
        _size--;
 
395
        erase(end() - 1, end());
396
396
    }
397
397
 
398
398
    T& front() {
412
412
    }
413
413
 
414
414
    void swap(prevector<N, T, Size, Diff>& other) {
415
 
        if (_size & other._size & 1) {
416
 
            std::swap(_union.capacity, other._union.capacity);
417
 
            std::swap(_union.indirect, other._union.indirect);
418
 
        } else {
419
 
            std::swap(_union, other._union);
420
 
        }
 
415
        std::swap(_union, other._union);
421
416
        std::swap(_size, other._size);
422
417
    }
423
418