Пример #1
0
void Buffer::ensureWritableBytes(size_t len)
{
    if (writableBytes() < len)
    {
        makeSpace(len);
    }
    assert(writableBytes() >= len);
}
Пример #2
0
/** Expand the space available for this Dlist.
 *  Rebuilds old value in new space.
 *  @param size is the size of the expanded object.
 */
void Dlist::expand(int size) {
	int old_n = n();
	List::expand(size);
	if (n() == old_n) return;
	index *old_pred = pred; makeSpace();
	std::copy(old_pred, old_pred+old_n+1, pred);
	std::fill(pred+old_n+1, pred+n()+1, -1);
	delete [] old_pred;
}
Пример #3
0
/** Assignment operator (copy).
 *  @param other is a reference to a list to be compared to this
 *  @return true if the two lists are equal
 */
Dlist& Dlist::operator=(const Dlist& src) {
	if (this == &src) return *this;
	int old_n = n();
	List::operator=(src); // copy parent class data
	if (n() != old_n) {  // parent resized, do likewise
		freeSpace(); makeSpace();
	}
	init();
	for (index x = src.first(); x != 0; x = src.next(x))
		pred[x] = src.pred[x];
	return *this;
}
Пример #4
0
bool GrIndexBufferAllocPool::appendIndices(int indexCount,
                                           const void* indices,
                                           const GrIndexBuffer** buffer,
                                           int* startIndex) {
    void* space = makeSpace(indexCount, buffer, startIndex);
    if (NULL != space) {
        memcpy(space, indices, sizeof(uint16_t) * indexCount);
        return true;
    } else {
        return false;
    }
}
Пример #5
0
// ------------------------------------------------->
// Allocates memory for a word and initializes it.
// ------------------------------------------------->
struct word *initializeWord(char *givenWord)
{
	struct word *word = makeSpace(sizeof(struct word));

	int wordLength = strlen(givenWord);

	char *name = makeSpace(wordLength + 1);
	
	strcpy(name, givenWord);

	word->name = name;
	word->step = -1;
	word->numNearby = 0;
	word->length = wordLength;

	word->linkedWord = NULL;
	word->nearby = NULL;
	word->ladder = NULL;
	word->nextWord = NULL;

	return word;
}
Пример #6
0
bool GrVertexBufferAllocPool::appendVertices(GrVertexLayout layout,
                                             int vertexCount,
                                             const void* vertices,
                                             const GrVertexBuffer** buffer,
                                             int* startVertex) {
    void* space = makeSpace(layout, vertexCount, buffer, startVertex);
    if (NULL != space) {
        memcpy(space,
               vertices,
               GrDrawTarget::VertexSize(layout) * vertexCount);
        return true;
    } else {
        return false;
    }
}
Пример #7
0
bool GrVertexBufferAllocPool::appendVertices(size_t vertexSize,
                                             int vertexCount,
                                             const void* vertices,
                                             const GrVertexBuffer** buffer,
                                             int* startVertex) {
    void* space = makeSpace(vertexSize, vertexCount, buffer, startVertex);
    if (NULL != space) {
        memcpy(space,
               vertices,
               vertexSize * vertexCount);
        return true;
    } else {
        return false;
    }
}
Пример #8
0
// Construct a copy of a graph from a given graph
digraph::digraph(const digraph& G) : graph(G) {
    makeSpace();
    copyFrom(G);
}
Пример #9
0
// Construct a graph with space for N1 vertices and mM1 edges.
digraph::digraph(int mN1, int mM1) : graph(mN1,mM1) {
    makeSpace();
}
Пример #10
0
void digraph::mSpace() {
    graph::mSpace();
    makeSpace();
}
Пример #11
0
 ReaderPacker(Reader content) : packedMessage(makeSpace(content)), outs(packedMessage) {
     capnp::writePackedMessage(outs, message);
 }
Пример #12
0
/** Default constructor for Dlist objects.  */
Dlist::Dlist() : List() { makeSpace(); init(); }
Пример #13
0
/** Resize the flograph.
 *  The old flograph is discarded and new space allocated.
 *  @param numv is the number of vertices in the graph
 *  @param maxe is the max number of edges in the graph
 */
void Wflograph::resize(int numv, int maxe) {
        Flograph::resize(numv, maxe);
        freeSpace(); makeSpace(numv, maxe);
}
Пример #14
0
/** Resize a Dlists_r object.
 *  The old value is discarded.
 *  @param size is the size of the resized object.
 */
void Dlists_r::resize(int size) {
	freeSpace(); makeSpace(); clear();
}
Пример #15
0
/** Resize a Graph object.
 *  The old value is discarded.
 *  @param numv is the number of vertices to allocate space for
 *  @param maxe is the number of edges to allocate space for
 */
void Graph::resize(int numv, int maxe) {
	freeSpace();
	Adt::resize(numv);
	makeSpace(numv,maxe);
	init();
}
Пример #16
0
/** Constructor for Ssets2k class.
 *  @param n defines the index range for the constructed object.
 */
Ssets2k::Ssets2k(int n) : Ssets_rbt(n) {
	makeSpace(); init();
}
Пример #17
0
/** Resize a RlistSet object.
 *  The old value is discarded.
 *  @param size is the size of the resized object.
 */
void RlistSet::resize(int size) {
	freeSpace(); makeSpace(); clear();
}
Пример #18
0
/** Resize a Dlist object.
 *  The old value is discarded.
 *  @param size is the size of the resized object.
 */
void Dlist::resize(int size) {
	freeSpace(); List::resize(size); makeSpace(); init();
}
Пример #19
0
/** Copy constructor.
 *  @param src is a Dlist whose contents are copied to this Dlist.
 */
Dlist::Dlist(const Dlist& src) : List(src) {
	makeSpace(); init();
	for (index x = src.first(); x != 0; x = src.next(x))
		pred[x] = src.pred[x];
}
Пример #20
0
/** Constructor for Dlist objects with explicit index range.
 *  @param n specifies the maximum index
 */
Dlist::Dlist(int n) : List(n) { makeSpace(); init(); }
Пример #21
0
int placeAtEnd (queue *q, item item)
{
	makeSpace (q, q->size + 1);
	q->root[q->size] = item;
	return q->size++;
}
Пример #22
0
/** Constructor for RlistSet class.
 *  @param n defines the index set for the new object
 */
RlistSet::RlistSet(int n) : Adt(n) { makeSpace(); clear(); }
Пример #23
0
/** Constructor for Dlists_r class.
 *  @param n defines the index set for the new object
 */
Dlists_r::Dlists_r(int n) : Adt(n) { makeSpace(); clear(); }
Пример #24
0
/** Constructor for DkBstSet class.
 *  @param n defines the index range for the constructed object.
 */
DkBstSet::DkBstSet(int n) : BalBstSet(n) {
	makeSpace(); init();
}
Пример #25
0
/** Construct a Wflograph.
 *  @param numv is the number of vertices in the graph
 *  @param maxe is the max number of edges in the graph
 *  @param s1 is the source vertex
 *  @param t1 is the sink vertex
 */
Wflograph::Wflograph(int numv, int maxe, int s1, int t1) 
	: Flograph(numv, maxe, s1, t1) {
	makeSpace(numv,maxe);
}
Пример #26
0
/** Resize a DkBstSet object, discarding old value.
 *  @param n is the size of the resized object.
 */
void DkBstSet::resize(int n) {
	freeSpace(); BalBstSet::resize(n); makeSpace(); init();
}
Пример #27
0
/** Constructor for PathSet class.
 *  @param n defines the index range for the constructed object.
 *  @param pathVals is a vector of integer values, which is defined for
 *  each path in the set; that is if u is the handle of some path,
 *  then pathVals[u] will be an integer which the application using
 *  the PathSet has defined for the path; since the PathSet object
 *  may change the handle of a path as a side effect of any operation,
 *  the PathSet object updates pathVals whenever the handle for a path
 *  changes
 */
PathSet::PathSet(int n, int *pathVals) : Adt(n), pvals(pathVals) {
	makeSpace(); clear();
}
Пример #28
0
/** Resize a Ssets2k object, discarding old value.
 *  @param n is the size of the resized object.
 */
void Ssets2k::resize(int n) {
	freeSpace(); Ssets_rbt::resize(n); makeSpace(); init();
}
Пример #29
0
/** Resize a PathSet object, discarding old value.
 *  @param n is the size of the resized object.
 */
void PathSet::resize(int n) {
	freeSpace(); Adt::resize(n); makeSpace(); clear();
}
Пример #30
0
/** Resize a Partition object.
 *  The old value is discarded.
 *  @param n is the size of the resized object.
 */
void Partition::resize(int n) { freeSpace(); Adt::resize(n); makeSpace(); }