Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using std::cout;
- using std::endl;
- #define N 30000
- typedef unsigned int uint;
- class Node;
- class Edge;
- std::vector<Node*> nodes;
- std::vector<Edge*> edges;
- class Node
- {
- public:
- Node(uint id): id(id)
- {
- nodes.push_back(this);
- }
- public:
- uint id;
- };
- class Edge
- {
- public:
- Edge(int nod1, int nod2)
- : nodH(nod1), nodT(nod2)
- {
- edges.push_back(this);
- }
- /*
- bool Connects(Node* nod1, Node* nod2)
- {
- return (
- (nod1->id == this->nodH && nod2->id == this->nodT) ||
- (nod1->id == this->nodT && nod2->id == this->nodH));
- }
- */
- public:
- int nodH;
- int nodT;
- };
- template< class T >
- void clearVector( std::vector< T > & v )
- {
- std::vector< T > dummy;
- std::swap( v, dummy );
- }
- struct die {
- template <class T> void operator()( const T * p ) const { delete p; }
- };
- template< class InputIterator >
- inline void kill_em_all( const InputIterator & begin, const InputIterator & end )
- {
- std::for_each( begin, end, die() );
- }
- int main()
- {
- Node *nd;
- for(long int i=0;i<N;i++)
- {
- for (int j=0;j<N;j++)
- {
- nd = new Node(j);
- }
- for (uint j=0;j<N;j++)
- {
- Edge* e = new Edge(j,N-j);
- }
- if ( i % 1000 == 0 ) {
- cout << i << endl;
- }
- //kill_em_all( nodes.begin(), nodes.end() );
- //kill_em_all( edges.begin(), edges.end() );
- //clearVector( nodes );
- //clearVector( edges );
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment