Exemplo n.º 1
0
void
row_stop(int t)	\
	{ 
	int i;
	
	/* need to allow for handling the master and detail together */
	if (t == ORDER_LINE)
		t = ORDER;
	if (t == PART_PSUPP)
		t = PART;
	
	for (i=0; i <= MAX_STREAM; i++)
		if ((Seed[i].table == t) || (Seed[i].table == tdefs[t].child))
			{ 
			if (set_seeds && (Seed[i].usage > Seed[i].boundary))
				{
				fprintf(stderr, "\nSEED CHANGE: seed[%d].usage = %lld\n", 
					i, Seed[i].usage); 
				Seed[i].boundary = Seed[i].usage;
				} 
			else 
				{
				NthElement((Seed[i].boundary - Seed[i].usage), &Seed[i].value);
#ifdef RNG_TEST
				Seed[i].nCalls += Seed[i].boundary - Seed[i].usage;
#endif
				}
			} 
		return;
	}
Exemplo n.º 2
0
static listElementT NthElement(listADT list, int n)
{
    if (list == NULL) {
        Error("NthElement: No such element");
    } else if (n == 0) {
        return (ListHead(list));
    } else {
        return (NthElement(ListTail(list), n - 1));
    }
}
Exemplo n.º 3
0
/* updates Seed[column] using the a_rnd algorithm */
void
fake_a_rnd(int min, int max, int column)
{
   long len, itcount;
   RANDOM(len, (long)min, (long)max, (long)column);
   if (len % 5L == 0)
      itcount = len/5;
   else itcount = len/5 + 1L;
   NthElement(itcount, &Seed[column].usage);
   return;
}
void TargetPhraseCollection::Prune(bool adhereTableLimit, size_t tableLimit)
{
  NthElement(tableLimit);

  if (adhereTableLimit && m_collection.size() > tableLimit) {
    for (size_t ind = tableLimit; ind < m_collection.size(); ++ind) {
      const TargetPhrase *targetPhrase = m_collection[ind];
      delete targetPhrase;
    }
    m_collection.erase(m_collection.begin() + tableLimit, m_collection.end());
  }
}
Exemplo n.º 5
0
static void SelectionOperation(dataBlockT db, string lhs)
{
    string var;
    int pos;

    if (lhs != NULL) Error("NthElement result cannot be assigned");
    CheckForToken(db->scanner, "(");
    var = ConvertToLowerCase(ReadToken(db->scanner));
    CheckForToken(db->scanner, ",");
    pos = StringToInteger(ReadToken(db->scanner));
    CheckForToken(db->scanner, ")");
    printf("%s\n", NthElement(GetValue(db, var), pos));
}
Exemplo n.º 6
0
void 
advanceStream(int nStream, int nCalls, int bUse64Bit)
{
  if (bUse64Bit)
    Seed[nStream].value = AdvanceRand64(Seed[nStream].value, nCalls);
  else
    NthElement(nCalls, &Seed[nStream].value);

#ifdef RNG_TEST
  Seed[nStream].nCalls += nCalls;
#endif

  return;
}
Exemplo n.º 7
0
/* updates Seed[column] using the a_rnd algorithm */
void
fake_a_rnd(int min, int max, int column)
{
  DSS_HUGE len;
  DSS_HUGE itcount;

  RANDOM(len, min, max, column);
  if (len % 5L == 0)
    itcount = len/5;
  else 
    itcount = len/5 + 1L;
  NthElement(itcount, &Seed[column].usage);
#ifdef RNG_TEST
  Seed[column].nCalls += itcount;
#endif
  return;
}
	/// 中位数和顺序统计学
	int testNthElement()
	{
		vector<int> v;
		for ( int i = 0; i < 10; ++i )
		{
			v.push_back( ( rand() % 1000 ) );
		}
		copy( v.begin(), v.end(), ostream_iterator<int>( cout, "  " ) );
		cout << endl;

		for ( int i = 0; i < 10; ++i )
		{
			cout << i << "th element is:" << NthElement( v, i ) << endl;
		}

		return 0;
	}
Exemplo n.º 9
0
void
GFGClass::WriteProtected
	(
	ostream& 		os,
	const JBoolean	interface
	)
{
	const JSize count	= GetElementCount();
	for (JIndex i = 1; i <= count; i++)
		{
		GFGMemberFunction* fn	= NthElement(i);
		if (fn->IsUsed() &&
			fn->IsProtected())
			{
			WriteFunction(os, fn, interface);
			}
		}
}
Exemplo n.º 10
0
void
row_stop(int t)	\
	{ 
	int i;
	
	/*
	 * note: code for master/detail has been removed 
	 */
	for (i=0; i <= MAX_STREAM; i++)
		if (Seed[i].table == t)
			{ 
			if (set_seeds && (Seed[i].usage > Seed[i].boundary))
				{
				fprintf(stderr, "\nSEED CHANGE: seed[%d].usage = %d\n", 
					i, Seed[i].usage); 
				Seed[i].boundary = Seed[i].usage;
				} 
			else 
				{
				NthElement((Seed[i].boundary - Seed[i].usage), &Seed[i].value);
				}
			} 
		return;
	}