Tuesday, June 26, 2012

R:: Visualize your inbox using R

I just found an interesting R script that can visualize your email inbox.

http://expansed.com/2011/08/sna-visualising-an-email-box-with-r/

Edit: The post has been moved to r-bloggers.com. http://www.r-bloggers.com/sna-visualising-an-email-box-with-r/ (Thanks to M Mouse for the updated link.)

The script creates a Graph using 'from' and 'to' addresses of the messages in your inbox. I din't have to do any modification in the script, it worked directly for me in my gmail.

This is how my inbox looks like!

Friday, June 22, 2012

c++:: Using namespace std; What does that mean?


Namespaces in C++ are used to define a scope and allows us to group global classes, functions and/or objects into one group.

When you use using namespace std; you are instructing C++ compiler to use the standard C++ library. If you don't give this instruction, then you will have to use std::, each time you use a standard C++ function/entity.

Have a look at the following example, which is very straight forward.

#include <iostream>

using namespace std;

class MyClass {
        public: void sayHello();
};

void MyClass::sayHello() {
     cout<<"Hello World!\n";
}

int main() {
       MyClass myClass;
       myClass.sayHello();
       return 0;
}

If you are not using namespace in the above example, you will have to use std:: everywhere you use cout, like the following.


#include <iostream>

class MyClass {
        public: void sayHello();
};

void MyClass::sayHello() {
        std::cout<<"Hello World!\n";
}

int main() {
       MyClass myClass;
       myClass.sayHello();
       return 0;
}

More about namespaces in C++

Namespaces allow you to group different entities together. You may create your own namespaces for grouping your entities, and access them the same way you did for 'std' namespace.


#include <iostream>

using namespace std;

namespace myAwesomeNamespace {
  int a=10, b;
}
namespace myAwesomerNamespace {
  int a=20, b;
}

int main() {
   cout<<"Awesome a = "<<myAwesomeNamespace::a;
   cout<<"Awesomer a = "<<myAwesomerNamespace::a;
   return 0;
}

You may also use using namespace with your custom namespces.


#include <iostream>

using namespace std;

namespace myAwesomeNamespace {
  int a=10, b;
}
namespace myAwesomerNamespace {
  int a=20, b;
}

int main() {
   using namespace myAwesomeNamespace;
   cout<<"Awesome a = "<<a;
   cout<<"Awesomer a = "<<myAwesomerNamespace::a;
   return 0;
}

Warning: If you use namepaces that have same entities grouped in it, then it will result in ambiguity error.

Related Posts Plugin for WordPress, Blogger...