コード例 #1
0
ファイル: op_str2.c プロジェクト: SparroHawc/ScarletDME
Private void ins(bool compatible)
{
 /* Stack:

     |=============================|=============================|
     |            BEFORE           |           AFTER             |
     |=============================|=============================|
 top |  Subvalue number            |                             |
     |-----------------------------|-----------------------------| 
     |  Value number               |                             |
     |-----------------------------|-----------------------------| 
     |  Field number               |                             |
     |-----------------------------|-----------------------------| 
     |  ADDR to target string      |                             |
     |-----------------------------|-----------------------------| 
     |  Insertion string           |                             |
     |=============================|=============================|
 */

 DESCRIPTOR * descr;            /* Position descriptors */
 DESCRIPTOR * tgt_descr;        /* Target string */
 DESCRIPTOR * new_descr;        /* Replacement string */
 DESCRIPTOR result_descr;       /* Result string */
 long int field;
 long int value;
 long int subvalue;


 descr = e_stack - 1;
 GetInt(descr);
 subvalue = descr->data.value;
 k_pop(1);

 descr = e_stack - 1;
 GetInt(descr);
 value = descr->data.value;
 k_pop(1);

 descr = e_stack - 1;
 GetInt(descr);
 field = descr->data.value;
 k_pop(1);

 /* Find target and ensure that it is a string */

 tgt_descr = e_stack - 1;
 while(tgt_descr->type == ADDR) tgt_descr = tgt_descr->data.d_addr;
 k_get_string(tgt_descr);
 k_pop(1);     

 new_descr = e_stack - 1;
 k_get_string(new_descr);

 rdi(tgt_descr, field, value, subvalue, DYN_INSERT, new_descr, &result_descr, compatible);

 k_release(tgt_descr);
 *tgt_descr = result_descr;

 k_dismiss();
}
コード例 #2
0
ファイル: op_str2.c プロジェクト: SparroHawc/ScarletDME
void op_del()
{
 /* Stack:

     |=============================|=============================|
     |            BEFORE           |           AFTER             |
     |=============================|=============================|
 top |  Subvalue number            | Modified string             |
     |-----------------------------|-----------------------------| 
     |  Value number               |                             |
     |-----------------------------|-----------------------------| 
     |  Field number               |                             |
     |-----------------------------|-----------------------------| 
     |  Source string              |                             |
     |=============================|=============================|
 */

 DESCRIPTOR * descr;            /* Position descriptors */
 DESCRIPTOR * src_descr;        /* Source string */
 DESCRIPTOR result_descr;       /* Result string */
 long int field;
 long int value;
 long int subvalue;

 descr = e_stack - 1;
 GetInt(descr);
 subvalue = descr->data.value;

 descr = e_stack - 2;
 GetInt(descr);
 value = descr->data.value;

 descr = e_stack - 3;
 GetInt(descr);
 field = descr->data.value;

 src_descr = e_stack - 4;
 k_get_string(src_descr);

 if ((field < 0) || (value < 0) || (subvalue < 0))
  {
   /* Leave source string as the result */

   k_dismiss();
   k_dismiss();
   k_dismiss();
  }
 else
  {
   rdi(src_descr, field, value, subvalue, DYN_DELETE, NULL, &result_descr, FALSE);

   k_dismiss();
   k_dismiss();
   k_dismiss();
   k_dismiss();

   *(e_stack++) = result_descr;
  }
}
コード例 #3
0
ファイル: op_str2.c プロジェクト: SparroHawc/ScarletDME
Private void insert(bool compatible)
{
 /* Stack:

     |=============================|=============================|
     |            BEFORE           |           AFTER             |
     |=============================|=============================|
 top |  Insertion string           | Modified string             |
     |-----------------------------|-----------------------------| 
     |  Subvalue number            |                             |
     |-----------------------------|-----------------------------| 
     |  Value number               |                             |
     |-----------------------------|-----------------------------| 
     |  Field number               |                             |
     |-----------------------------|-----------------------------| 
     |  Source string              |                             |
     |=============================|=============================|
 */

 DESCRIPTOR * descr;            /* Position descriptors */
 DESCRIPTOR * src_descr;        /* Source string */
 DESCRIPTOR * new_descr;        /* Replacement string */
 DESCRIPTOR result_descr;       /* Result string */
 long int field;
 long int value;
 long int subvalue;


 new_descr = e_stack - 1;
 k_get_string(new_descr);

 descr = e_stack - 2;
 GetInt(descr);
 subvalue = descr->data.value;

 descr = e_stack - 3;
 GetInt(descr);
 value = descr->data.value;

 descr = e_stack - 4;
 GetInt(descr);
 field = descr->data.value;

 src_descr = e_stack - 5;
 k_get_string(src_descr);

 rdi(src_descr, field, value, subvalue, DYN_INSERT, new_descr, &result_descr, compatible);

 k_dismiss();  /* Insertion string */
 k_pop(3);     /* Subvalue, value, field and ADDR to source */
 k_dismiss();  /* Source string        0147 was k_pop() */

 *(e_stack++) = result_descr;
}
コード例 #4
0
    void BroxOpticalFlow::runAll()
    {
        Poco::DirectoryIterator rdi(m_sourceFolder);
        Poco::DirectoryIterator end_rdi;

        std::string parentFolder = m_sourceFolder;
        bool dirProcessed = false;
        for (; rdi != end_rdi; ++rdi) {
            if ((*rdi).isDirectory())
            {
                runOnFolder(rdi.path().toString());
            }
        }
    }
コード例 #5
0
/**
	\brief Searches inside a path and optional recursive subdirectories for files that are
	byte-level duplicates.
	\param searchPath The directory path to search inside.
	\param includeSubDirectories Whether to recursively include subdirectories.
	\return An unsigned integer representing how many duplicates it has found and copies the
	filenames into its list of wstrings: "duplicates".
*/
unsigned int DuplicateFinder::FindDuplicates( const std::wstring & searchPath,
                                              const bool & includeSubDirectories )
{
	numberOfDuplicates = 0;
	duplicates.clear();

	std::multimap<unsigned int, std::wstring> files; //a map for filenames

	//first, get a list of all files that we need to search through, including their file sizes
	if( includeSubDirectories )
	{
		//search through paths recursively
		boost::filesystem::recursive_directory_iterator rdi( searchPath );
		while( rdi != boost::filesystem::recursive_directory_iterator() )
		{
			//if it's a file, add it to the filename list
			if( boost::filesystem::is_regular_file( *rdi ) )
			{
				files.insert( std::pair<unsigned int, std::wstring>(
                    ( unsigned int ) boost::filesystem::file_size( *rdi ),
                    ( *rdi ).path().wstring() ) );
			}
			++rdi;
		}
	}
	else
	{
		//search only through the current path
		boost::filesystem::directory_iterator di( searchPath );
		while( di != boost::filesystem::directory_iterator() )
		{
			//if it's a file, add it to the filename list
			if( boost::filesystem::is_regular_file( *di ) )
			{
				files.insert( std::pair<unsigned int, std::wstring>(
                    ( unsigned int ) boost::filesystem::file_size( *di ),
                    ( *di ).path().wstring() ) );
			}
			++di;
		}
	}

	if( !files.empty() )
	{
	    numberOfDuplicates += DuplicateComparison( files );
	}
	return numberOfDuplicates;
}
コード例 #6
0
ファイル: dirdef.cpp プロジェクト: terceiro/doxyparse
void generateDirDocs(OutputList &ol)
{
  DirDef *dir;
  DirSDict::Iterator sdi(*Doxygen::directories);
  for (sdi.toFirst();(dir=sdi.current());++sdi)
  {
    dir->writeDocumentation(ol);
  }
  if (Config_getBool("DIRECTORY_GRAPH"))
  {
    SDict<DirRelation>::Iterator rdi(Doxygen::dirRelations);
    DirRelation *dr;
    for (rdi.toFirst();(dr=rdi.current());++rdi)
    {
      dr->writeDocumentation(ol);
    }
  }
}
コード例 #7
0
ファイル: 没写完.cpp プロジェクト: keroro520/ACM
int main()
{
    int query;
    scanf("%d%d", &query, &Limit);
    init();
    while(query--) {
        char op = rdc();
        int  k  = rdi();
        if(op == 'I') {
            if(k < Limit) continue;
            int res = Find(root, k);
            if(res != -1) f[res].num++, n++;
            else Insert(k);
        } else if(op != 'F') {
            if(k > n) { printf("-1\n"); continue; }
            Update(root, k * (op == 'A' ? 1 : -1));
        } else printf("%d\n", Query(root, k));
    }
    return 0;
}
コード例 #8
0
ファイル: dirdef.cpp プロジェクト: bithium/doxygen
void generateDirDocs(OutputList &ol)
{
  DirDef *dir;
  DirSDict::Iterator sdi(*Doxygen::directories);
  for (sdi.toFirst();(dir=sdi.current());++sdi)
  {
    ol.pushGeneratorState();
    if (!dir->hasDocumentation())
    {
      ol.disableAllBut(OutputGenerator::Html);
    }
    dir->writeDocumentation(ol);
    ol.popGeneratorState();
  }
  if (Config_getBool(DIRECTORY_GRAPH))
  {
    SDict<DirRelation>::Iterator rdi(Doxygen::dirRelations);
    DirRelation *dr;
    for (rdi.toFirst();(dr=rdi.current());++rdi)
    {
      dr->writeDocumentation(ol);
    }
  }
}
コード例 #9
0
ファイル: op_str2.c プロジェクト: SparroHawc/ScarletDME
Private void rep(bool compatible)
{
 /* Stack:

     |=============================|=============================|
     |            BEFORE           |           AFTER             |
     |=============================|=============================|
 top |  Replacement string         |                             |
     |-----------------------------|-----------------------------| 
     |  Subvalue number            |                             |
     |-----------------------------|-----------------------------| 
     |  Value number               |                             |
     |-----------------------------|-----------------------------| 
     |  Field number               |                             |
     |-----------------------------|-----------------------------| 
     |  ADDR to string to update   |                             |
     |=============================|=============================|
 */

 DESCRIPTOR * descr;            /* Position descriptors */
 long int field;
 long int value;
 long int subvalue;

 DESCRIPTOR * str_descr;        /* String to update */
 STRING_CHUNK * str_first_chunk;
 STRING_CHUNK * str_hdr;
 STRING_CHUNK * str_prev;
 short int chunk_size;

 STRING_CHUNK * new_str_hdr;    /* For copying replaced chunk */

 DESCRIPTOR * rep_descr;        /* Replacement string */
 STRING_CHUNK * rep_str_hdr;
 long int rep_len;              /* Length of inserted data */
 long int s_len;                /* New length of result string */

 DESCRIPTOR result_descr;       /* Result string */

 bool add_fm;

 rep_descr = e_stack - 1;
 k_get_string(rep_descr);
 rep_str_hdr = rep_descr->data.str.saddr;

 descr = e_stack - 2;
 GetInt(descr);
 subvalue = descr->data.value;

 descr = e_stack - 3;
 GetInt(descr);
 value = descr->data.value;

 descr = e_stack - 4;
 GetInt(descr);
 field = descr->data.value;

 str_descr = e_stack - 5;
 while (str_descr->type == ADDR) str_descr = str_descr->data.d_addr;
 k_get_string(str_descr);


 /* Optimised path for the S<-1, 0, 0> case with a reference count of one */

 if ((field < 0) && (value == 0) && (subvalue == 0))
  {
   str_hdr = str_descr->data.str.saddr;

   if (str_hdr == NULL)
    {
     /* Appending a field to a null string.  Make the updated string a
        reference to the replacement string.                            */

     if (rep_str_hdr != NULL) rep_str_hdr->ref_ct++;
     str_descr->data.str.saddr = rep_str_hdr;
     goto exit_op_rep;
    }

   /* Examine the string we are to update. If this has a reference count of
      one, we can optimise the action by simply appending to the string
      without copying it.                                                  */

   if (str_hdr->ref_ct == 1)
    {
     /* Ensure we do not leave a remove pointer active */

     str_descr->flags &= ~DF_REMOVE;

     /* Find the final chunk of the string */

     str_first_chunk = str_hdr;
     str_prev = NULL;
     while(str_hdr->next != NULL)
      {
       str_prev = str_hdr;
       str_hdr = str_hdr->next;
      }

     /* We need to take into account the program's append mode. For
        compatible style, if the last character of the existing string
        is a field mark (i.e. the string ends with a null field), we
        do not add a further field mark.                                */
     /* 0407 Rearranged code so that mark length is only added if we
        will be adding the mark.                                        */

     add_fm = !compatible || (str_hdr->data[str_hdr->bytes-1] != FIELD_MARK);
     if (rep_str_hdr == NULL) rep_len = add_fm;
     else rep_len = rep_str_hdr->string_len + add_fm;


     /* Update the total string length */

     s_len = str_first_chunk->string_len + rep_len;
     str_first_chunk->string_len = s_len;
     

     if (str_hdr->alloc_size >= s_len)
      {
       /* The entire result will fit in the allocated size of the target
          string.  Append the new data.                                  */

       if (add_fm) str_hdr->data[str_hdr->bytes++] = FIELD_MARK;

       while(rep_str_hdr != NULL)
        {
         memcpy(str_hdr->data + str_hdr->bytes,
                rep_str_hdr->data, rep_str_hdr->bytes);
         str_hdr->bytes += rep_str_hdr->bytes;
         rep_str_hdr = rep_str_hdr->next;
        }
       goto exit_op_rep;
      }

     /* If this chunk is less than maximum size, replace it by a new chunk. */

     if (str_hdr->bytes < MAX_STRING_CHUNK_SIZE)
      {
       /* Replace final chunk */

       rep_len += str_hdr->bytes;
       new_str_hdr = s_alloc(rep_len, &chunk_size);

       /* Copy old data and rechain chunks, freeing old one */

       memcpy(new_str_hdr->data, str_hdr->data, str_hdr->bytes);
       new_str_hdr->bytes = str_hdr->bytes;

       if (str_prev == NULL) /* First chunk */
        {
         new_str_hdr->string_len = str_hdr->string_len;
         new_str_hdr->ref_ct = 1;

         str_descr->data.str.saddr = new_str_hdr;
        }
       else
        {
         str_prev->next = new_str_hdr;
        }

       s_free(str_hdr);
       str_hdr = new_str_hdr;
      }
     else
      {
       chunk_size = (short int)min(rep_len, MAX_STRING_CHUNK_SIZE);
      }
      
     /* Append field mark and new data */

     if (add_fm)
      {
       str_hdr = copy_string(str_hdr, &(str_descr->data.str.saddr),
                             FIELD_MARK_STRING, 1, &chunk_size);
      }

     while(rep_str_hdr != NULL)
      {
       str_hdr = copy_string(str_hdr, &(str_descr->data.str.saddr),
                        rep_str_hdr->data, rep_str_hdr->bytes, &chunk_size);
       rep_str_hdr = rep_str_hdr->next;
      }

     goto exit_op_rep;
    }
  }

 rdi(str_descr, field, value, subvalue, DYN_REPLACE, rep_descr, &result_descr, compatible);
 k_release(str_descr);
 InitDescr(str_descr, STRING);
 str_descr->data.str.saddr = result_descr.data.str.saddr;

exit_op_rep:
 k_dismiss();
 k_pop(4);     /* subvalue, value and field positions and ADDR to target */
}