Class OJ
 All Classes Functions
Static Public Member Functions | List of all members
OJ Class Reference

Static Public Member Functions

static void dump (bool v)
 
static void dump (double v)
 
static void dump (int v)
 
static void dump (string v)
 
static void dump (vector< char * > &v)
 
static void dump (vector< const char * > &v)
 
static void dump (const vector< double > &v)
 
static void dump (const vector< TreeNode * > &v)
 
static void dump (const TreeNode *v)
 
static void dump (const vector< TreeLinkNode * > &v)
 
static void dump (const TreeLinkNode *v)
 
static void dump (const ListNode *v)
 
static void dump (const vector< ListNode * > &v)
 
static void dump (const vector< int > &v)
 
static void dump (const int *v, const int size)
 
static void dump (const vector< int * > &v, const vector< int > v_size)
 
static void dump (const Interval &v)
 
static void dump (const vector< Interval > &v)
 
static void dump (const vector< vector< Interval > > &v)
 
static void dump (const vector< string > &v)
 
static void dump (const vector< vector< int > > &v)
 
static void dump (const vector< vector< string > > &v)
 
static void dump (const set< string > &v)
 
static void dump (const vector< set< string > > &v)
 
static void dump (const vector< char > &v)
 
static void dump (const vector< vector< char > > &v)
 
static void dump (const vector< vector< vector< char > > > &v)
 
static bool equal (bool a, bool b)
 
static bool equal (double a, double b)
 
static bool equal (int a, int b)
 
static bool equal (string a, string b)
 
static bool equal (const ListNode *a, const ListNode *b)
 
static bool equal (const vector< ListNode * > &a, const vector< ListNode * > &b)
 
static bool equal (vector< ListNode * > a, vector< ListNode * > b, bool _sort)
 
static bool equal (const TreeNode *a, const TreeNode *b)
 
static bool equal (vector< TreeNode * > &a, vector< TreeNode * > &b)
 
static bool equal (vector< TreeNode * > a, vector< TreeNode * > b, bool _sort)
 
static bool equal (const TreeLinkNode *a, const TreeLinkNode *b)
 
static bool equal (vector< TreeLinkNode * > &a, vector< TreeLinkNode * > &b)
 
static bool equal (vector< TreeLinkNode * > a, vector< TreeLinkNode * > b, bool _sort)
 
static bool equal (Interval &a, Interval &b)
 
static bool equal (vector< Interval > &a, vector< Interval > &b)
 
static bool equal (vector< Interval > a, vector< Interval > b, bool _sort)
 
static bool equal (vector< vector< Interval > > &a, vector< vector< Interval > > &b)
 
static bool equal (vector< vector< Interval > > a, vector< vector< Interval > > b, bool _sort)
 
static bool equal (vector< int > &a, vector< int > &b)
 
static bool equal (vector< int > a, vector< int > b, bool _sort)
 
static bool equal (vector< string > a, vector< string > b)
 
static bool equal (vector< string > a, vector< string > b, bool _sort)
 
static bool equal (vector< vector< int > > &a, vector< vector< int > > &b)
 
static bool equal (vector< vector< int > > a, vector< vector< int > > b, bool _sort)
 
static bool equal (vector< vector< string > > a, vector< vector< string > > b)
 
static bool equal (vector< vector< string > > a, vector< vector< string > > b, bool _sort)
 
static bool equal (const set< string > &a, const set< string > &b)
 
static bool equal (vector< set< string > > &a, vector< set< string > > &b)
 
static bool equal (vector< set< string > > a, vector< set< string > > b, bool _sort)
 
static void explode (vector< string > &in, const string &str, const char &ch)
 
static string ltrim (const string s)
 
static void read (const string &input, vector< char * > &in)
 
static void read (const string &input, vector< const char * > &in)
 
static void read (const string &input, vector< double > &in)
 
static void read (const string &input, vector< int > &in)
 
static void read (const string &input, vector< int * > &in, vector< int > &in_size)
 
static void read (const string &input, vector< ListNode * > &in)
 
static void read (const string &input, vector< string > &in)
 
static void read (const string &input, vector< TreeLinkNode * > &in)
 
static void read (const string &input, vector< TreeNode * > &in)
 
static void read (const string &input, vector< set< string > > &in)
 
static void read (const string &input, vector< vector< int > > &in)
 
static void read (const string &input, vector< vector< Interval > > &in)
 
static void read (const string &input, vector< vector< string > > &in)
 
static void read (const string &input, vector< vector< vector< char > > > &in)
 
static string rtrim (const string s)
 
static void sort_deep (vector< vector< Interval > > &a)
 
static void sort_deep (vector< vector< int > > &a)
 
static void sort_deep (vector< vector< string > > &a)
 
static void sort_vec (vector< ListNode * > &a)
 
static void sort_vec (vector< TreeNode * > &a)
 
static void sort_vec (vector< TreeLinkNode * > &a)
 
static void sort_vec (vector< Interval > &a)
 
static void sort_vec_vec (vector< vector< Interval > > &a)
 
static void sort_vec_vec (vector< vector< int > > &a)
 
static void sort_vec_vec (vector< vector< string > > &a)
 
static string trim (const string s)
 

Detailed Description

The OJ class includes utility functions to:

  1. read input (from string input into vector in)
  2. compare two objects, and
  3. dump/write an object.
  4. Some other utility functions: sort, explode, trim etc.
Author
Xin Chen
Version
0.9
Since
08/04/2013 - 08/09/2013

Member Function Documentation

static bool OJ::equal ( const vector< ListNode * > &  a,
const vector< ListNode * > &  b 
)
inlinestatic

Compare a and b, sort before comparing.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< ListNode * >  a,
vector< ListNode * >  b,
bool  _sort 
)
inlinestatic

Compare a and b, sort before comparing if _sort is true.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< TreeNode * > &  a,
vector< TreeNode * > &  b 
)
inlinestatic

Compare a and b, sort before comparing.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< TreeNode * >  a,
vector< TreeNode * >  b,
bool  _sort 
)
inlinestatic

Compare a and b, sort before comparing if _sort is true.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< TreeLinkNode * > &  a,
vector< TreeLinkNode * > &  b 
)
inlinestatic

Compare a and b, sort before comparing.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< TreeLinkNode * >  a,
vector< TreeLinkNode * >  b,
bool  _sort 
)
inlinestatic

Compare a and b, sort before comparing if _sort is true.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< Interval > &  a,
vector< Interval > &  b 
)
inlinestatic

Compare a and b, sort before comparing.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< Interval a,
vector< Interval b,
bool  _sort 
)
inlinestatic

Compare a and b, sort before comparing if _sort is true.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< vector< Interval > > &  a,
vector< vector< Interval > > &  b 
)
inlinestatic

Compare a and b, sort (on first level) before comparing.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< vector< Interval > >  a,
vector< vector< Interval > >  b,
bool  _sort 
)
inlinestatic

Compare a and b, sort (on first level) before comparing if _sort is true.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< int > &  a,
vector< int > &  b 
)
inlinestatic

Compare a and b, sort before comparing.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< int >  a,
vector< int >  b,
bool  _sort 
)
inlinestatic

Compare a and b, sort (on first level) before comparing if _sort is true.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< string >  a,
vector< string >  b 
)
inlinestatic

Compare a and b, sort before comparing.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< string >  a,
vector< string >  b,
bool  _sort 
)
inlinestatic

Compare a and b, sort before comparing if _sort is true.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< vector< int > > &  a,
vector< vector< int > > &  b 
)
inlinestatic

Compare a and b, sort (on first level) before comparing.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< vector< int > >  a,
vector< vector< int > >  b,
bool  _sort 
)
inlinestatic

Compare a and b, sort (on first level) before comparing if _sort is true.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< vector< string > >  a,
vector< vector< string > >  b 
)
inlinestatic

Compare a and b, sort (on first level) before comparing.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< vector< string > >  a,
vector< vector< string > >  b,
bool  _sort 
)
inlinestatic

Compare a and b, sort (on first level) before comparing if _sort is true.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( const set< string > &  a,
const set< string > &  b 
)
inlinestatic

Set uses internal (unspecified) order. If two sets have the same elements, the order should be the same.

static bool OJ::equal ( vector< set< string > > &  a,
vector< set< string > > &  b 
)
inlinestatic

Compare a and b, sort (on first level) before comparing.

Copies of a and b are used in sorting, the originals are not changed.

static bool OJ::equal ( vector< set< string > >  a,
vector< set< string > >  b,
bool  _sort 
)
inlinestatic

Compare a and b, sort (on first level) before comparing if _sort is true.

Copies of a and b are used in sorting, the originals are not changed.

static void OJ::explode ( vector< string > &  in,
const string &  str,
const char &  ch 
)
inlinestatic

Split a given string str by ch, store results in vector in.

static string OJ::ltrim ( const string  s)
inlinestatic

Remove spaces from the left side of input string.

static void OJ::read ( const string &  input,
vector< char * > &  in 
)
inlinestatic

Each input value is delimited by "|". Allows empty string. Spaces are not trimmed.

static void OJ::read ( const string &  input,
vector< const char * > &  in 
)
inlinestatic

Each input value is delimited by "|". Allows empty string. Spaces are not trimmed.

static void OJ::read ( const string &  input,
vector< double > &  in 
)
inlinestatic

Each input value is delimited by "|".

Spaces will be trimmed.

Empty value is not allowed (will be ignored).

static void OJ::read ( const string &  input,
vector< int > &  in 
)
inlinestatic

Each input value is delimited by "|".

Spaces will be trimmed.

Empty value is not allowed (will be ignored).

static void OJ::read ( const string &  input,
vector< int * > &  in,
vector< int > &  in_size 
)
inlinestatic

Spaces are trimmed.

Each input value is delimited by "|" on the first level, which represents an array of integers. An empty string represents an empty int array.

Each input value is delimited by "," on the second level, which represents an int value in an int array. Any empty string is ignored.

static void OJ::read ( const string &  input,
vector< ListNode * > &  in 
)
inlinestatic

Spaces are trimmed.

Each input value is delimited by "|" on the first level, which represents a linked list of integers. An empty string represents an empty tree.

Each input value is delimited by "," on the second level, which represents the int value of a node in a linked list. Any empty string is ignored.

static void OJ::read ( const string &  input,
vector< string > &  in 
)
inlinestatic

Each input value is delimited by "|".

Spaces are NOT trimmed.

static void OJ::read ( const string &  input,
vector< TreeLinkNode * > &  in 
)
inlinestatic

Spaces are trimmed.

Each input value is delimited by "|" on the first level, which represents a series of trees. An empty string represents an empty tree.

Each input value is delimited by "," on the second level, which represents the int value of a node in a tree.

static void OJ::read ( const string &  input,
vector< TreeNode * > &  in 
)
inlinestatic

Spaces are trimmed.

Each input value is delimited by "|" on the first level, which represents a series of trees.

Each input value is delimited by "," on the second level, which represents the int value of a node in a tree.

static void OJ::read ( const string &  input,
vector< set< string > > &  in 
)
inlinestatic

Each input value is delimited by "|" on the first level, which represents a series of sets.

Each input value is delimited by "," on the second level, which represents a int value in a set.

Spaces are NOT trimmed, since strings can contain start/end spaces.

static void OJ::read ( const string &  input,
vector< vector< int > > &  in 
)
inlinestatic

Each input value is delimited by "|" on the first level, which represents a series of vector<int> objects. Spaces are trimmed, and an empty string represents an empty vector.

Each input value is delimited by "," on the second level, which represents a int value in a vector<int> object. Spaces are trimmed, and empty strings are ignored.

static void OJ::read ( const string &  input,
vector< vector< Interval > > &  in 
)
inlinestatic

Each input value is delimited by "|" on the first level, which represents a series of vector<Interval> objects. Spaces are trimmed. An empty string represents an empty vectory.

Each input value is delimited by "," on the second level, which represents the paired int value of an Interval in a vector<Interval> object. Spaces are trimmed. Empty string is not allowed.

static void OJ::read ( const string &  input,
vector< vector< string > > &  in 
)
inlinestatic

Each input value is delimited by "|" on the first level, which represents a series of vector<string> objects.

Each input value is delimited by "," on the second level, which represents a string in a vector<string> object.

Spaces are NOT trimmed.

static void OJ::read ( const string &  input,
vector< vector< vector< char > > > &  in 
)
inlinestatic

Each input value is delimited by "|" on the first level, which represents a series of vector<vector<char> > objects. An empty string represents an empty vector.

Each input value is delimited by "," on the second level, which represents the values of a vector<char> object.

Spaces are NOT trimmed.

static string OJ::rtrim ( const string  s)
inlinestatic

Remove spaces from the right side of input string.

static void OJ::sort_deep ( vector< vector< Interval > > &  a)
inlinestatic

Sort on both first and second levels.

static void OJ::sort_deep ( vector< vector< int > > &  a)
inlinestatic

Sort on both first and second levels.

static void OJ::sort_deep ( vector< vector< string > > &  a)
inlinestatic

Sort on both first and second levels.

static void OJ::sort_vec ( vector< ListNode * > &  a)
inlinestatic

Sort a vector of lists (made of ListNode).

static void OJ::sort_vec ( vector< TreeNode * > &  a)
inlinestatic

Sort a vector of trees (made of TreeNode).

static void OJ::sort_vec ( vector< TreeLinkNode * > &  a)
inlinestatic

Sort a vector of trees (made of TreeLinkNode).

static void OJ::sort_vec ( vector< Interval > &  a)
inlinestatic

Sort a vector of Intervals.

First compare value of start, then compare value of end.

static void OJ::sort_vec_vec ( vector< vector< Interval > > &  a)
inlinestatic

Sort a vector of vector of Intervals (on vector<Interval> level).

First compare value of start, then compare value of end.

static void OJ::sort_vec_vec ( vector< vector< int > > &  a)
inlinestatic

Sort a vector of vector of int (on first level, i.e., vector<int> level).

static void OJ::sort_vec_vec ( vector< vector< string > > &  a)
inlinestatic

Sort a vector of vector of int (on first level, i.e., vector<int> level).

static string OJ::trim ( const string  s)
inlinestatic

Remove spaces from the left and right sides of input string.


The documentation for this class was generated from the following file: