Jump to content
xisto Community

qwijibow

Members
  • Content Count

    1,359
  • Joined

  • Last visited

Everything posted by qwijibow

  1. i have written a template class that acts as a lightning fast linked list. unlike basic linked lists, it does not slow down as the size of the list gets bigger. and the template nature of it allows it to be an array of any datatype or object. i have an unusual syntax error reported by the compiler, and i cant find whate wrong. i compile with the GNU c++ compiler with the command like "g++ -o tester.bin tllisttest.cpp" for anyone who want to try compileing with GCC, but i would welcome any error messages reported by other compilers.. this source code SHOULD also compile on microsofts visual C++ under the windows platform, although ive not been able to test that. PLEASE help, this is driving me mad here is the compiler error output. here are lines 55 to 58 of tllist.h template<class dataType> cllist::cllist() { init();}template<class dataType> cllist::cllist(unsigned long n) { init(n);}template<class dataType> cllist::cllist(unsigned long n, dataType defVal){ init(n,defVal);}template<class dataType> cllist::~cllist(){ flush();} you will notice there is no return type, ive checked the manual, and i know constructors dont have return types, (not even void's) i tried adding void, same error message. this error message makes no sence !!!! here is the cokmplete source code of tllist.h // template linked list class by chris stones.// a class to hold a variable array / stack of any type.// maximum size of array = 4,294,967,296 (unsigned long).// the Arrays performance does NOT decreace with size when used in a sequential mannor. // a single link in the listtemplate <class dataType>struct clink { clink<dataType> *left; clink<dataType> *right; dataType data;};// floater. a marker that points to the item in the list that was last accessed in the hope that the next// link that needs finding will probably lie next to it.template <class dataType>struct cfloater { unsigned long currentIndex; clink<dataType> *currentAddress;};// an exception to throwclass TLLIST_OUT_OF_BOUNDS{};// where all the magick happens.template <class dataType>class cllist {private: clink<dataType> first,last; cfloater<dataType> floater; unsigned long size; void init(); void init(unsigned long, dataType); void init(unsigned long); clink<dataType> *access(unsigned long);public: ~cllist(); cllist(); // default constructor, sets up an emptly list. cllist(unsigned long); // single parameter constructor, sets up an array of the specified size. cllist(unsigned long,dataType); // same as above, but with initiated to match parameter 2. dataType pop(unsigned long); // remove a single item from anywhere in the list. dataType popLeft(); // remove the first (left) item from the fist. dataType popRight(); // remove the last (right) item from the list. void push(unsigned long, dataType); // insert an item anywhere on the list. void pushLeft(dataType); // add an item onto the beggining (Left) of the list void pushRight(dataType); // add an item onto the end (right) of the list void flush(); // empty the list. unsigned long getSize(); // return the size of the list. dataType& operator [](double); // overloaded [] for array like access to the list.};// constructors + destructorstemplate<class dataType> cllist::cllist() { init();}template<class dataType> cllist::cllist(unsigned long n) { init(n);}template<class dataType> cllist::cllist(unsigned long n, dataType defVal){ init(n,defVal);}template<class dataType> cllist::~cllist(){ flush();}// smaller function boddiestemplate<class dataType> void cllist::init(unsigned long n, dataType defVal) { while(size != n) { push(defVal);}}template<class dataType> void cllist::init(unsigned long n) { init(); init(n,dataType());}template<class dataType> dataType cllist::popLeft() { return pop(0);}template<class dataType> dataType cllist::popRight() { return pop(size-1);}template<class dataType> void cllist::pushLeft(dataType data) { push(0,data);}template<class dataType> void cllist::pushRight(dataType data) { push(size, data);}template<class dataType> dataType& cllist::operator [](double n) { return access(n)->data;}template<class dataType> void cllist::flush() { while(size != 0){ pop(0);}}template<class dataType> unsigned long cllist::getSize() { return size;}template<class dataType> void cllist::init(){ // basic initilisation size = 0; first.left = 0; first.right = &last; last.right = 0; last.left = &first; floater.currentIndex = 0; floater.currentAddress = 0;}template<class dataType> clink<dataType>* cllist::access(unsigned long index) { // a quick check... if(index >= size) { throw TLLIST_OUT_OF_BOUNDS(); } // which is closer to the desired link ? (first, last or floater) unsigned long distanceFirst = index + 1; unsigned long distanceLast = (size + 1) - index; unsigned long distanceFloater; // the first time access() is called, floater is not inside the actual array, // and because index is an unsigned variable (not able to be -1) its index is incorrect to its position, // ignore floater the first time the closest point is calculated. if (floater.currentAddress != &first) { if (index >= floater.currentIndex) { distanceFloater = index - floater.currentIndex; } else { distanceFloater = floater.currentIndex - index; } } else { distanceFloater = size; } // make it impossibly big, so one of the others is selected as closer. // is the required index point to the right, or left of the closest known index point ? bool loopRight = true; // default, first is closest clink<dataType> *thisLink = &first; unsigned long distance = distanceFirst; // maybe last is closer ?? if (distanceLast < distance) { distance = distanceLast; thisLink = &last; loopRight = false; } // or maybe the floater ?? if (distanceFloater < distance) { distance = distanceFloater; thisLink = floater.currentAddress; if (floater.currentIndex > index) { loopRight = false; } else { loopRight = true; } } // now loop to the required access index. while(distance != 0) { distance--; if (loopRight) { thisLink = thisLink->right; } else { thisLink = thisLink->left; } } // set floater to this link UNLESS accessing the first of last link (remembed by first and last local variable) if(index != 0 && index != size-1) { floater.currentIndex = index; floater.currentAddress = thisLink; } //return result return thisLink;}template<class dataType> dataType cllist::pop(unsigned long n) { clink<dataType> *popLink = access(n); dataType forReturn = popLink->data; // correct pointers on either side of the link to be poped popLink->left->right = popLink->right; popLink->right->left = popLink->left; // correct size parameter size--; // are we about to delete the object that the floater points to ? if(popLink == floater.currentAddress) { // move the floater to the right, (index remains correct) floater.currentAddress = popLink->right; } else { // the object floater points to will not be deleted. // however, if we deleted an object on the left of floater, then floaters // index needs to be decremented. if(n < floater.currentIndex) { floater.currentIndex--; } } // delete the poped link delete popLink; // return the data return forReturn;}template<class dataType> void cllist::push(unsigned long index, dataType value) { // to push to position n is to add a link with the index of n. pushing the last index n to index n+1. clink<dataType> *rightLink; clink<dataType> *leftLink; // create a new link. clink<dataType> *newLink = new clink<dataType>; newLink->data = value; // get the link which will be to the right of the new link // special case.. PUSHING to the very end of the list. will throw an out of bounds if we call accessLink() if (index == size) { rightLink = &last; } else { rightLink = access(index); } // get the link which will be to the left of the new link leftLink = rightLink->left; // insert the new link newLink->right = rightLink; newLink->left = leftLink; rightLink->left = newLink; leftLink->right = newLink; // fix the size variable size++; // fix the floater.... // dont move the floater if we are pushing to the very right, or left of the list if(index != size-1 && index != 0) { floater.currentIndex = index; floater.currentAddress = newLink; } else { // if we just pushed to the left of the floater, then floaters index needs to be incrememnted if(index <= floater.currentIndex) { floater.currentIndex++; } }} and HERE is a program i wrote to test the tllist class // linked list tester by chris stones.#include<iostream>using namespace std;#include"tllist.h"// tests...// add 100 items to the list// remove link from random place// add link to random place// output entire list (with array interface)// output entire list by popping.// exception tests...// Out of boundsint main() { cllist<int> stack; int n; cout << "pushing 20 numbers to the right" << endl; for (n=0; n<20; n++) { stack.pushRight(n); } cout << "output entire list" << endl; for (n=0; n<20; n++) { cout << stack[n] << '|'; } cout << "output intex 10" << endl; cout << stack[10] << endl; cout << "output index 15" << endl; cout << stack[15] << endl; cout << "insert 99 into index 10" << endl; stack.push(10,99); cout << "remove index 1 = "; cout << stack.pop(1) << endl; cout << "pop all items off list" << endl; while(stack.getSize != 0) { cout << stack.popLeft() << '|'; } cout << "cause out of bounds error" << endl; stack.popRight(); return 0;} AGH... this forum doesnt format the CODE blocks very well... i also posted this question at linuxquestions.org.. if you think you can help, but this CODE is sending your eyes into the back of your skull, please have a look here http://forums.xisto.com/no_longer_exists/ thanX
  2. Last time Windows won the TCO test, we all laughed... DUDE, its a test funded and published by MS... how many MS funded test dare to tell bill he sucked ? and out of al those who told bill he sucked, how many did bill publish... none... if they even exist.. who knows...anyways.... I believe that Linux has a lower TCO... however,after smiting dwn the windows winning test for being funded by MS, by principal you HAVE to critisize this test for beiing done by an Open Source company.when will there be a TCO test done by a totally unbiased source ???? like my little sister
  3. It used to be, or maybe it still is... i cant remember that exact date that Solaris 10 is released as Open source... last time i read about it, Sun was negotiating an open source licence with the Open source software groupe.
  4. Yep, only a few machines can boot from USB.do you have a CD-ROM ?All Linux distro's have boot cd-roms to install from.What Linux DIstro are you planning on installing ?
  5. What Does OpenBSD count as ?its Open source, but its mainly controlled by the university of california (a central point) anyways, it doent change my opinion of windows... i fount it annoying, slow, un-reliable before, and i still think this is the case. Isnt MS windows the ONLY fully closed source popular operating system around ? the trends are obviouse, open your source and your *bottom* will follow.
  6. lol if i remember correctly, the last OS Apple created (MacOS 9) was sending the whole company down the pan. lol. ive heared PearPC is actually quite fast, on the home page in the odcumentation there is a performace loss %, and its quite low, (cant remember the exact figure). however if i was going to install MacOSX on my PC, i would first build a tiny, very highly optimised Linux From Scratch distro.
  7. https://www.kde.org/ Free and Open source. its part of the kde network package. works on any *nix system.
  8. Linux is Just a kernel, and doesnt include a user interface. the most Popular Interface KDE is actually *nix Desktop environment. Anyways... comparing KDE to Windows and OSX i think KDE is easyer, this is just an opinion. What does the Windows User interface do that KDE doesnt ? both point and click... both have a control center for selcting screen savers, screen resolution, background image.. as far as i can tell, KDE does everything WIndows Desktop does, and more. Audio Ripping using the file manager konqueror, optional preview on image, audio and movie files. an encrypt with GnuPG feature. multiple virtual desktops... i personally dont see how KDE could possibly be any easyer.
  9. do any of you guys Use Kopete MSN messenger client ?it doesnt support video conferencing, but it does support spell checking, and language translation. very nifty
  10. qwijibow

    Prefixes

    the prefix is the install location... it will usually default to /usr/ but you can change it with ./configure --prefix=/urs/installPath/
  11. eh ? its not the Unix people#s fault... the Unix people were computer scientists, they made an OS which philosophy's and design has never been bested. however billy was a buisnessman. he picked the perfect time to pay someone to write a dirty quick cheap OS, and sell it super cheap to the OEM's. Pc's begin being sold with MS's OS pre installed, thats how he got is foot in the door, and he's still here now. Unix was too expensive for home use, so people used MS-DOS. however, now the best OS in terms of stability and security are... free.
  12. or you could go CraZY and install a minimal linux system (Gentoo for speed, or Linux From Scratch for speed and ulta minimalism) then install PearPC (the MAC hardware emulator) then get your hands on a MacOSX install CD, and install MacOS on your pc ! and when a super tiny Linux system (like linux from scratch) can goot on my 1.3Ghz athlon in 4 seconds... you might not even notice your not using a mac. but anyways, in a Linux person.. personally i dont understand why poeple go from a open Hardware with closed OS (windows) to a Open OS on closed hardware... why not go all the way and just install a Linux of FreeBSD on a PC. anyways.... check it out, i think its on https://sourceforge.net/ its called pearPC
  13. actually, your horrably wrong.... windows is 1) not campatable with anything 2) a nightmare to program !!! first off, take a program sice as KDE. its a whole destop environment, grap the source code and compile it... compile it on FreeBSD, compile it on Linux, compile it on OpenBSD, solaris, whatever !... the same source code will compile on all these different operating systems,a nd work... however with windows, nope, it will not compile. nor will windows source code compile on any other OS. Plus,, has anyone ever tried compiling and using a DLL in windows... its a nightmare, in linux, its as simple as turning the "share" switch on when compiling, to make an .so (shared object) SECONDLY.... and here's what annoys the CRUD out of me... last time i tried to compile the following code in VC++, it failed with an error like "error variable array length" int number = GetStrLen("hello world");char *StrArray = new char[number+1]; that code is perfectly legal c++.
  14. Counter Strike runs fine in Wine.and Wine runs fine on *nix systems.https://www.winehq.org/
  15. Gentoo, Linux From Scratch, Slackware, FreeBSD, OpenBSD, Sun's Solaris UNIXwhatever... aslong as its not windows, i can get along with it just fine.
  16. looks like the site dont allow hot linkin.i dont think it will take off.. i installed a 3d destop environment a while ago on my Gentoo Linux box.. it was pretty,, but it took 5 times aslong to organise my desktop.if you want somthing amasing AND usefull, install Xorg 6.8, the dektop (kde in my case) supports transparent windows...window contents everything...How many people can say they watched a full screen DVD, and surfed the internet on a full screen web browser at the same time, on the same screen.... i can..
  17. OSX and OpenBSD (call it Unix if you want) are virtually the same OS. the BSD's are cousins of Linux, Linux is the daughter of Minix, Minix was Unix's little brother... its a strange family tree... but windows is the complete oposite of anything even remotely Unix Like.
  18. i love DIsturbed.... Down with the sickness rocks !i love the way Disturbed are heavy rock, but if you listen to the lyrics (or look them up for the more energetic performaces) the lyrics are quite clever... and meaningful.i also love.. Metallica, Nirvana, Placebo, Garbage, Static X, and ofcourse SYSTEM OF A DOWN !
  19. mas OSX Iis UNIX. as far as i am concerned, MAC OS is dead... Mac OS9 was lame... the company was panicking, they re-hired steve jobs, and he saved the company... How did he do it ? He scrapped Mac OS, and instead, used FreeBSD (re-write the kernel, and desktop environment, ported from OS9)
  20. lol..... sorry to burse your buble... but Microsoft are already working on Avalon... the replacement to .NET they will force the adoption of .NET and just when you have recovered from that... BOOM...Avalon. their are 2 ways of doing things.... there's THE WAY (works on every operating system except Windows) and the windows way. MS are pushing developers away, the GNU way is lokking more and more tempting to developers i think. i used to code c++ with MS VC++ then i tried GNU/Linux never looked back. then i went to university.. Linux binary's wont run on solaris, porting my software was as simple as a 2 minute re-compile... no source code to port..., just a recompile.
  21. for a Desktop you dont want 2 CPU's !!!! this would be a waste of money in many cases. for example, take Unreal TOurnament 2004. this game only uses 2 processor threads, one which runs the sound,, (very light on CPU power) and the other does everything else. therefore... a Single 2Ghz Pentium4 system would out-perform a dual 1.8Ghz Pentium4 system (in theory) leave multiple CPU systems to the serversand cluster networks.
  22. ohh and or if you use Linux / Solaris / BSD virus scanners dont even exist.. guess why.. okay.. ive finiished ranting... (for now)
  23. cummon.... face it ! the reason windows is so insecure is because ... well. has anyone ever watched fightclub ? have a look at http://www.openbsd.org/ the slogan on the front page is correct... its almost 10 years since there was a remote vunerability in OpenBSD in almost 10 years !!!!!! first of all, on the internet,,, Linux and BSD is the majority, windows the minority,,, so out the window goes the target poulation theory... a server is also much more jucy to crackers than a home pc thats only turned on 2 hours a day. So..... the OpenBSD source code is free... it would even be legal for MS to use BSD source code in windows if they wanted to... (older versions of windows used the BSD source code in the TCP stack) so why is windows so in-secure.. because its more profitable to blame script kiddies, blame the virus writers.... and continute to make maximum profits at minimum effors. most Windows users dont even realsise BSD and Linux and Solaris exists... they dont realise that the only reason virii exists, and de-fragmenting is needed every month is because it was easyer for microsoft to let you live in ignorance, accepting this crap as just a fact of computing.
  24. not too long ago, there were no commercial games for linux... (loooooads of free open source games)but now, there are quite a few... i have the following linux games...Unreal Tournament / Ut2003 / Ut2004Quake 1 / 2 / 3Kingpin: Life of CrimeHalf-Life (using Wine)Counter Strike (using wine)Opposing forces (using wine)Doom 3The SImsand for open source games... Tourcs is a great realistic racing game, and Flight Gear Flight Simulator is a great free replacement to Microsoft's FLight simulator.Linux games are commin to getcha !
  25. they all do the same thing pretty much.... i use kimage, or konqueror... whatever.
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.