Beispiel #1
0
void charSplit(SLIST *strList, struct String *src, char c)
{
	int i = 0;
	struct String *tempStr = createStr();
	while (i <= src->strLen)
	{
		if ((src->buf[i]) == c && (tempStr->strLen != 0)) {
			//add tempStr contents to strList, clear tempStr
			//printf("tempStr contents: %s\n", tempStr->buf);
			addLit(strList, tempStr->buf);
			clearBufStr(tempStr);
			i++;
		}
		else if ((src->buf[i]) == c && (tempStr->strLen == 0)) {
			i++;
		}
		else {
			appendChar(tempStr, src->buf[i]);
			i++;
		}
	}
	if (tempStr->strLen != 0)
	{
		addLit(strList, tempStr->buf);
	}
	destroyStr(tempStr);
}
Beispiel #2
0
  const LitVector& LitVector::operator+=(Literal l) {
    if (_size == _alloc) {
      _alloc <<= 1;
      _lits = (Literal*) realloc(_lits, sizeof(Literal) * _alloc);
    }

#if MERGING > 0
    addLit(l);
#else
    _lits[_size++] = l;
#endif
    return *this;
  }
Beispiel #3
0
  void LitVector::init(const LitVector& other, Literal l) {
    _size = other._size;

    int newAlloc = other._alloc;
    if (_size == newAlloc) newAlloc <<= 1;
    if (newAlloc > _alloc) {
      _alloc = newAlloc;
      _lits = (Literal*) realloc(_lits, _alloc * sizeof(Literal));
    }
    memcpy(_lits, other._lits, sizeof(Literal) * _size);
#if MERGING > 0
    addLit(l);
#else
    _lits[_size++] = l;
#endif
  }