unsigned int OutByteFile::size(){
	const unsigned int currPos = pos();
	goEnd();
	const unsigned int size = pos();
	seek(currPos);
	return size;
}
void OutByteFile::skip(unsigned int skip){
	const unsigned int currentPos = pos();
	const unsigned int filesize = size();

	if(currentPos+skip >= filesize){
		goEnd();
		for(unsigned int i = filesize; i < currentPos+skip; i++ )
			writeChar(0);
	}else{
		seek(currentPos+skip);
	}
}
Beispiel #3
0
 bool goEnd(int A[], int n, int index)
 {
     if (index >= n-1) return true;
     
     int step = A[index];
     bool flag = false;
     for (int i = index+1; i < n && i <= index+step; i++)
     {
         flag = goEnd(A, n, i);
         if (flag)
             return true;
     }
     return false;
 }
Beispiel #4
0
//Goes to the end of the file, checks the length, and then goes to the start.
unsigned long long FileIO::getFileLength()
{
   fileLength = 0; unsigned long long returnInt;
   if(!isBinary){//Not a binary file, therefore it is a text file
      goStart(1);
      std::string line;
      while (std::getline(myfile, line)){
         fileLength = fileLength + line.length() + 1;//Length of string plus null terminator
      }
      goStart(1);
   }

   if (isBinary){
      std::streampos fsize = 0;
      goEnd(1);
      fileLength = myfile.tellg() - fsize;
      goStart(1);
   }
returnInt = fileLength; return returnInt;
}
Beispiel #5
0
int main()
{
///The metafunction @Metafunction.Iterator@ returns the iterator type for a given container type.
	seqan::String<char> str = "admn";
	seqan::Iterator<seqan::String<char> >::Type it = begin(str);
	seqan::Iterator<seqan::String<char> >::Type itEnd = end(str);
///We can use iterators to iterate over the elements of a container.
	while (it != itEnd) {
		::std::cout << *it;
		++it;
	}
	::std::cout << ::std::endl;
///Rooted iterators know their container (@Concept.RootedIteratorConcept|Rooted Iterator@).
///Hence, the functions @Function.goBegin@ and @Function.atEnd@ do
///not get $str$ as an argument.
///The following loop increments each character in $str$.
	seqan::Iterator<seqan::String<char>, seqan::Rooted >::Type it2 = begin(str);
	for (goBegin(it2); !atEnd(it2); goNext(it2)) 
	{
		++value(it2);
	}
///Some iterators support an iteration in reverse order.
///Note that @Function.goPrevious@ is called before the value of $it2$ is accessed.
///Remember that the end position of a container is always the position behind the last item in the container.
	goEnd(it2);
	while (!atBegin(it2))              
	{
		goPrevious(it2);
		::std::cout << getValue(it2);
	}
	::std::cout << ::std::endl;
///@Function.assignValue@ can be used to change the value of an iterator.
	assignValue(begin(str), 'X');
	::std::cout << str << ::std::endl;
	
	return 0;
}
Beispiel #6
0
 bool canJump(int A[], int n) {
     if (n == 0) return true;
     
     return goEnd(A, n, 0);
 }