text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
to classes which implement the [`Shape`](http://java.sun.com/javase/6/docs/api/java/awt/Shape.html) interface. A list of classes implementing `Shape` can be found in the linked Java API specifications for the `Shape` interface.
For more information on how to use `AffineTransform` and Java 2D:
* [Trail: 2D Graphics](h... | [
0.5707853436470032,
-0.23661847412586212,
0.22424589097499847,
-0.0312952883541584,
-0.2909710109233856,
0.2282145470380783,
0.003028714330866933,
-0.34240058064460754,
0.14154088497161865,
-0.914679765701294,
-0.28204020857810974,
0.4705098867416382,
-0.04813994839787483,
-0.0810010209679... | |
I need to maintain a roster of connected clients that are very shortlived and frequently go up and down. Due to the potential number of clients I need a collection that supports fast insert/delete. Suggestions?
C5 Generic Collection Library
-----------------------------
The best implementations I have found in C# and ... | [
0.0529421903192997,
-0.019382935017347336,
0.44843772053718567,
-0.0015852372162044048,
-0.050064388662576675,
-0.11212088912725449,
0.17739376425743103,
-0.1495523899793625,
-0.3814525008201599,
-0.6000698804855347,
-0.05224859341979027,
0.4601524770259857,
0.1582481414079666,
0.112536132... | |
data-structures anyway these researchers have a [red-black-tree](http://en.wikipedia.org/wiki/Red-black_tree) implementation in their library, similar to what you find if you fire up Lütz reflector and have a look in System.Data's internal structures :p. Insert-complexity: O(log(n)).
Lock-free C++ collections
--------... | [
0.11183146387338638,
0.11440672725439072,
0.32784897089004517,
0.375460684299469,
-0.11768839508295059,
-0.08314456045627594,
0.18645982444286346,
-0.3005455732345581,
-0.41020306944847107,
-0.28369268774986267,
-0.4993683695793152,
0.2956101894378662,
-0.26617053151130676,
-0.097225748002... | |
put together. VC++ can do native C++ interop without annoying boundaries. [http://www.swig.org/](http://groups.google.com/group/lock-free) can otherwise help you wrap C++ interfaces for consumption in .Net, or you can do it yourself through P/Invoke.
Microsoft's Take
----------------
They have written tutorials, [thi... | [
0.35841354727745056,
0.047554969787597656,
0.3425983190536499,
0.18269675970077515,
-0.2714103162288666,
-0.16096380352973938,
0.14619815349578857,
-0.3662256598472595,
-0.4745050072669983,
-1.0414398908615112,
0.06693717837333679,
0.311275452375412,
-0.13202181458473206,
-0.11143892258405... | |
"linear" on search.
Google's perf-tools
-------------------
If you wish to speed up the time it takes for memory-allocation you can use google's perf-tools. They are available at google code and they contain a [very interesting multi-threaded malloc-implementation (TCMalloc)](http://goog-perftools.sourceforge.net/doc... | [
-0.151472270488739,
-0.22068466246128082,
0.49018916487693787,
0.474899560213089,
-0.10466577857732773,
-0.053249482065439224,
0.012233356013894081,
-0.000003819502126134466,
-0.36331385374069214,
-0.3746040463447571,
-0.21601919829845428,
0.5927914977073669,
-0.29623734951019287,
0.014562... | |
your own using the research which has been done on [bloom-filters](http://en.wikipedia.org/wiki/Bloom_filter), which allow O(k) lookup complexity where k is a constant that depends on the number of hash-functions you have implemented. This is how google's BigTable has been implemented. These filter will get you the ele... | [
0.025983523577451706,
-0.15719074010849,
0.18149276077747345,
0.07266698032617569,
0.03648986667394638,
-0.05097481235861778,
0.14222535490989685,
-0.03119043819606304,
-0.423455148935318,
-0.7903886437416077,
0.05283813923597336,
0.27416786551475525,
-0.22253361344337463,
-0.0642279610037... | |
for .Net implementations of this, but since the hashing calculations are independent you can use [MS's performance team's implementation of Tasks to speed that up.](http://blogs.msdn.com/pfxteam/archive/2008/06/02/8567093.aspx)
"My" take -- randomize to reach average O(log n)
------------------------------------------... | [
-0.07031223177909851,
-0.27522850036621094,
0.22040583193302155,
0.1559762954711914,
-0.13940508663654327,
-0.13766852021217346,
0.16199305653572083,
-0.40101367235183716,
-0.22668154537677765,
-0.7372021675109863,
-0.13502724468708038,
0.34650638699531555,
-0.2748996615409851,
-0.05168014... | |
allows you to very quickly O(1) in principle get a "hash"-to-value lookup of your data.
Random Binary Search Tree/Bloom Filter C++ code
-----------------------------------------------
I would really appreciate feedback if you find mistakes in the code, or just pointers on how I can do it better (or with better usage... | [
-0.24060110747814178,
-0.3910077214241028,
0.24516363441944122,
0.04427168890833855,
0.05125613510608673,
-0.3718770146369934,
0.020722521468997,
-0.03342171013355255,
0.03327915072441101,
-1.0088605880737305,
0.0646257996559143,
0.6886940002441406,
-0.2947574257850647,
-0.1924497783184051... | |
{countAdd=0; countDelete=0;countFind=0;}
virtual ~DataStructure() {}
void resetCountAdd() {countAdd=0;}
void resetCountFind() {countFind=0;}
void resetCountDelete() {countDelete=0;}
unsigned int getCountAdd(){return countAdd;}
unsigned int getCountDelete(){return countDelete;}
unsigned int... | [
-0.33307260274887085,
-0.2360641211271286,
0.6294926404953003,
-0.32905659079551697,
0.22509229183197021,
-0.00009026443876791745,
0.4074581563472748,
-0.526864230632782,
-0.09761221706867218,
-0.2761732339859009,
-0.5285675525665283,
0.6930387020111084,
-0.22674334049224854,
0.06862747669... | |
bool operator<(const string& other);
bool operator>(const string& other);
bool operator==(const string& other);
virtual ~Key() {}
};
#endif /*KEY_H_*/
```
**Key.cpp**
```
#include "Key.h"
bool Key::operator<(const string& other)
{
return compare(other) < 0;
};
bool Key::operator>(const string& ot... | [
-0.4199325442314148,
-0.36437246203422546,
0.6036954522132874,
-0.4174671471118927,
-0.02585768513381481,
0.02396145462989807,
0.19235333800315857,
-0.5941104292869568,
0.056754592806100845,
-0.5140778422355652,
-0.47691527009010315,
0.623185396194458,
-0.4506845474243164,
-0.1037305071949... | |
BloomFilter(unsigned long length){init(length);}
virtual ~BloomFilter(){}
void init(unsigned long length);
void dump();
void add(const Key& key);
void del(const Key& key);
/**
* Returns true if the key IS BELIEVED to exist, false if it absolutely doesn't.
*/
bool testExist(const... | [
0.10190335661172867,
-0.4659498929977417,
0.4147073030471802,
-0.45637938380241394,
0.2669062316417694,
-0.012494092807173729,
0.4954761862754822,
-0.25203195214271545,
0.15972580015659332,
-0.2604660391807556,
-0.42722088098526,
0.609417736530304,
-0.24822543561458588,
0.15342064201831818... | |
getHashAndIndicies(unsigned long& h1, unsigned long& h2, int& i1, int& i2, const Key& key);
void getCountIndicies(const int i1, const unsigned long h1,
const int i2, const unsigned long h2, int& i1_c, int& i2_c);
vector<unsigned long> m_tickBook;
vector<unsigned int> m_useCounts;
unsigned long ... | [
-0.250658243894577,
-0.23906724154949188,
0.4270310699939728,
-0.2493514120578766,
0.1683027744293213,
0.3243485391139984,
0.11168403178453445,
-0.67854905128479,
-0.21925605833530426,
-0.6183019280433655,
-0.4100272059440613,
0.32179564237594604,
-0.5391592383384705,
-0.30336228013038635,... | |
//m_length = length;
m_length = (unsigned long)((2.0*length)/log(2))+1;
m_pockets = (unsigned long)(ceil(double(m_length)/m_pocketSize));
m_tickBook.resize(m_pockets);
// my own (allocate nr bits possible to store in the other vector)
m_useCounts.resize(m_pockets * m_pocketSize);
unsigned long... | [
0.036712195724248886,
-0.19286370277404785,
0.6819826364517212,
-0.5327942967414856,
0.5594892501831055,
0.5772512555122375,
0.16050931811332703,
-0.7797255516052246,
-0.3760189116001129,
-0.6556721925735474,
-0.3118533194065094,
0.29163801670074463,
-0.14823605120182037,
-0.08391112089157... | |
hash = ((hash << 5) + hash) + key.c_str()[i]; /* hash * 33 + c */
}
double d_hash = (double) hash;
d_hash *= (0.5*(sqrt(5)-1));
d_hash -= floor(d_hash);
d_hash *= (double)m_length;
return (unsigned long)floor(d_hash);
}
unsigned long BloomFilter::hash2(const Key& key)
{
unsigned long has... | [
-0.22501429915428162,
-0.31601762771606445,
0.5291000008583069,
-0.5357621908187866,
0.2851666808128357,
0.1528686285018921,
0.22210821509361267,
-0.5565249919891357,
-0.45866715908050537,
-0.3599034547805786,
-0.3261468708515167,
0.38512858748435974,
-0.16810959577560425,
0.18385289609432... | |
hash;
}
double d_hash = (double) hash;
d_hash *= (0.5*(sqrt(5)-1));
d_hash -= floor(d_hash);
d_hash *= (double)m_length;
return (unsigned long)floor(d_hash);
}
bool BloomFilter::testExist(const Key& key, bool v){
if(exist(key)) {
if(v) cout<<"Key "<< key<<" is in the set"<<endl;
... | [
-0.3275285065174103,
-0.4138687551021576,
0.3553602993488312,
-0.5708137154579163,
0.40830570459365845,
0.005158079322427511,
0.38349953293800354,
-0.4613248407840729,
-0.04002942889928818,
-0.24871882796287537,
-0.5158323049545288,
0.33955931663513184,
-0.2654082179069519,
0.1761269420385... | |
false;
}
}
void BloomFilter::dump()
{
cout<<m_pockets<<" Pockets: ";
// I changed u to %p because I wanted it printed in hex.
unsigned long i; for(i=0; i< m_pockets; i++) printf("%p ", (void*)m_tickBook[i]);
cout<<endl;
}
void BloomFilter::add(const Key& key)
{
unsigned long h1, h2;
int i... | [
-0.12788036465644836,
-0.28570976853370667,
0.36508825421333313,
-0.3354407846927643,
0.32276344299316406,
0.4713784456253052,
0.27631545066833496,
-0.313637375831604,
0.020885640755295753,
-0.4578774571418762,
-0.2500694990158081,
0.2127501368522644,
-0.3449680507183075,
-0.11540112644433... | |
m_tickBook[i2] = m_tickBook[i2] | bitmask(h2);
m_useCounts[i1_c] = m_useCounts[i1_c] + 1;
m_useCounts[i2_c] = m_useCounts[i2_c] + 1;
countAdd++;
}
void BloomFilter::del(const Key& key)
{
unsigned long h1, h2;
int i1, i2;
int i1_c, i2_c;
if (!exist(key)) throw "You can't delete keys which... | [
-0.2148079127073288,
-0.47907018661499023,
0.5508403778076172,
-0.27018144726753235,
0.2104831486940384,
0.009244769811630249,
0.030033288523554802,
-0.49018606543540955,
-0.07629425078630447,
-0.48197072744369507,
-0.23223145306110382,
0.6530670523643494,
-0.23366495966911316,
0.034038711... | |
the index into the bitvector
// times the number of bits per vector item plus the offset into
// that same vector item.
getCountIndicies(i1, h1, i2, h2, i1_c, i2_c);
// We need to update the value in the bitvector in order to
// delete the key.
m_useCounts[i1_c] = (m_useCounts[i1_c] == 1 ? 0 : ... | [
-0.15498636662960052,
-0.24517299234867096,
0.7727526426315308,
0.1054019182920456,
0.08585791289806366,
0.3360356390476227,
-0.13769720494747162,
-0.5036129355430603,
-0.28782224655151367,
-0.5592464208602905,
-0.1918516308069229,
0.7123292088508606,
-0.2923343777656555,
0.008112728595733... | |
a specific bit, then set it to
// zero, by anding the complete unsigned long with the notted bitmask
// of the hash value
if (m_useCounts[i1_c] == 0)
m_tickBook[i1] = m_tickBook[i1] & ~(bitmask(h1));
if (m_useCounts[i2_c] == 0)
m_tickBook[i2] = m_tickBook[i2] & ~(bitmask(h2));
count... | [
-0.153520867228508,
-0.31969931721687317,
0.37721097469329834,
-0.48452967405319214,
0.17137688398361206,
-0.025664670392870903,
0.3897024989128113,
-0.5798795223236084,
0.21486419439315796,
-0.2676754891872406,
-0.40983930230140686,
0.46066728234291077,
-0.3942442834377289,
0.107897020876... | |
return ((m_tickBook[i1] & bitmask(h1)) > 0) &&
((m_tickBook[i2] & bitmask(h2)) > 0);
}
/*
* Gets the values of the indicies for two hashes and places them in
* the passed parameters. The index is into m_tickBook.
*/
void BloomFilter::getHashAndIndicies(unsigned long& h1, unsigned long& h2, int& i1,
... | [
-0.3858785033226013,
-0.6105279326438904,
0.5010570287704468,
-0.21531811356544495,
0.5020387768745422,
0.1814032644033432,
0.12601199746131897,
-0.3362569510936737,
-0.18131069839000702,
-0.6829061508178711,
-0.15927840769290924,
0.56342613697052,
-0.3103729486465454,
-0.18366408348083496... | |
into the count vector, which keeps
* track of how many times a specific bit-position has been used.
*/
void BloomFilter::getCountIndicies(const int i1, const unsigned long h1,
const int i2, const unsigned long h2, int& i1_c, int& i2_c)
{
i1_c = i1*m_pocketSize + h1%m_pocketSize;
i2_c = i2*m_pocketSize + h... | [
-0.2722207009792328,
-0.35439327359199524,
0.5527768731117249,
-0.46709996461868286,
0.5562206506729126,
0.3711537718772888,
0.22850996255874634,
-0.5320404767990112,
-0.2326696813106537,
-0.7376925945281982,
-0.46421313285827637,
0.3300960659980774,
-0.6331141591072083,
-0.127598211169242... | |
m_right = NULL;
m_size = 1U; // the size of one node is 1.
}
virtual ~RBSTNode(){}
string setKey(const Key& key){return Key(key);}
RBSTNode* left(){return m_left; }
RBSTNode* right(){return m_right;}
RBSTNode* setLeft(RBSTNode* left) { m_left = left; return this; }
RBSTNode* setRi... | [
-0.4383707046508789,
-0.4186493754386902,
0.8416202664375305,
-0.39096730947494507,
0.5523088574409485,
0.11206984519958496,
0.490721195936203,
-0.17966589331626892,
-0.36075034737586975,
-0.5229135155677795,
-0.5070653557777405,
0.6617376208305359,
-0.41195377707481384,
0.0726290270686149... | |
out << "Key(" << *this << ", m_size: " << m_size << ")";
return out;
}
#endif
unsigned int size() { return m_size; }
void setSize(unsigned int val)
{
#ifdef DEBUG
this->print(cout);
cout << "::setSize(" << val << ") called." << endl;
#endif
if (val == 0) throw "Cannot ... | [
-0.24177327752113342,
-0.224708691239357,
0.42299872636795044,
-0.5423175692558289,
0.46186214685440063,
0.06773025542497635,
0.25104841589927673,
-0.4418797791004181,
-0.30732211470603943,
-0.5373439788818359,
-0.40670064091682434,
0.33271142840385437,
-0.4830891788005829,
0.1812162995338... | |
m_size = val;
}
void incSize() {
#ifdef DEBUG
this->print(cout);
cout << "::incSize() called" << endl;
#endif
m_size++;
}
void decrSize()
{
#ifdef DEBUG
this->print(cout);
cout << "::decrSize() called" << endl;
#endif
if (m_size == 1) throw "Cannot... | [
-0.10506480187177658,
-0.09047896414995193,
0.5041500926017761,
-0.6494144797325134,
0.20742492377758026,
0.28258058428764343,
0.436359167098999,
-0.6298159956932068,
-0.3066815733909607,
-0.4853781461715698,
-0.5540618896484375,
0.6652091145515442,
-0.4266626834869385,
0.1598748415708542,... | |
just delete this node.";
m_size--;
}
#ifdef DEBUG
unsigned int size(RBSTNode* x);
#endif
private:
RBSTNode(){}
RBSTNode* m_left;
RBSTNode* m_right;
unsigned int m_size;
};
class RBST : public DataStructure
{
public:
RBST() {
m_size = 0;
m_head = NULL;
srand... | [
-0.22543644905090332,
-0.38605552911758423,
0.6687381267547607,
-0.3605639636516571,
0.6228005886077881,
0.1560242474079132,
0.6294800639152527,
-0.10646731406450272,
-0.2430792599916458,
-0.46959078311920166,
-0.36233410239219666,
0.5821159482002258,
-0.2925059497356415,
0.404466062784194... | |
Tries to add key into the tree and will return
* true for a new item added
* false if the key already is in the tree.
*
* Will also have the side-effect of printing to the console if v=true.
*/
bool add(const Key& key, bool v=false);
/**
* Same semantics as other add fu... | [
-0.0005675032734870911,
-0.13541337847709656,
0.3282080590724945,
-0.24604162573814392,
-0.10295949876308441,
0.14310942590236664,
0.47365817427635193,
-0.3111264109611511,
0.03697943314909935,
-0.4814029335975647,
-0.3072758913040161,
0.700236439704895,
-0.30250072479248047,
-0.2034048289... | |
string,
* but diff name, because that'll cause an ambiguity because of inheritance.
*/
bool addString(const string& key);
/**
* Deletes a key from the tree if that key is in the tree.
* Will return
* true for success and
* false for failure.
*
* Will also have... | [
-0.13272976875305176,
0.015279046259820461,
0.22629323601722717,
-0.32035598158836365,
0.1369696706533432,
-0.006435686722397804,
0.3977345824241638,
-0.12838584184646606,
-0.22503259778022766,
-0.3188629150390625,
-0.5804070234298706,
0.5070966482162476,
-0.20130765438079834,
0.2169823795... | |
side-effect of printing to the console if v=true.
*/
bool del(const Key& key, bool v=false);
/**
* Tries to find the key in the tree and will return
* true if the key is in the tree and
* false if the key is not.
*
* Will also have the side-effect of printing to the cons... | [
-0.09509694576263428,
-0.19994719326496124,
0.39664748311042786,
-0.15634967386722565,
0.04662228003144264,
0.1554480791091919,
0.16113348305225372,
-0.1278630793094635,
-0.3540786802768707,
-0.49826255440711975,
-0.26926809549331665,
0.8015366792678833,
0.008288045413792133,
-0.1063705086... | |
*/
bool find(const Key& key, bool v = false);
unsigned int count() { return m_size; }
#ifdef DEBUG
int dump(char sep = ' ');
int dump(RBSTNode* target, char sep);
unsigned int size(RBSTNode* x);
#endif
private:
RBSTNode* randomAdd(RBSTNode* target, const Key& key);
RBSTNode* addRoot(RBSTN... | [
-0.3268374800682068,
-0.4502749741077423,
0.2183918058872223,
-0.3220038115978241,
0.052866168320178986,
0.34968745708465576,
0.15937024354934692,
-0.28982681035995483,
-0.24918201565742493,
-0.32567456364631653,
-0.3888709545135498,
0.2792823910713196,
-0.2710658609867096,
0.2581500709056... | |
RBSTNode* find(RBSTNode* target, const Key& key);
RBSTNode* m_head;
unsigned int m_size;
};
#endif /*RBST_H_*/
```
\*\* RBST.cpp \*\*
```
#include "RBST.h"
bool RBST::add(const Key& key, bool v){
unsigned int oldSize = m_size;
m_head = randomAdd(m_head, key);
if (m_size > oldSize){
if(... | [
-0.10437726229429245,
-0.10564380139112473,
0.5769461393356323,
-0.44570815563201904,
0.2519473731517792,
0.1301230490207672,
0.1849929541349411,
-0.5147318243980408,
-0.2621695399284363,
-0.3917836844921112,
-0.5976683497428894,
0.45530882477760315,
-0.1636766940355301,
0.0087602082639932... | |
return false;
}
if(v) cout<<endl;
};
bool RBST::addString(const string& key) {
return add(Key(key), false);
}
bool RBST::del(const Key& key, bool v){
unsigned oldSize= m_size;
m_head = del(m_head, key);
if (m_size < oldSize) {
if(v) cout<<"Node "<<key<< " is deleted from the tree."<<en... | [
-0.03241700679063797,
-0.19420184195041656,
0.5821922421455383,
-0.5560780167579651,
0.07088353484869003,
0.18644866347312927,
0.13237550854682922,
-0.5355404615402222,
-0.4745370149612427,
-0.3147405683994293,
-0.731238603591919,
0.7439852952957153,
0.011061285622417927,
0.100979849696159... | |
return false;
}
};
bool RBST::find(const Key& key, bool v){
RBSTNode* ret = find(m_head, key);
if (ret == NULL){
if(v) cout<< "Node "<<key<< " is not in the tree."<<endl;
return false;
}else {
if(v) cout<<"Node "<<key<< " is in the tree."<<endl;
return true;
}
};
#i... | [
-0.038908716291189194,
-0.06361588090658188,
0.11839409172534943,
-0.3593684732913971,
0.09051268547773361,
0.2640799880027771,
0.6142473220825195,
-0.43523767590522766,
-0.03604961186647415,
-0.08550515025854111,
-0.45714202523231506,
0.5209947824478149,
-0.23388490080833435,
0.2886455357... | |
dump(m_head, sep);
cout<<"SIZE: " <<ret<<endl;
return ret;
};
int RBST::dump(RBSTNode* target, char sep){
if (target == NULL) return 0;
int ret = dump(target->left(), sep);
cout<< *target<<sep;
ret ++;
ret += dump(target->right(), sep);
return ret;
};
#endif
/**
* Rotates the tree aro... | [
-0.09034601598978043,
-0.21190547943115234,
0.5526406764984131,
-0.5325056910514832,
-0.012891802936792374,
0.4597305655479431,
0.148319274187088,
-0.288080632686615,
-0.4581538736820221,
-0.5173120498657227,
-0.41363006830215454,
0.2887457311153412,
-0.30457863211631775,
0.087936572730541... | |
/ \ right / \
* a ? ----> ? b
* / \ / \
* ? x | [
-0.03600573539733887,
0.43745651841163635,
0.15409547090530396,
-0.21539241075515747,
0.09935583919286728,
0.43829989433288574,
0.07071553170681,
0.19384263455867767,
0.16741551458835602,
-0.5001164078712463,
-0.5740070343017578,
0.0947781428694725,
-0.1461922973394394,
-0.0202334765344858... | |
x ?
*
*/
RBSTNode* RBST::rightRotate(RBSTNode* target) // private
{
if (target == NULL) throw "Invariant failure, target is null"; // Note: may be removed once tested.
if (target->left() == NULL) throw "You cannot rotate right around a target whose left node is NULL!";
#ifdef DEBUG
cout <<"Right-rot... | [
-0.026889517903327942,
0.020923413336277008,
0.3081175684928894,
-0.24522098898887634,
0.18465182185173035,
0.1392596811056137,
0.3009587824344635,
-0.17117048799991608,
-0.19050970673561096,
-0.25701311230659485,
-0.29511377215385437,
0.31189998984336853,
-0.626823365688324,
0.06864719092... | |
RBSTNode* l = target->left();
int as0 = l->size();
// re-order the sizes
l->setSize( l->size() + (target->right() == NULL ? 0 : target->right()->size()) + 1); // a.size += b.right.size + 1; where b.right may be null.
target->setSize( target->size() -as0 + (l->right() == NULL ? 0 : l->right()->size()) )... | [
0.08268449455499649,
-0.2757575213909149,
0.31184858083724976,
-0.5200185775756836,
0.2305746078491211,
0.3161928355693817,
0.25567662715911865,
-0.6180848479270935,
-0.183626189827919,
-0.1836930215358734,
-0.4700465202331543,
0.44630149006843567,
-0.4802560806274414,
-0.11092247068881989... | |
cout << "A-node size: " << l->size() << ", b-node size: " << target->size() << "." << endl;
#endif
// return the new root, a.
return l;
};
/**
* Like rightRotate, but the other way. See docs for rightRotate(RBSTNode*)
*/
RBSTNode* RBST::leftRotate(RBSTNode* target)
{
if (target == NULL) throw "Invari... | [
-0.51778644323349,
-0.19870196282863617,
0.45070797204971313,
-0.5554763674736023,
0.07175008952617645,
0.15890315175056458,
0.1279250532388687,
-0.0825478658080101,
-0.2190321534872055,
-0.39800766110420227,
-0.39295053482055664,
0.2669548988342285,
-0.4796639084815979,
-0.026685038581490... | |
cout << " for b-node ";
target->right()->print(cout);
cout << "." << endl;
#endif
RBSTNode* r = target->right();
int bs0 = r->size();
// re-roder the sizes
r->setSize(r->size() + (target->left() == NULL ? 0 : target->left()->size()) + 1);
target->setSize(target->size() -bs0 + (r->lef... | [
-0.10404161363840103,
-0.08372940123081207,
0.440608948469162,
-0.5986708402633667,
0.2308824211359024,
0.30992066860198975,
0.1755596548318863,
-0.4442940950393677,
-0.27879172563552856,
-0.34721118211746216,
-0.4533085525035858,
0.08498521894216537,
-0.5049300193786621,
-0.09474097192287... | |
r->setLeft(target);
#ifdef DEBUG
cout << "Left-rotation done: a-node size: " << target->size() << ", b-node size: " << r->size() << "." << endl;
#endif
return r;
};
//
/**
* Adds a key to the tree and returns the new root of the tree.
* If the key already exists doesn't add anything.
* Increments m_siz... | [
-0.13459619879722595,
-0.23543410003185272,
0.6813385486602783,
-0.49758586287498474,
0.11006823182106018,
0.19277407228946686,
0.35090920329093933,
-0.6564531326293945,
-0.270638644695282,
-0.3162606358528137,
-0.4060900807380676,
0.4782983362674713,
-0.5225304961204529,
0.121591858565807... | |
== NULL) return new RBSTNode(key);
#ifdef DEBUG
cout << "addRoot(";
cout.flush();
target->print(cout) << "," << key << ") called." << endl;
#endif
if (*target < key)
{
target->setRight( addRoot(target->right(), key) );
target->incSize(); // Should I?
RBSTNode* res = leftRot... | [
0.1042405515909195,
-0.4602198004722595,
0.41361203789711,
-0.3428092300891876,
0.3691914677619934,
0.1155586838722229,
0.3550386428833008,
-0.5958728790283203,
-0.19378075003623962,
-0.4794990122318268,
-0.27824899554252625,
0.6572797298431396,
-0.6005906462669373,
0.07728768140077591,
... | |
return res;
}
target->setLeft( addRoot(target->left(), key) );
target->incSize(); // Should I?
RBSTNode* res = rightRotate(target);
#ifdef DEBUG
if (target->size() != size(target))
BUG("in addRoot 2");
#endif
return res;
};
/**
* This function is called from the public add(key) functi... | [
-0.060301586985588074,
-0.638531506061554,
0.4658246636390686,
-0.43892189860343933,
0.24026501178741455,
0.17677395045757294,
0.4091641902923584,
-0.5453872084617615,
-0.27101650834083557,
-0.6500596404075623,
-0.23732586205005646,
0.4625457525253296,
-0.5748155117034912,
0.25521224737167... | |
m_size++;
return new RBSTNode(key);
}
#ifdef DEBUG
cout << "randomAdd(";
target->print(cout) << ", \"" << key << "\") called." << endl;
#endif
int r = (rand() % target->size()) + 1;
// here is where we add the target as root!
if (r == 1)
{
m_size++; // TODO: Need to lock... | [
-0.18647105991840363,
-0.2354232519865036,
0.5425237417221069,
-0.5766991972923279,
0.30541929602622986,
0.29810529947280884,
0.3804357051849365,
-0.6478837728500366,
-0.24216435849666595,
-0.3490661084651947,
-0.13877344131469727,
0.6223250031471252,
-0.36565783619880676,
0.38519367575645... | |
}
#ifdef DEBUG
printf("randomAdd recursion part, ");
#endif
// otherwise, continue recursing!
if (*target <= key)
{
#ifdef DEBUG
printf("target <= key\n");
#endif
target->setRight( randomAdd(target->right(), key) );
target->incSize(); // TODO: Need to lock.
#ifdef DEBUG
if ... | [
-0.17020705342292786,
-0.48042523860931396,
0.15675291419029236,
-0.24676692485809326,
0.39168617129325867,
-0.10072330385446548,
0.2641797959804535,
-0.33103498816490173,
-0.21759557723999023,
-0.41326817870140076,
-0.34058359265327454,
0.7102943658828735,
-0.6500785946846008,
0.074797160... | |
printf("target > key\n");
#endif
target->setLeft( randomAdd(target->left(), key) );
target->incSize(); // TODO: Need to lock.
#ifdef DEBUG
if (target->left()->size() != size(target->left()))
BUG("in randomAdd 2");
#endif
}
#ifdef DEBUG
printf("randomAdd return part\n");
#end... | [
-0.5421827435493469,
-0.4307609796524048,
0.2610147297382355,
-0.2819187045097351,
0.15976186096668243,
0.14467157423496246,
-0.053866274654865265,
-0.26898640394210815,
-0.23776695132255554,
-0.6658350229263306,
-0.3323923349380493,
0.46508270502090454,
-0.770148754119873,
-0.029632234945... | |
node.
* Decrements m_size if something was deleted.
*/
RBSTNode* RBST::del(RBSTNode* target, const Key& key)
{
countDelete++;
if (target == NULL) return NULL;
#ifdef DEBUG
cout << "del(";
target->print(cout) << ", \"" << key << "\") called." << endl;
#endif
RBSTNode* ret = NULL;
// found t... | [
-0.2531835436820984,
-0.484666645526886,
0.5611392855644226,
-0.42493677139282227,
0.11345931142568588,
0.2826237976551056,
0.26132962107658386,
-0.43141603469848633,
-0.4664774537086487,
-0.5280129313468933,
-0.34306126832962036,
0.3771335780620575,
-0.39828115701675415,
0.303271949291229... | |
delete target;
return ret; // return the newly built joined subtree!
}
// store a temporary size before recursive deletion.
unsigned int size = m_size;
if (*target < key) target->setRight( del(target->right(), key) );
else target->setLeft( del(target->left(), key) );
... | [
-0.12233448773622513,
-0.5932692289352417,
0.5404238104820251,
-0.3610970675945282,
0.05125254765152931,
0.12093794345855713,
0.20373791456222534,
-0.26836204528808594,
-0.4710361063480377,
-0.5767720937728882,
-0.49813327193260193,
0.4563687741756439,
-0.43373414874076843,
0.0723513215780... | |
if (m_size < size) target->decrSize();
#ifdef DEBUG
if (RBST::size(target) != target->size())
BUG("in del");
#endif
return target;
};
/**
* Joins the two subtrees represented by left and right
* by randomly choosing which to make the root, weighted on the
* size of the sub-tree.
*/
RBSTNode* RBST... | [
-0.3636581003665924,
-0.272565633058548,
0.27671191096305847,
-0.34918078780174255,
0.3290017247200012,
0.236055389046669,
0.10024818778038025,
-0.2891295850276947,
-0.47789302468299866,
-0.5710422992706299,
-0.3729250133037567,
0.39130738377571106,
-0.659717857837677,
0.03218997269868851,... | |
") called." << endl;
#endif
// Find the chance that we use the left tree, based on its size over the total tree size.
// 3 s.d. randomness :-p e.g. 60.3% chance.
bool useLeft = ((rand()%1000) < (signed)((float)left->size()/(float)(left->size() + right->size()) * 1000.0));
RBSTNode* subtree = NULL;
... | [
-0.04409480839967728,
-0.42287904024124146,
0.3732568919658661,
-0.1863260120153427,
0.1592337042093277,
0.031117992475628853,
0.478031724691391,
-0.6857250928878784,
-0.26438674330711365,
-0.28571587800979614,
-0.2777341306209564,
0.32939520478248596,
-0.2881443202495575,
0.15668088197708... | |
0 : left->left()->size())
+ subtree->size() + 1 );
#ifdef DEBUG
if (size(left) != left->size())
BUG("in join 1");
#endif
return left;
}
subtree = join(right->left(), left);
right->setLeft(subtree)
->setSize((right->right() == NULL ? 0 : right-... | [
-0.28556257486343384,
-0.40855759382247925,
0.32253381609916687,
-0.33950260281562805,
0.34228846430778503,
-0.1826595962047577,
0.32337629795074463,
-0.37216776609420776,
-0.34191709756851196,
-0.47205737233161926,
-0.5330089330673218,
0.2559819221496582,
-0.7954145073890686,
0.0485783219... | |
+ subtree->size() + 1);
#ifdef DEBUG
if (size(right) != right->size())
BUG("in join 2");
#endif
return right;
};
/////////////////////////////////////////////////////////////
///////////////////// FIND FUNCTIONS ///////////////////////
/////////////////////////////////////////////////////////////
/... | [
-0.26974722743034363,
-0.3557472229003906,
0.5308007597923279,
-0.3035942316055298,
-0.042248453944921494,
0.08559311926364899,
0.31977543234825134,
-0.6151943206787109,
-0.2383047491312027,
-0.3570529520511627,
-0.27134403586387634,
0.2462388575077057,
-0.8205538392066956,
-0.103369295597... | |
found.
if (*target == key) return target; // found (does string override ==?)
if (*target < key) return find(target->right(), key); // search for gt to the right.
return find(target->left(), key); // search for lt to the left.
};
#ifdef DEBUG
unsigned int RBST::size(RBSTNode* x)
{
if (x == NULL) retur... | [
-0.052487537264823914,
-0.03210128843784332,
0.27084892988204956,
-0.15889127552509308,
0.17134928703308105,
-0.04590192437171936,
0.34523701667785645,
-0.30166003108024597,
-0.0795210599899292,
-0.6850914359092712,
0.002565476344898343,
0.3525325357913971,
-0.4857442378997803,
-0.20651777... | |
as follows:
**Graph showing time taken to add new items for BloomFilter, RBST and SkipList.**
[graph http://haf.se/content/dl/addtimer.png](http://haf.se/content/dl/addtimer.png)
**Graph showing time taken to find items for BloomFilter, RBST and SkipList**
[graph http://haf.se/content/dl/findtimer.png](http://haf.se/... | [
-0.47868677973747253,
-0.3829348385334015,
0.39898017048835754,
-0.15532808005809784,
-0.37196457386016846,
0.17484158277511597,
-0.16303440928459167,
-0.33342283964157104,
-0.3366563618183136,
-0.738505482673645,
-0.04770989716053009,
0.2420724481344223,
-0.15585744380950928,
-0.082622215... | |
In java there is a possibility of re-throwing the exception but there is any advantage in it?
Sometimes, you want a specific type of Exception to be thrown by a method, but there are rare instances that cause other Exceptions to be thrown within the method. I often wrap the causal Exception with my desired Exception an... | [
0.004833744838833809,
-0.08858843147754669,
-0.37915024161338806,
-0.011661716736853123,
-0.13887308537960052,
-0.36436328291893005,
0.2670471668243408,
-0.0175471231341362,
-0.3381367623806,
-0.48560717701911926,
0.0619390644133091,
0.2833257019519806,
-0.4373476505279541,
-0.055143218487... | |
back in the stacktrace to see why. | [
0.08676259219646454,
0.1589636653661728,
0.2391563057899475,
-0.05210435763001442,
-0.06837998330593109,
-0.1376643180847168,
0.3766297996044159,
0.10037867724895477,
-0.6418887972831726,
-0.188902348279953,
-0.06307686120271683,
0.0649343729019165,
-0.007256165612488985,
0.050657309591770... | |
So I found [this](https://stackoverflow.com/questions/326919/disabling-button-with-javascript-ff-vs-ie/327152#327152) recommendation, but I can't quite seem to figure out how.
This is the code I originally started with:
```
function greySubmits(e) {
var value = e.srcElement.defaultValue;
// This doesn'... | [
0.04374200850725174,
-0.13774369657039642,
0.3086056411266327,
-0.21902726590633392,
0.27172374725341797,
-0.05150626599788666,
0.39167729020118713,
-0.5235095620155334,
-0.14505577087402344,
-0.6242281794548035,
-0.007769424468278885,
0.5584889054298401,
-0.46935415267944336,
0.0399791412... | |
$$("input[type='submit']").each(function(e) {
Event.observe(e, 'click', greySubmits);
});
});
```
Anyway, I am pretty close, but I can't seem to get any further.
Thanks for any help at all!
**Update**: Sorry, I guess I wasn't entirely clear. I'd like to disable all of the submit buttons when someone ... | [
0.24502180516719818,
0.14083509147167206,
0.20972546935081482,
-0.20294934511184692,
0.014138516038656235,
0.02167408913373947,
0.4233836531639099,
-0.1960391104221344,
0.14749163389205933,
-0.5964531898498535,
0.09154605865478516,
0.586969256401062,
-0.37313559651374817,
0.203493773937225... | |
on.) And then after disabling the submit buttons I need to call the containing form of the submit buttons submit call, as IE will not submit after you disable the button. Does that make sense?
I finally got it to work. Ryan helped so I'll upvote him :-) Here's the code:
```
function replaceSubmit(e) {
var el = e... | [
0.05990505963563919,
-0.12229970842599869,
0.44043272733688354,
-0.12253568321466446,
0.13105618953704834,
0.07675349712371826,
0.3860558271408081,
-0.33986592292785645,
0.14702557027339935,
-0.9470115900039673,
-0.28694814443588257,
0.7667457461357117,
-0.42883050441741943,
-0.05600082129... | |
return(false)
if (e.returnValue) {
$$("input[type='submit']").each(function(v) {v.disabled = true;})
}
}
function fixButtons() {
$$("input[type='submit']").each(function(v) {
if (Element.hasClassName(v, 'disabled')) {
v.disabled = true;
} else {
v.disabled = fa... | [
0.11759009212255478,
-0.3443574011325836,
0.13016214966773987,
-0.35760462284088135,
0.18688538670539856,
0.2568884789943695,
0.3399631977081299,
-0.4150038957595825,
-0.06042930856347084,
-0.49517491459846497,
-0.34220781922340393,
0.9123627543449402,
-0.3702827990055084,
-0.2461776733398... | |
fixButtons();
$$("input[type='submit']").each(function(e) {
Event.observe(e, 'click', replaceSubmit);
});
$$("form").each(function(e) {
Event.observe(e, 'submit', greySubmits);
});
});
```
The fixButtons is so that when people click the back button the page will fix... | [
0.1258091926574707,
-0.12546230852603912,
0.5728932023048401,
-0.18981237709522247,
0.21843920648097992,
0.3409571051597595,
0.2461257129907608,
-0.16996055841445923,
-0.1897413283586502,
-0.4132387936115265,
-0.39494454860687256,
0.8764629364013672,
-0.7428981065750122,
-0.178322315216064... | |
of disabled. | [
-0.0026814236771315336,
0.27549925446510315,
-0.22412116825580597,
-0.3669430911540985,
0.020675277337431908,
0.07988682389259338,
0.1514778435230255,
0.2965107560157776,
-0.4796440899372101,
-0.3671591579914093,
-0.47659364342689514,
0.44317203760147095,
-0.2890165448188782,
0.25187766551... | |
I have been wanting to make a RSS reader for a while now (just for fun), but I don't have the slightest idea of where to start. I don't understand anything about RSS. Are there any good tutorials on RSS and how to implement it in an application (not a tutorial on how to make a RSS reader, that would be too easy).
See
... | [
0.8120927810668945,
-0.04744558781385422,
0.24300949275493622,
-0.05356932803988457,
-0.3530804514884949,
-0.2646816074848175,
-0.11642549186944962,
0.23355790972709656,
-0.3449765145778656,
-0.6514621376991272,
0.08381621539592743,
0.4167265295982361,
-0.43345293402671814,
-0.034278143197... | |
feed and prints the title and author of all the items, for example. (Works for RSS 2.0 (not others!) or Atom.) | [
0.9877745509147644,
-0.042383141815662384,
0.2848489582538605,
0.2975865602493286,
-0.09986846148967743,
-0.5575205683708191,
-0.18598279356956482,
0.13449151813983917,
-0.08509281277656555,
-0.4344555139541626,
-0.3218078315258026,
0.14304696023464203,
-0.4575682282447815,
-0.123277500271... | |
I've got a web page that automatically reloads every few seconds and displays a different random image. When it reloads, however, there is a blank page for a second, then the image slowly loads. I'd like to continue to show the original page until the next page is loaded into the browser's memory and then display it al... | [
0.4576680362224579,
0.09722874313592911,
0.21065017580986023,
0.21528597176074982,
-0.017297709360718727,
-0.013024293817579746,
-0.022400708869099617,
0.2669942378997803,
-0.5835072994232178,
-0.597893476486206,
0.2453473061323166,
0.09799056500196457,
-0.17637130618095398,
0.270274579524... | |
body.onload() method I would then put the content where it needed to go.
Pre-AJAX that was a pretty good solution.
I'm just mentioning this for completeness. I'm not recommending it but it's worth noting that Ajax is not a prerequisite.
That being said, in your case where you're simply cycling an image, use Ajax or ... | [
0.43849629163742065,
-0.3812524974346161,
0.17737522721290588,
0.3715791702270508,
-0.3948120176792145,
-0.32527151703834534,
0.03887872397899628,
0.13996292650699615,
-0.18901295959949493,
-0.6907025575637817,
0.1789395660161972,
0.8712109923362732,
-0.056707147508859634,
-0.4991685450077... | |
I wish to write a windows service in .Net 2.0 that listens to and processes a Message Queue (MSMQ).
Rather than reinvent the wheel, can someone post an example of the best way to do it? It only has to process things one at a time, never in parallel (eg. Threads).
Essentially I want it to poll the queue, if there's an... | [
0.27825120091438293,
-0.10169791430234909,
0.14162451028823853,
0.021871602162718773,
-0.15748952329158783,
-0.1558409035205841,
0.060506269335746765,
0.21114526689052582,
-0.24786455929279327,
-0.5907977223396301,
0.01972764916718006,
0.2818942666053772,
-0.322443425655365,
0.164745643734... | |
integer and floating-point operations may take place. In numerical promotion, byte, char, and short values are converted to int values. The int values are also converted to long values, if necessary. The long and float values are converted to double values, as required. | [
-0.28779277205467224,
0.028413474559783936,
-0.042534831911325455,
0.09764238446950912,
0.09048377722501755,
0.3218299448490143,
-0.2449449598789215,
-0.08173983544111252,
-0.2901201844215393,
0.00878105964511633,
-0.5732205510139465,
0.49579617381095886,
-0.0051124985329806805,
-0.0714421... | |
Does anyone know how to reset the border color of an input control once you have modified it using javascript? Useful for validation by highlighting fields that have incorrect or invalid data in them etc.
E.g. changing the border:
```
document.getElementById('myinput').style.border = '1px solid red';
```
how to re... | [
0.4021337330341339,
0.15315409004688263,
0.5400171875953674,
0.15488845109939575,
0.18700991570949554,
-0.2278272658586502,
0.3639775812625885,
0.12877465784549713,
-0.3067108392715454,
-0.7081125974655151,
-0.10857396572828293,
0.5012803673744202,
-0.20823797583580017,
-0.0929048508405685... | |
also recommend using a Javascript library to handle this. It just makes the code cleaner.
Removing CSS attributes is problematic because you don't always know what they should be set back to. Adding and removing classes just... works.
You can have multiple classes per element so there's really no argument against doi... | [
0.1947389841079712,
-0.044503357261419296,
0.2881588637828827,
-0.0991334468126297,
-0.22992607951164246,
-0.08906717598438263,
0.29119688272476196,
-0.20632049441337585,
-0.34487614035606384,
-0.8248188495635986,
-0.007920334115624428,
0.5926989316940308,
-0.43487241864204407,
0.043249297... | |
I want to implement a File Explorer, It is different from a normal file explorer, it first scan file system and store information into database, them read file system information from Database, and display them, I need to store the icons of the file, how can I do this? Is there any Windows APIs?
Many thanks!
[SHGetFile... | [
0.3403928577899933,
0.009470125660300255,
0.22585445642471313,
0.12752148509025574,
-0.030376579612493515,
-0.12466933578252792,
0.32077038288116455,
-0.03543799743056297,
-0.3367561995983124,
-0.7328217625617981,
0.0980692133307457,
0.3273034393787384,
-0.12658680975437164,
0.312913119792... | |
Newbie IIS question:
I want to setup HTTPS access for my XHTML page (not asp.net) hosted on my IIS 6.0 server. So far I have done the following:
In IIS Manager, for the particular folder, the following are set:
* Require secure channel (SSL)
* Require 128 bit encryption
* Ignore client certificates
However when I... | [
0.23185910284519196,
-0.02185031771659851,
0.5042411684989929,
-0.3123806118965149,
0.0063454024493694305,
-0.30316904187202454,
0.37833839654922485,
-0.2847803235054016,
0.05347685515880585,
-1.016344428062439,
-0.02168847993016243,
0.5762127041816711,
-0.5036114454269409,
0.3060897290706... | |
server?**
[Here](http://support.microsoft.com/kb/299875) are the official instructions for setting up SSL in IIS. You can find directions [here](http://codeforeternity.com/blogs/technology/archive/2008/02/15/creating-self-signed-ssl-certificates-on-iis-6-0-and-windows-server-2003.aspx) for creating a self signed certif... | [
0.2646997272968292,
-0.07244817912578583,
0.5683527588844299,
-0.022311383858323097,
-0.20097768306732178,
-0.5442460775375366,
0.5037803053855896,
-0.1121051087975502,
-0.22241871058940887,
-0.5019168257713318,
-0.17757298052310944,
0.09603190422058105,
-0.1996421366930008,
0.001230739988... | |
from my controller I want to assign a value to an application variable much like I would a session variable.
I assumed I could just use:
```
Application("MyValue") = "test"
```
```
HttpContext.Application["MyValue"] = test
``` | [
0.19728828966617584,
-0.1346013993024826,
0.28815850615501404,
0.08802048116922379,
0.12371623516082764,
-0.11300449818372726,
0.11638709902763367,
-0.09264630824327469,
0.1147208958864212,
-0.6245096325874329,
-0.02737668715417385,
0.37700459361076355,
-0.2915835678577423,
0.2019535750150... | |
I am trying to get call one of my classes attribute writers, but for some reason it never gets called. Here's some code that'll make this clearer:
```
class Test
attr_reader :test
def test=(val)
puts 'Called'
@test = val
end
def set_it(val)
test = val
end
end
obj = Test.new
obj.set_it 5
puts o... | [
0.2779908776283264,
0.23265685141086578,
0.059380076825618744,
-0.23699742555618286,
-0.058731600642204285,
-0.02733476087450981,
0.5335709452629089,
-0.062287576496601105,
0.07861161977052689,
-0.604938268661499,
-0.009181223809719086,
0.47716471552848816,
-0.24746586382389069,
0.13790497... | |
it. So the question is much more generalized now.
You're doing nothing "wrong" per se. Ruby just thinks you intend to set the local variable test to val, not call the `test=` method. `self.test = val` will do what you expect. | [
0.45073622465133667,
-0.146564319729805,
-0.1290092021226883,
0.21966814994812012,
-0.06539278477430344,
-0.21903380751609802,
0.6448014974594116,
0.003651637816801667,
0.001640554517507553,
-0.09372451156377792,
-0.062400322407484055,
0.7283058166503906,
-0.1303011029958725,
0.04164078831... | |
In Perl (and other languages) a conditional ternary operator can be expressed like this:
```
my $foo = $bar == $buz ? $cat : $dog;
```
Is there a similar operator in VB.NET?
Depends upon the version. The `If` operator in VB.NET 2008 is a ternary operator (as well as a null coalescence operator). This was just introd... | [
-0.15204253792762756,
-0.4071367084980011,
0.38898757100105286,
-0.3559156656265259,
-0.3729265332221985,
0.04771578311920166,
0.22209249436855316,
-0.19863787293434143,
-0.02562767080962658,
-0.04121936485171318,
-0.28175556659698486,
0.38320261240005493,
-0.5664337277412415,
0.0457899868... | |
dog)
``` | [
0.2508395314216614,
0.6591559052467346,
0.10488560050725937,
-0.32156679034233093,
-0.03297180309891701,
0.18448041379451752,
0.779724657535553,
-0.14142107963562012,
-0.01668228581547737,
-0.32689329981803894,
-0.4719368517398834,
0.6348822116851807,
-0.7384323477745056,
0.099747762084007... | |
In [this thread](https://stackoverflow.com/questions/576185/logging-best-practices) many people have indicated that they use log4net. I am a fan of TraceSources and would like to know why log4net is used.
Here is why I like trace sources:
* Pluggable listeners - XML, TextFile, Console, EventLog, roll your own
* Cust... | [
0.5401822328567505,
-0.0186375230550766,
0.16321218013763428,
0.22364814579486847,
0.14673955738544464,
-0.28222110867500305,
0.31674131751060486,
0.01078415010124445,
-0.40884655714035034,
-0.5920122861862183,
0.30972036719322205,
0.1935204267501831,
-0.36509016156196594,
-0.0876264870166... | |
app.config/web.config.
Since the .NET framework internally uses TraceSources, it also gives me a consistent way of configuring tracing - with log4net, I have to configure log4net as well as TraceSources.
What does log4net give me that TraceSources don't (or that couldn't be done by writing a couple of custom TraceLi... | [
0.6452593207359314,
0.22935818135738373,
0.39767616987228394,
0.061980247497558594,
-0.01775474287569523,
-0.21157769858837128,
0.1251743733882904,
-0.23517122864723206,
-0.3579975664615631,
-0.6719315648078918,
0.13163189589977264,
0.7251167297363281,
-0.548837423324585,
-0.18517999351024... | |
my favourite values for the colored console appender.
If I may be so bold - my colored console happiness:
```
<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
<!-- Can Use:
Blue
Green
Red
White
Yellow
Purple
Cyan
Hig... | [
-0.4357832074165344,
-0.029899638146162033,
0.5355912446975708,
0.05140189453959465,
0.04163333773612976,
0.30584049224853516,
0.01855102926492691,
0.3308121860027313,
-0.14337162673473358,
-0.7040694952011108,
-0.07746098190546036,
0.6508772373199463,
0.014941475354135036,
-0.071504287421... | |
value="Yellow, HighIntensity" />
<backColor value="Red" />
</mapping>
<mapping>
<level value="ERROR" />
<foreColor value="White" />
<backColor value="Purple, HighIntensity" />
</mapping>
<mapping>
<level value="WARN" />
<backColor value="Blue" />
<foreColor value="White" />
</mapping>
<mapping>
<level v... | [
-0.43300682306289673,
-0.05629735812544823,
0.09054973721504211,
0.11784768849611282,
-0.025254862383008003,
0.22358888387680054,
0.7053192853927612,
-0.3787825107574463,
-0.16819602251052856,
-0.633036732673645,
-0.2230742871761322,
0.46990957856178284,
-0.2535777688026428,
-0.19337742030... | |
I actually miss is AUDIT for who-did-what logging.
Customisable configuration: I use a log4net.config file which I load up at runtime (or write a log to c:\ whining that I can't find the config.)
```
Try
' Get log4net configuration from file
Dim logConfigFile As FileInfo
logConfigFile = Ne... | [
0.2507363259792328,
-0.25275957584381104,
0.11590638011693954,
0.07641320675611496,
0.13653206825256348,
-0.20981533825397491,
0.7581197023391724,
-0.1798022836446762,
-0.3326267898082733,
-0.5798102617263794,
0.06835940480232239,
0.48667681217193604,
-0.36744269728660583,
0.13995485007762... | |
Else
CreateEmergenceLogFile(logConfigFile.FullName)
End If
Catch ex As Exception
Console.Out.WriteLine("Could not load the log4net config file")
End Try
```
just a big set of TraceListeners: sorry skipping that one - I'll take your word for it.
Correlation of activities/scopes: d... | [
0.36844101548194885,
-0.28826746344566345,
0.08631718903779984,
0.10336752235889435,
-0.025793548673391342,
-0.46411603689193726,
0.4181603491306305,
-0.14147165417671204,
-0.5240353941917419,
-0.5521012544631958,
0.07638457417488098,
0.48795947432518005,
-0.2888605296611786,
0.08401450514... | |
truth may have grown to do too much ...)
In a class file:
```
Private Shared _logger As log4net.ILog = _
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
Private Shared _loggerAttribute As log4net.ILog = _
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCur... | [
0.2849303185939789,
0.19117297232151031,
0.2348334789276123,
0.3072797358036041,
-0.10521351546049118,
-0.13039009273052216,
0.7624767422676086,
-0.2948033809661865,
0.00227350858040154,
-0.510322630405426,
0.14368537068367004,
0.7299004793167114,
0.02885257452726364,
0.12941671907901764,
... | |
just my own little usage tricks.
hth,
-Mike | [
0.5930250883102417,
0.43056491017341614,
0.43906474113464355,
-0.053645044565200806,
0.2539430260658264,
0.11593051254749298,
0.3639068305492401,
0.1605885773897171,
-0.2198294997215271,
-0.3179990351200104,
0.1666071116924286,
0.6006962656974792,
0.0005242432234808803,
-0.1274487525224685... | |
In java, im creating a SortedSet from a list which is always going to be ordered (but is only of type ArrayList). I figure adding them one by one is going to have pretty poor performance (in the case for example of an AVL tree), as it will have to reorder the tree a lot.
my question is, how *should* i be creating thi... | [
-0.08220407366752625,
-0.23637385666370392,
-0.08137021958827972,
-0.4197748601436615,
-0.44649603962898254,
-0.08464739471673965,
0.008906284347176552,
-0.3411957323551178,
-0.35789889097213745,
-0.7364806532859802,
0.1442449390888214,
0.338936448097229,
-0.7637133598327637,
-0.1654555648... | |
poor performance wont affect me too much anyway (too small amount of data), but im still interested in how it would be done in a general case.
A set having a tree implementation would have the middle element from your list in the top. So the algorithm would be as following:
1. find the middle element of the List
2. in... | [
-0.004772133659571409,
-0.21306684613227844,
0.15073996782302856,
0.023675359785556793,
0.05329763889312744,
-0.04993831366300583,
0.32187581062316895,
-0.4401748478412628,
0.1796797513961792,
-0.46481549739837646,
0.01980818808078766,
0.38589566946029663,
-0.3000682294368744,
-0.493985861... | |
Ok the output is supposed to look like this:
```
./a 3 4 8 2
3
4
8
2
```
This is what I have so far, but I am lost and can only get the first integer to print (we have to use GetInt, which gets the specified integer in the string):
```
int main (int argc, char*argv []){
int v;
int i;
i ... | [
-0.06485062092542648,
0.09909839183092117,
0.5642217993736267,
-0.30913734436035156,
0.13962168991565704,
-0.05989120155572891,
0.40109267830848694,
-0.2949257493019104,
-0.16663135588169098,
-0.43558934330940247,
-0.22225385904312134,
0.7144551873207092,
-0.37701907753944397,
0.2577455937... | |
1){
printf("%d\n", GetInt(argc, argv, i));
}
return 0;
}
```
Without actually seeing your implementation of GetInt, something like this (Assumes C90):
```
#include <stdio.h>
int GetInt( int argc, char* argv[], int i ) {
/*
* you may want to use sscanf, strtol or other functions,
... | [
0.09981770813465118,
-0.32558929920196533,
0.19704462587833405,
-0.21337921917438507,
-0.08159103989601135,
-0.09930244088172913,
0.28749510645866394,
-0.47602587938308716,
-0.1253807097673416,
-0.6723453998565674,
-0.2483687698841095,
0.7338644862174988,
-0.854103147983551,
-0.26512011885... | |
int i;
for ( i = 1; i < argc; ++i ) {
printf( "%d\n", GetInt( argc, argv, i ) );
}
return 0;
}
```
Returns:
```
$ ./a.out 3 4 8 2
3
4
8
2
```
Error checking omitted and such. It is an exercise to you to figure out how to deal with non-decimal arguments. | [
-0.24445657432079315,
0.20055411756038666,
0.18137234449386597,
-0.38771551847457886,
-0.09005926549434662,
0.2623448073863983,
0.09553742408752441,
-0.37831318378448486,
0.07431558519601822,
-0.26377227902412415,
-0.2825484871864319,
0.5572195053100586,
-0.1463703215122223,
0.068252936005... | |
I'm working on a Web app where users need to input a date and time. I've used this calendar widget before and it works fine:
<http://www.dynarch.com/projects/calendar/>
However, it hasn't been updated since 2005. I'm wondering if anyone knows of a better one.
The calendar in jQuery UI doesn't handle times. Only date... | [
0.3693874180316925,
-0.11327158659696579,
0.19730453193187714,
0.10042940080165863,
-0.07994572073221207,
0.29820069670677185,
-0.34468162059783936,
0.3255250155925751,
-0.4619777500629425,
-0.9250290393829346,
0.6440659761428833,
0.1957097053527832,
0.3216687738895416,
0.35552307963371277... | |
[ClockPick](http://www.jnathanson.com/index.cfm?page=jquery/clockpick/ClockPick) and [datePicker](http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/). Both are [jQuery](http://jquery.com) plugins, work great across browsers, and are very easy to customize. | [
0.39771464467048645,
-0.36459678411483765,
0.4329044818878174,
0.002405287232249975,
0.44262567162513733,
0.14820685982704163,
-0.13758526742458344,
-0.048490580171346664,
-0.27945438027381897,
-0.4067939519882202,
-0.28444918990135193,
0.4204007685184479,
0.30207929015159607,
-0.110852584... | |
If I learn python 3.0 and code in it, will my code be still compatible with Python 2.6 (or 2.5 too!)?
---
Remarkably similar to:
[If I'm Going to Learn Python, Should I Learn 2.x or Just Jump Into 3.0?](https://stackoverflow.com/questions/410609/if-im-going-to-learn-python-should-i-learn-2-x-or-just-jump-into-3-0/41... | [
0.38356515765190125,
-0.05220872536301613,
0.26035982370376587,
-0.013184492476284504,
-0.022369634360074997,
-0.47121870517730713,
0.3651100993156433,
-0.01980508118867874,
-0.17120909690856934,
-0.6353907585144043,
-0.1387932002544403,
0.703436553478241,
0.06899576634168625,
-0.156778708... | |
a real pain).
Just start learning 2.6. The infrastructure is there now, and there's plenty of help for when you finally want to move to 3.x. 2.x is not going away: there will be a 2.7 release at some point, so you're not going to be out of luck if you learn 2.6 now. | [
0.21400390565395355,
-0.09553007036447525,
0.5123306512832642,
0.1935766190290451,
-0.09917537122964859,
-0.14996971189975739,
0.5085914134979248,
0.17010284960269928,
-0.17996826767921448,
-0.7501131296157837,
-0.050071123987436295,
0.6945340037345886,
0.14862160384655,
0.1797627061605453... | |
Most of my application is written in PHP ((Front and Back ends).
There is a part that works too slowly and I will need to rewrite it, probably not in PHP.
What will give me the following:
1. Most speed
2. Fastest development
3. Easily maintained.
I have in my mind to rewrite this piece of code in CPP as a PH... | [
0.040285829454660416,
0.4694824814796448,
0.4454716444015503,
0.19906839728355408,
0.02401818335056305,
0.016003882512450218,
0.6360906958580017,
-0.11307711899280548,
-0.28276288509368896,
-0.7291982173919678,
0.29455119371414185,
0.38181206583976746,
0.01616000197827816,
-0.0827219337224... | |
it is.
**If it is a long running process (at least seconds)** then perhaps an external program written in C++ would be super easy. It would not have the complexities of a PHP extension and it's stability would not affect PHP/apache. You could communicate over pipes, shared memory, or the sort...
**If it is a short ru... | [
0.3583953082561493,
-0.31424498558044434,
0.4553348124027252,
0.2497023642063141,
-0.2558633089065552,
-0.209073007106781,
0.30802321434020996,
0.02838193066418171,
-0.14948324859142303,
-0.8322230577468872,
-0.13504989445209503,
0.5515047907829285,
-0.04976309835910797,
0.0669431015849113... | |
to PHP when PHP asks for information. Then your per-call overhead is basically creating a socket (not bad). The server could be in any language (c, c++, python, erlang, etc...), and the client could be a 50 line PHP class that uses the socket\_\*() functions.
---
A lot of information needs evaluated before making thi... | [
0.3001016676425934,
-0.09081095457077026,
0.2679584324359894,
0.370827317237854,
-0.37230515480041504,
-0.020048223435878754,
0.22318147122859955,
-0.059455566108226776,
-0.2354939579963684,
-0.35941028594970703,
-0.09346664696931839,
0.36295440793037415,
-0.32014206051826477,
0.0466383434... | |
to write it in PHP?
* Are you database bound?
* Is it CPU bound, Network bound, or IO bound?
* Can the result be cached?
* Does a library already exist which will do the heavy lifting.
---
By committing to a custom PHP extension, you add significantly to the base of knowledge required to maintain it (even above C++).... | [
0.48193860054016113,
0.13229073584079742,
0.13994461297988892,
0.28674885630607605,
-0.12376553565263748,
-0.3016666769981384,
0.2673845589160919,
0.04312383383512497,
-0.22210270166397095,
-0.5115537047386169,
0.11174768954515457,
0.46741294860839844,
-0.12416926771402359,
-0.439166754484... | |
I'm trying to use select on STDIN and a TCP socket in Ruby, but for some reason, the value returned from select never seems to match one of the choices; it looks like it's the socket that's being returned, but it doesn't match using == (or equal?). Can anyone tell me why the result returned from select doesn't match th... | [
0.34187808632850647,
0.1933874934911728,
0.30474603176116943,
-0.153631329536438,
-0.31182587146759033,
-0.07950153946876526,
0.4093986749649048,
-0.22266244888305664,
-0.21287696063518524,
-1.0137473344802856,
0.027023568749427795,
0.41557058691978455,
-0.45082446932792664,
0.576469361782... | |
puts "Reading from STDIN"
execute_command
elsif results[0] == server
puts "Reading from server"
receive_data
else
puts "Something's wrong... results[0]: #{results[0]}, server: #{server}"
puts "IDs: results[0]: #{results[0].__id__}, server: #{server.__id__}"
exit 1
end
end
```
Here's what... | [
-0.03566746413707733,
0.28848591446876526,
0.4338809549808502,
-0.40328049659729004,
-0.2743561565876007,
0.11959594488143921,
0.4365220367908478,
-0.35051271319389343,
-0.0581652969121933,
-0.7849835753440857,
0.19952738285064697,
0.33102285861968994,
-0.15309131145477295,
-0.052475422620... | |
objects that are ready. So you should compare the STDIN and server to results[0][0]. Or better check, if the socket is in the results Array
```
...
if results[0].include? STDIN
...
elsif results[0].include? server
...
...
``` | [
-0.04412714019417763,
-0.09620140492916107,
0.2761474847793579,
0.07606194913387299,
-0.10214134305715561,
0.05150843784213066,
0.0013625443680211902,
-0.19074848294258118,
-0.22754986584186554,
-0.7403146624565125,
-0.18842104077339172,
0.4362221360206604,
-0.37589845061302185,
0.16580015... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.