示例#1
0
int main()
{
	int ia[] = { 29,23,20,17,15,26,51,12,35,40,
		     74,16,54,21,44,62,10,41,65,71 };

	vector< int, allocator > ivec( ia, ia+20 );
        void (*pfi)( int ) = print_elements;

	// place the two subsequences in sorted order
	sort( &ia[0], &ia[10] ); 
	sort( &ia[10], &ia[20] );
		
	cout << "ia sorted into two sub-arrays: \n";
        for_each( ia, ia+20, pfi ); cout << "\n\n";

	inplace_merge( ia, ia+10, ia+20 );
	
	cout << "ia inplace_merge:\n";
        for_each( ia, ia+20, pfi ); cout << "\n\n";

	sort( ivec.begin(),    ivec.begin()+10, greater<int>() );
	sort( ivec.begin()+10, ivec.end(),      greater<int>() );
		
	cout << "ivec sorted into two sub-vectors: \n";
        for_each( ivec.begin(), ivec.end(), pfi ); cout << "\n\n";

	inplace_merge( ivec.begin(), ivec.begin()+10, 
		       ivec.end(),   greater<int>() );
		
	cout << "ivec inplace_merge:\n";
        for_each( ivec.begin(), ivec.end(), pfi ); cout << endl;
}
示例#2
0
int main(int argc, const char **argv)
{
    int a[] = {1,2,3,4,5};
    int b[] = {2,4,6,7,10};
    int c[] = {3,5,8,10,11};

    std::vector<int> z(15);

    std::copy(a, a+5, z.begin());
    std::copy(b, b+5, z.begin() + 5);
    std::copy(c, c+5, z.begin() + 10);

    std::vector<int> indeces, counts;

    indeces.push_back(0);
    indeces.push_back(5);
    indeces.push_back(10);

    counts.push_back(5);
    counts.push_back(5);
    counts.push_back(5);

    inplace_merge(indeces, counts, 0, 3, z);

    std::cout << z;
}
double dac(point_t *p, int l, int r) {
  double d = 10e100;
  if (r - l <= 3) {
    for (int i = l; i <= r; ++i) {
      for (int j = i + 1; j <= r; ++j) {
        d = min(d, dist2(p[i], p[j]));
      }
    }
    sort(p + l, p + r + 1, cmpY);
  } else {
    int mid = (l + r) / 2;
    d = min(dac(p, l, mid), dac(p, mid + 1, r));
    inplace_merge(p + l, p + mid + 1, p + r + 1, cmpY);
    static point_t tmp[maxN]; int cnt = 0;
    for (int i = l; i <= r; ++i) {
      if ((p[i].x - p[mid].x) * (p[i].x - p[mid].x) <= d) tmp[++cnt] = p[i];
    }
    for (int i = 1; i <= cnt; ++i) {
      for (int j = 1; j <= 8 && j + i <= cnt; ++j) {
        d = min(d, dist2(tmp[i], tmp[j + i]));
      }
    }
  }
  return d;
}
示例#4
0
int SpeedCurve::mouseClicked(shared_ptr<ViewInterface> v, int button, int state, int x, int y) {
	glm::vec3 click(x, y, 0);
	if (!state) {

		/* get nearby points */
		float distance = 30;
		selection = -1;
		for ( unsigned int i = 0; i < speed.points.size(); ++i ) {

			float dt = glm::distance(speed.points.data()[i], glm::vec3(x, y, 0));
			if (dt < distance) {
				selection = i;
				distance = dt;
			}
		}
		if (selection < 0) {
			// sort new values, so order has increasing x
			speed.points.push_back( click );
			inplace_merge(begin(speed.points), speed.points.end() - 1, speed.points.end(), vec_comp_x);
			calculateValues();
		}
		else {
			dragSelection = true;
			pmx = x;
			pmy = y;

		}
		return 1;
	}
	else {
		dragSelection = false;
		calculateValues();
	}
	return 0;
}
示例#5
0
TreeNode * TreeNode::AddChild( int anItem, bool Intra, int Sup)
{
	TreeNode *Result = NULL;
	TreeNode *Child  = NULL;

	Result = FindChild( anItem, Intra);
	if( Result == NULL ) {
		Child= new TreeNode(anItem, Intra, Sup);
		Result = Child;
		(*Children).push_back( Child ); 
		// To keep the children vector sorted.
		inplace_merge( (*Children).begin(), (*Children).end()-1, (*Children).end(), TreeNodeLess );
		Child->Parent = this;
		if( Child->ItemIsIntra ) {
			Child->ItemsetNumber = ItemsetNumber;
			Child->Items = Items + 1;
		}
		else {
			Child->ItemsetNumber = ItemsetNumber + 1;
			Child->Items = Items + 1;
		}
	} else {
		if( Result->Support < Sup ) {
			printf("Item: %d %d %d\n", anItem, Result->Support, Sup);
			printf("ParentItem: %d %d\n", Item, Support);
			Result->Support = Sup;
		}
	}
	return Result;
}
示例#6
0
void GotoFileList::UpdateList(const bool reloadAll) {
	const FileEntry* selEntry = GetSelectedAction();
	const int topLine = GetFirstVisibleLine();
	int selection = -1;
	const unsigned int startItem = reloadAll ? 0 : m_items.size();

	// Insert new items
	if (m_searchText.empty()) {
		// Copy all actions to items
		m_items.resize(m_actions.size());
		for (unsigned int i = startItem; i < m_actions.size(); ++i) {
			m_items[i].file_entry = m_actions[i];
			m_items[i].hlChars.clear();
		}
	}
	else {
		// Copy matching actions to items
		for (unsigned int i = m_actionCount; i < m_actions.size(); ++i) {
			if (m_tempEntry->path.empty() || m_actions[i]->path != m_tempEntry->path)
				AddFileIfMatching(m_searchText, m_actions[i]);
		}
	}

	// Sort the items
	if (startItem) {
		sort(m_items.begin() + startItem, m_items.end());
		inplace_merge(m_items.begin(), m_items.begin() + startItem, m_items.end());
	}
	else sort(m_items.begin(), m_items.end());

	// Keep same selection
	if (selEntry) {
		for (unsigned int i = 0; i < m_items.size(); ++i) {
			if (m_items[i].file_entry == selEntry) {
				selection = i;
				break;
			}
		}
	}

	// Refresh and redraw listCtrl
	Freeze();
	SetItemCount(m_items.size());
	SetSelection(selection);

	if (selection == -1)
		ScrollToLine(topLine);
	else if (!IsVisible(selection))
		ScrollToLine(selection);

	RefreshAll();
	Thaw();

	m_actionCount = m_actions.size();
}
示例#7
0
 int countRange(vector<long>& sums, int start, int end, int lower, int upper) {
     if (end - start <= 1)
         return 0;
     int mid = start + (end - start) / 2;
     long count = countRange(sums, start, mid, lower, upper) + countRange(sums, mid, end, lower, upper);
     int r = mid, l = mid;
     for (int i = start; i != mid; i++) {
         while (l < end && sums[l] - sums[i] < lower)
             l++;
         while (r < end && sums[r] - sums[i] <= upper)
             r++;
         count += r - l;
     }
     inplace_merge(sums.begin()+start, sums.begin()+mid, sums.begin()+end);
     return count;
 }
示例#8
0
inline TreeNode *TreeNode::AddChildWithoutChecking(int anItem, bool Intra, int Sup)
{
	TreeNode *Child;

	Child= new TreeNode(anItem, Intra, Sup);

	(*Children).push_back( Child ); 
	// To keep the children vector sorted.
	inplace_merge( (*Children).begin(), (*Children).end()-1, (*Children).end(), TreeNodeLess );
	Child->Parent = this;
	if( Child->ItemIsIntra ) {
		Child->ItemsetNumber = ItemsetNumber;
		Child->Items = Items + 1;
	}
	else {
		Child->ItemsetNumber = ItemsetNumber + 1;
		Child->Items = Items + 1;
	}
	return Child;
}
示例#9
0
void sort_algo_demo(){
    cout<<endl<<"sort_algo_demo :"<<endl;
    int ia[] = {0, 7,  3, 11, 5, 9, 4 , 2, 8};
    vector<int> iv(ia,ia+9);vector<int> iv1(9,0);
    vector<int>::iterator itr;
    cout<<iv<<endl;
//	partial_sort_copy()
    partial_sort(iv.begin(),iv.begin()+5,iv.end());		//内部采用堆算法,保证前面的middle-first有序
    partial_sort_copy(iv.begin(),iv.end(),iv1.begin(),iv1.begin()+4,greater<int>());
    cout<<"partial_sort: "<<iv<<endl<<"partial_sort_copy: "<<iv1<<endl;
    sort(iv.begin(),iv.end(),greater<int>());
    cout<<"sort: "<<iv<<endl;

    int ia1[] = {1, 3,  5, 7, 2, 4, 6 , 8, 10};
    vector<int> iv2(ia1,ia1+9);	vector<int> iv3(ia1,ia1+9);
    inplace_merge(iv2.begin(),iv2.begin()+4,iv2.end());
    cout<<"inplace_merge: "<<iv2<<endl;
    nth_element(iv3.begin(),iv3.begin()+5,iv3.end());
    cout<<"nth_element: "<<iv3<<endl<<"5th element: "<<*(iv3.begin()+5)<<endl;

}
示例#10
0
// Check if we have a matching trigger
int GotoFileList::FindMatchesAndSelection(const std::map<wxString,wxString>& triggers) {
	if (!m_items.size()) return wxNOT_FOUND;

	int selection = wxNOT_FOUND;
	std::map<wxString,wxString>::const_iterator p = triggers.find(m_searchText);
	if (p != triggers.end())
		selection = FindPath(p->second);

	if (selection != wxNOT_FOUND)
		return selection;

	// Check if we have a partial match, using saved triggers
	for (p = triggers.begin(); p != triggers.end(); ++p) {
		if (!p->first.StartsWith(m_searchText)) continue;

		selection = FindPath(p->second);
		if (selection != wxNOT_FOUND) continue;

		// Since we have a trigger but it is not in list yet
		// Let's check if it exists and add it temporarily
		if (wxFileExists(p->second)) {
			m_tempEntry->SetPath(p->second);

			// Add entry with highlighted search chars
			AddFileIfMatching(m_searchText, m_tempEntry);

			// Find position it will end up after sort
			std::vector<aItem>::iterator insPos = lower_bound(m_items.begin(), m_items.end()-1, m_items.back());
			selection = distance(m_items.begin(), insPos);

			// Move item to correct position
			if (m_items.size() > 1)
				inplace_merge(m_items.begin(), m_items.end()-1, m_items.end());

			return selection;
		}
	}

	return selection;
}
示例#11
0
文件: list.c 项目: manjuraj/archive
/* 
 * Sorts LIST according to LESS given auxiliary data AUX, using a
 * natural iterative merge sort that runs in O(n lg n) time and
 * O(1) space in the number of elements in LIST.
 */
void
list_sort (struct list *list, list_less_func *less, void *aux)
{
  size_t output_run_cnt;        /* Number of runs output in current pass. */

  ASSERT (list != NULL);
  ASSERT (less != NULL);

  /* 
   * Pass over the list repeatedly, merging adjacent runs of
   * nondecreasing elements, until only one run is left.
   */
  do
    {
      struct list_elem *a0;     /* Start of first run. */
      struct list_elem *a1b0;   /* End of first run, start of second. */
      struct list_elem *b1;     /* End of second run. */

      output_run_cnt = 0;
      for (a0 = list_begin (list); a0 != list_end (list); a0 = b1)
        {
          /* Each iteration produces one output run. */
          output_run_cnt++;

          /* Locate two adjacent runs of nondecreasing elements
             A0...A1B0 and A1B0...B1. */
          a1b0 = find_end_of_run (a0, list_end (list), less, aux);
          if (a1b0 == list_end (list))
            break;
          b1 = find_end_of_run (a1b0, list_end (list), less, aux);

          /* Merge the runs. */
          inplace_merge (a0, a1b0, b1, less, aux);
        }
    }
  while (output_run_cnt > 1);

  ASSERT (is_sorted (list_begin (list), list_end (list), less, aux));
}
示例#12
0
static void TestAlgorithms (void)
{
    static const int c_TestNumbers[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 13, 14, 15, 16, 17, 18 };
    const int* first = c_TestNumbers;
    const int* last = first + VectorSize(c_TestNumbers);
    intvec_t v, buf;
    v.assign (first, last);
    PrintVector (v);

    cout << "swap(1,2)\n";
    swap (v[0], v[1]);
    PrintVector (v);
    v.assign (first, last);

    cout << "copy(0,8,9)\n";
    copy (v.begin(), v.begin() + 8, v.begin() + 9);
    PrintVector (v);
    v.assign (first, last);

    cout << "copy with back_inserter\n";
    v.clear();
    copy (first, last, back_inserter(v));
    PrintVector (v);
    v.assign (first, last);

    cout << "copy with inserter\n";
    v.clear();
    copy (first, first + 5, inserter(v, v.begin()));
    copy (first, first + 5, inserter(v, v.begin() + 3));
    PrintVector (v);
    v.assign (first, last);

    cout << "copy_n(0,8,9)\n";
    copy_n (v.begin(), 8, v.begin() + 9);
    PrintVector (v);
    v.assign (first, last);

    cout << "copy_if(is_even)\n";
    intvec_t v_even;
    copy_if (v, back_inserter(v_even), &is_even);
    PrintVector (v_even);
    v.assign (first, last);

    cout << "for_each(printint)\n{ ";
    for_each (v, &printint);
    cout << "}\n";

    cout << "for_each(reverse_iterator, printint)\n{ ";
    for_each (v.rbegin(), v.rend(), &printint);
    cout << "}\n";

    cout << "find(10)\n";
    cout.format ("10 found at offset %zd\n", abs_distance (v.begin(), find (v, 10)));

    cout << "count(13)\n";
    cout.format ("%zu values of 13, %zu values of 18\n", count(v,13), count(v,18));

    cout << "transform(sqr)\n";
    transform (v, &sqr);
    PrintVector (v);
    v.assign (first, last);

    cout << "replace(13,666)\n";
    replace (v, 13, 666);
    PrintVector (v);
    v.assign (first, last);

    cout << "fill(13)\n";
    fill (v, 13);
    PrintVector (v);
    v.assign (first, last);

    cout << "fill_n(5, 13)\n";
    fill_n (v.begin(), 5, 13);
    PrintVector (v);
    v.assign (first, last);

    cout << "fill 64083 uint8_t(0x41) ";
    TestBigFill<uint8_t> (64083, 0x41);
    cout << "fill 64083 uint16_t(0x4142) ";
    TestBigFill<uint16_t> (64083, 0x4142);
    cout << "fill 64083 uint32_t(0x41424344) ";
    TestBigFill<uint32_t> (64083, 0x41424344);
    cout << "fill 64083 float(0.4242) ";
    TestBigFill<float> (64083, 0x4242f);
#if HAVE_INT64_T
    cout << "fill 64083 uint64_t(0x4142434445464748) ";
    TestBigFill<uint64_t> (64083, UINT64_C(0x4142434445464748));
#else
    cout << "No 64bit types available on this platform\n";
#endif

    cout << "copy 64083 uint8_t(0x41) ";
    TestBigCopy<uint8_t> (64083, 0x41);
    cout << "copy 64083 uint16_t(0x4142) ";
    TestBigCopy<uint16_t> (64083, 0x4142);
    cout << "copy 64083 uint32_t(0x41424344) ";
    TestBigCopy<uint32_t> (64083, 0x41424344);
    cout << "copy 64083 float(0.4242) ";
    TestBigCopy<float> (64083, 0.4242f);
#if HAVE_INT64_T
    cout << "copy 64083 uint64_t(0x4142434445464748) ";
    TestBigCopy<uint64_t> (64083, UINT64_C(0x4142434445464748));
#else
    cout << "No 64bit types available on this platform\n";
#endif

    cout << "generate(genint)\n";
    generate (v, &genint);
    PrintVector (v);
    v.assign (first, last);

    cout << "rotate(4)\n";
    rotate (v, 7);
    rotate (v, -3);
    PrintVector (v);
    v.assign (first, last);

    cout << "merge with (3,5,10,11,11,14)\n";
    const int c_MergeWith[] = { 3,5,10,11,11,14 };
    intvec_t vmerged;
    merge (v.begin(), v.end(), VectorRange(c_MergeWith), back_inserter(vmerged));
    PrintVector (vmerged);
    v.assign (first, last);

    cout << "inplace_merge with (3,5,10,11,11,14)\n";
    v.insert (v.end(), VectorRange(c_MergeWith));
    inplace_merge (v.begin(), v.end() - VectorSize(c_MergeWith), v.end());
    PrintVector (v);
    v.assign (first, last);

    cout << "remove(13)\n";
    remove (v, 13);
    PrintVector (v);
    v.assign (first, last);

    cout << "remove (elements 3, 4, 6, 15, and 45)\n";
    vector<uoff_t> toRemove;
    toRemove.push_back (3);
    toRemove.push_back (4);
    toRemove.push_back (6);
    toRemove.push_back (15);
    toRemove.push_back (45);
    typedef index_iterate<intvec_t::iterator, vector<uoff_t>::iterator> riiter_t;
    riiter_t rfirst = index_iterator (v.begin(), toRemove.begin());
    riiter_t rlast = index_iterator (v.begin(), toRemove.end());
    remove (v, rfirst, rlast);
    PrintVector (v);
    v.assign (first, last);

    cout << "unique\n";
    unique (v);
    PrintVector (v);
    v.assign (first, last);

    cout << "reverse\n";
    reverse (v);
    PrintVector (v);
    v.assign (first, last);

    cout << "lower_bound(10)\n";
    PrintVector (v);
    cout.format ("10 begins at position %zd\n", abs_distance (v.begin(), lower_bound (v, 10)));
    v.assign (first, last);

    cout << "upper_bound(10)\n";
    PrintVector (v);
    cout.format ("10 ends at position %zd\n", abs_distance (v.begin(), upper_bound (v, 10)));
    v.assign (first, last);

    cout << "equal_range(10)\n";
    PrintVector (v);
    TestEqualRange (v);
    v.assign (first, last);

    cout << "sort\n";
    reverse (v);
    PrintVector (v);
    random_shuffle (v);
    sort (v);
    PrintVector (v);
    v.assign (first, last);

    cout << "stable_sort\n";
    reverse (v);
    PrintVector (v);
    random_shuffle (v);
    stable_sort (v);
    PrintVector (v);
    v.assign (first, last);

    cout << "is_sorted\n";
    random_shuffle (v);
    const bool bNotSorted = is_sorted (v.begin(), v.end());
    sort (v);
    const bool bSorted = is_sorted (v.begin(), v.end());
    cout << "unsorted=" << bNotSorted << ", sorted=" << bSorted << endl;
    v.assign (first, last);

    cout << "find_first_of\n";
    static const int c_FFO[] = { 10000, -34, 14, 27 };
    cout.format ("found 14 at position %zd\n", abs_distance (v.begin(), find_first_of (v.begin(), v.end(), VectorRange(c_FFO))));
    v.assign (first, last);

    static const int LC1[] = { 3, 1, 4, 1, 5, 9, 3 };
    static const int LC2[] = { 3, 1, 4, 2, 8, 5, 7 };
    static const int LC3[] = { 1, 2, 3, 4 };
    static const int LC4[] = { 1, 2, 3, 4, 5 };
    cout << "lexicographical_compare";
    cout << "\nLC1 < LC2 == " << lexicographical_compare (VectorRange(LC1), VectorRange(LC2));
    cout << "\nLC2 < LC2 == " << lexicographical_compare (VectorRange(LC2), VectorRange(LC2));
    cout << "\nLC3 < LC4 == " << lexicographical_compare (VectorRange(LC3), VectorRange(LC4));
    cout << "\nLC4 < LC1 == " << lexicographical_compare (VectorRange(LC4), VectorRange(LC1));
    cout << "\nLC1 < LC4 == " << lexicographical_compare (VectorRange(LC1), VectorRange(LC4));

    cout << "\nmax_element\n";
    cout.format ("max element is %d\n", *max_element (v.begin(), v.end()));
    v.assign (first, last);

    cout << "min_element\n";
    cout.format ("min element is %d\n", *min_element (v.begin(), v.end()));
    v.assign (first, last);

    cout << "partial_sort\n";
    reverse (v);
    partial_sort (v.begin(), v.iat(v.size() / 2), v.end());
    PrintVector (v);
    v.assign (first, last);

    cout << "partial_sort_copy\n";
    reverse (v);
    buf.resize (v.size());
    partial_sort_copy (v.begin(), v.end(), buf.begin(), buf.end());
    PrintVector (buf);
    v.assign (first, last);

    cout << "partition\n";
    partition (v.begin(), v.end(), &is_even);
    PrintVector (v);
    v.assign (first, last);

    cout << "stable_partition\n";
    stable_partition (v.begin(), v.end(), &is_even);
    PrintVector (v);
    v.assign (first, last);

    cout << "next_permutation\n";
    buf.resize (3);
    iota (buf.begin(), buf.end(), 1);
    PrintVector (buf);
    while (next_permutation (buf.begin(), buf.end()))
	PrintVector (buf);
    cout << "prev_permutation\n";
    reverse (buf);
    PrintVector (buf);
    while (prev_permutation (buf.begin(), buf.end()))
	PrintVector (buf);
    v.assign (first, last);

    cout << "reverse_copy\n";
    buf.resize (v.size());
    reverse_copy (v.begin(), v.end(), buf.begin());
    PrintVector (buf);
    v.assign (first, last);

    cout << "rotate_copy\n";
    buf.resize (v.size());
    rotate_copy (v.begin(), v.iat (v.size() / 3), v.end(), buf.begin());
    PrintVector (buf);
    v.assign (first, last);

    static const int c_Search1[] = { 5, 6, 7, 8, 9 }, c_Search2[] = { 10, 10, 11, 14 };
    cout << "search\n";
    cout.format ("{5,6,7,8,9} at %zd\n", abs_distance (v.begin(), search (v.begin(), v.end(), VectorRange(c_Search1))));
    cout.format ("{10,10,11,14} at %zd\n", abs_distance (v.begin(), search (v.begin(), v.end(), VectorRange(c_Search2))));
    cout << "find_end\n";
    cout.format ("{5,6,7,8,9} at %zd\n", abs_distance (v.begin(), find_end (v.begin(), v.end(), VectorRange(c_Search1))));
    cout.format ("{10,10,11,14} at %zd\n", abs_distance (v.begin(), find_end (v.begin(), v.end(), VectorRange(c_Search2))));
    cout << "search_n\n";
    cout.format ("{14} at %zd\n", abs_distance (v.begin(), search_n (v.begin(), v.end(), 1, 14)));
    cout.format ("{13,13} at %zd\n", abs_distance (v.begin(), search_n (v.begin(), v.end(), 2, 13)));
    cout.format ("{10,10,10} at %zd\n", abs_distance (v.begin(), search_n (v.begin(), v.end(), 3, 10)));
    v.assign (first, last);

    cout << "includes\n";
    static const int c_Includes[] = { 5, 14, 15, 18, 20 };
    cout << "includes=" << includes (v.begin(), v.end(), VectorRange(c_Includes)-1);
    cout << ", not includes=" << includes (v.begin(), v.end(), VectorRange(c_Includes));
    cout << endl;

    static const int c_Set1[] = { 1, 2, 3, 4, 5, 6 }, c_Set2[] = { 4, 4, 6, 7, 8 };
    intvec_t::iterator setEnd;
    cout << "set_difference\n";
    v.resize (4);
    setEnd = set_difference (VectorRange(c_Set1), VectorRange(c_Set2), v.begin());
    PrintVector (v);
    assert (setEnd == v.end());
    cout << "set_symmetric_difference\n";
    v.resize (7);
    setEnd = set_symmetric_difference (VectorRange(c_Set1), VectorRange(c_Set2), v.begin());
    PrintVector (v);
    assert (setEnd == v.end());
    cout << "set_intersection\n";
    v.resize (2);
    setEnd = set_intersection (VectorRange(c_Set1), VectorRange(c_Set2), v.begin());
    PrintVector (v);
    assert (setEnd == v.end());
    cout << "set_union\n";
    v.resize (9);
    setEnd = set_union (VectorRange(c_Set1), VectorRange(c_Set2), v.begin());
    PrintVector (v);
    assert (setEnd == v.end());
    v.assign (first, last);
}
示例#13
0
//int qqq;
int addSequence(struct PROJ_DB *pDB, TreeNode **currentLevelp, ReverseHashTable *reverseTable)
{
	TreeNode   *pNode, *qNode;
	TreeNode *currentLevel=*currentLevelp;

	ReverseMap pMap;
	ReverseHashTable::iterator it, endit;


	int ret, myNumOfItems;

	
	/*printf("SSN: %d Item: %d\n", ++qqq, pDB->Item);

	if (qqq == 20496) {
		printf("hello\n");
	}*/

	

	//myNumOfItems=pDB->NumOfItems + pDB->m_nMaxSup - pDB->m_nSup;
	myNumOfItems=pDB->NumOfItems + pDB->m_nMaxSup;
	//myNumOfItems=pDB->NumOfItems;

	/*if (myNumOfItems == 3378012)
			printf("GUGU\n");
	*/


	pMap=(*reverseTable).equal_range(myNumOfItems);
	for (it=pMap.first, endit=pMap.second; it != endit; it++) {
		pNode=(*it).second;
		if (pNode->Support != pDB->m_nMaxSup)
			continue;
		ret=isContained_DBSizeEqual(pDB, currentLevel, pNode);
		switch (ret) {
			case 0:
				continue;
			case 1:  //Backward SubPattern
				//(*(currentLevel->Children)).push_back(pNode);
				//(*(currentLevel->IntraChildren))[pDB->Item]=pNode;
				//qNode is a mirror of pNode, but has slight different
				//the major goal is to let closed_maxPruning much easier
				qNode= new TreeNode();
				qNode= currentLevel->AddChildWithoutChecking( pDB->Item, pDB->ItemIsIntra, pDB->m_nMaxSup);
				qNode->SetProjDBSize(myNumOfItems);
				qNode->Children=pNode->Children;
				return EQUAL_PROJECT_DB_SIZE;

			case -1: //Backward SuperPattern

				qNode= new TreeNode(pNode);
				updateOldNodeInfo(pNode->Parent, pNode, qNode);

				if (pDB->ItemIsIntra) {
					updateNodeInfo(pNode, 
								   currentLevel->Items - pNode->Parent->Items,
								   currentLevel->ItemsetNumber - pNode->Parent->ItemsetNumber);
					//checkNodeInfo(currentLevel);
					pNode->ItemIsIntra=true;
					pNode->Parent=currentLevel;
					(*(currentLevel->Children)).push_back(pNode);
					inplace_merge((*(currentLevel->Children)).begin(), (*(currentLevel->Children)).end()-1, 
								  (*(currentLevel->Children)).end(), TreeNodeLess );
				}
				else {
					updateNodeInfo(pNode, 
								   currentLevel->Items - pNode->Parent->Items,
								   currentLevel->ItemsetNumber - pNode->Parent->ItemsetNumber);
					//checkNodeInfo(currentLevel);
					//pNode->Parent->Children->erase(pNode);
					pNode->ItemIsIntra=false;
					pNode->Parent=currentLevel;
					(*(currentLevel->Children)).push_back(pNode);
					inplace_merge((*(currentLevel->Children)).begin(), (*(currentLevel->Children)).end()-1, 
								  (*(currentLevel->Children)).end(), TreeNodeLess );

				}
				
				//reverseTable->erase(it);
				//reverseTable->insert(ReverseHashTable::value_type(myNumOfItems, qNode));
					
				return EQUAL_PROJECT_DB_SIZE;
			default:
				break;
		}
	}
	
	zzz++;
	pNode= new TreeNode();
	pNode= currentLevel->AddChildWithoutChecking( pDB->Item, pDB->ItemIsIntra, pDB->m_nMaxSup);
	pNode->SetProjDBSize(myNumOfItems);
	(*currentLevelp)=pNode;
	reverseTable->insert(ReverseHashTable::value_type(myNumOfItems, pNode));

	return INEQUAL_PROJECT_DB_SIZE;

}