========================================================================= Date: Wed, 1 Mar 2000 00:04:34 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jonathan Pryor Subject: Re: free lists and overloading new In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit ``operator new'' is supposed to return raw memory. All you need to do is return enough raw memory to fulfill the memory request. Additionally, for safety you should check the parameter passed to ``operator new'' to make sure that it's the same size as what you're providing a free list for. For example: void* prt_internal::operator new (size_t size) { if (size != sizeof(prt_internal)) return ::operator new(size); // call default allocator prt_root* temp = free_lst; free_lst = (prt_root*)free_lst->nw; return temp; } For more information, see item 10 of "Effective C++, Second Edition" by Scott Meyers. It's important to note that you should call ``::operator new(size);'', and not ``::new typename;''. The purpose of ``operator new'' is to allocate memory; it's not supposed to invoke the constructor. ``operator new'' just allocates memory (like malloc() in C); the constructor call is made separately. If you just call ``::new typename;'', the class constructor will be invoked twice (once in your own ``operator new'', and again after your ``operator new'' returns). In the general case, this is bad, as it could lead to corrupted data. In other cases, it may not matter. (An example of where data could be corrupted is if a class has a static data member that tracks the number of objects in existence. This member would be incremented in the constructor and decremented in the destructor. However, if you just call ``::new typename;'', the constructor will be called twice, without an intervening call to the class destructor. This will screw up the class data.) - Jon > -----Original Message----- > From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of > r e duffy > Sent: Tuesday, February 29, 2000 11:00 PM > To: CS2604@LISTSERV.VT.EDU > Subject: free lists and overloading new > > > i think that having a free list may be a good idea for this program, since > removing a record may implicate multiple deletions (collapsing tree). i > under stand the concept of a free list, but i am having trouble > understanding how to overload the new operator, especially what parameters > nust be passed. > > this is a derivation of the example in the notes: > > void* prt_internal::operator new(size_t){ // what is size t? > > // what other parameters can exist? > if (free_lst == fly_weight) // list is empty > return ::new what??; //what goes here? > prt_root* temp = free_lst; > free_lst = (prt_root*)free_lst->nw; > return temp; > } > > thanks- > duffy ========================================================================= Date: Mon, 1 Mar 0100 00:48:50 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brian Wagner Subject: Re: Question about Node Class In-Reply-To: <000e01bf8332$c23f6040$0201a8c0@vtacs.com> from "John Owens" at Feb 29, 0 11:01:00 pm Content-Type: text Umm, don't use inheritance w/ a project of this small of a scope. (It's not worth the effort.) My solution (this only illustrates the most basic design concepts...): (This has worked fine for me.) class PRNode { //Readers: public: // both: bool readIsLeaf(); bool readIsInternal(); public: bool IN_IsEmpty(); bool LF_IsEmpty(); // Attributes: private: bool IsLeaf; bool IsInternal; }; bool PRNode::IN_IsEmpty() { if( IsInternal == false ) return false; // ... } bool PRNode::LF_IsEmpty() { if( IsLeaf == false ) return false; // ... } > > I am trying to use inheritance to have an internal and leaf node subclass > built off of a main node class. (basic example used in notes) I have two > different questions. > > 1) Can we just create a single node class that has the 4 pointers and the > data, or do we need to have 2 seperate types of node classes (as the form of > inheritance I am trying to do)... it would make coding a lot easier. > > 2) My problem is in the typecasting. Doing recursive transversals, i either > need to return a Node (the main class that internal and leaf are derived > from) or pass a Node by reference. How would I typecast either of those? > > The example in the notes shows: > class VarBinNode > class LeafNode : public VarBinNode > class IntlNode : public VarBinNode > > and then in a traverse function > void traverse(VarBinNode *rt) > and an example of a typecast there is traverse(((IntlNode *)rt)->leftch()); > > how would i change that to pass rt by reference? or would i need to use > a return command instead of using a void in the function? > > John > -- // Brian Wagner, CpE WWW: http://www.bigfoot.com/~datatroi First guy (proudly): "My wife's an angel!" Second guy: "You're lucky, mine's still alive." :-) ------------------------------------------------------------------------- ========================================================================= Date: Wed, 1 Mar 2000 01:14:11 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Mike Schaefer Subject: Re: Question about Node Class MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I beg to differ on that... I'm using inheritance with polymorphism and, assuming you can understand what's going on, I found it made things very nice. You don't have to know, nor do you care, what kind of node you're working with, it's all taken care of at run time. It all depends on what you are comfortable with. :) -----Original Message----- From: Brian Wagner [SMTP:brwagne2@VT.EDU] Sent: Wednesday, March 01, 2000 12:49 AM To: CS2604@LISTSERV.VT.EDU Subject: Re: Question about Node Class Umm, don't use inheritance w/ a project of this small of a scope. (It's not worth the effort.) My solution (this only illustrates the most basic design concepts...): (This has worked fine for me.) class PRNode { //Readers: public: // both: bool readIsLeaf(); bool readIsInternal(); public: bool IN_IsEmpty(); bool LF_IsEmpty(); // Attributes: private: bool IsLeaf; bool IsInternal; }; bool PRNode::IN_IsEmpty() { if( IsInternal == false ) return false; // ... } bool PRNode::LF_IsEmpty() { if( IsLeaf == false ) return false; // ... } > > I am trying to use inheritance to have an internal and leaf node subclass > built off of a main node class. (basic example used in notes) I have two > different questions. > > 1) Can we just create a single node class that has the 4 pointers and the > data, or do we need to have 2 seperate types of node classes (as the form of > inheritance I am trying to do)... it would make coding a lot easier. > > 2) My problem is in the typecasting. Doing recursive transversals, i either > need to return a Node (the main class that internal and leaf are derived > from) or pass a Node by reference. How would I typecast either of those? > > The example in the notes shows: > class VarBinNode > class LeafNode : public VarBinNode > class IntlNode : public VarBinNode > > and then in a traverse function > void traverse(VarBinNode *rt) > and an example of a typecast there is traverse(((IntlNode *)rt)->leftch()); > > how would i change that to pass rt by reference? or would i need to use > a return command instead of using a void in the function? > > John > -- // Brian Wagner, CpE WWW: http://www.bigfoot.com/~datatroi First guy (proudly): "My wife's an angel!" Second guy: "You're lucky, mine's still alive." :-) ------------------------------------------------------------------------- ========================================================================= Date: Wed, 1 Mar 2000 08:25:48 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Andy Strassburg Subject: Why me?? In-Reply-To: <01BF831B.749D8860.mischaef@vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Ok, Check this problem out. My program doesn't recognize my instances of strings, because for some reason, it does not include the string.h header file when I try to include it. The funny thing is, I made a new program as follows: #include void main() { string someString; } // end main And it doesn't compile! I even tried 'using namespace std', as if that would make a difference, and it said that std was not a namespace! Even weirder, I sent this stuff over to a friend who is running Visual 6 (I have Visual 5), and it didn't work on his either!!! I checked in the /VC/include directory, and string.h is there, and I saw that my settings were correct to look in this directory. Has ANYONE had a stupid problem like this before? Any help would be most appreciated, thanks!! Andy ========================================================================= Date: Wed, 1 Mar 2000 10:00:52 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: output for search In-Reply-To: <38BC8FED.243F6C8C@vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Multiple lines (1 per city) is probably clearer. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- On Tue, 29 Feb 2000, Patrick O'day wrote: > what does the output look like for searches that find more than 1 city > within the radius? should they all be on one line or multiple lines? > ========================================================================= Date: Wed, 1 Mar 2000 09:27:27 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brad Friedman Subject: Re: Why me?? In-Reply-To: <3.0.6.32.20000301082548.007df590@mail.vt.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Try #include instead of . Also include using namespace std. Change the program to look like this: #include using namespace std; void main() { string someString; } // end main It looks like you are trying to use the newer C++ strings, but you are including the header file for the C style strings. Alot of the newer C++/STL stuff does not have the .h on the header file to differentiate them from the older C style headers. Hope this works for you. Brad -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Andy Strassburg Sent: Wednesday, March 01, 2000 8:26 AM To: CS2604@LISTSERV.VT.EDU Subject: Why me?? Ok, Check this problem out. My program doesn't recognize my instances of strings, because for some reason, it does not include the string.h header file when I try to include it. The funny thing is, I made a new program as follows: #include void main() { string someString; } // end main And it doesn't compile! I even tried 'using namespace std', as if that would make a difference, and it said that std was not a namespace! Even weirder, I sent this stuff over to a friend who is running Visual 6 (I have Visual 5), and it didn't work on his either!!! I checked in the /VC/include directory, and string.h is there, and I saw that my settings were correct to look in this directory. Has ANYONE had a stupid problem like this before? Any help would be most appreciated, thanks!! Andy ========================================================================= Date: Wed, 1 Mar 2000 11:47:05 -0800 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Luck Subject: Re: Pointers by reference In-Reply-To: <001101bf8093$0a3a1630$585f52c6@sfung.campus.vt.edu> MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_ElX9t1wHm/d62HtM/4GSaQ)" This is a multi-part message in MIME format. --Boundary_(ID_ElX9t1wHm/d62HtM/4GSaQ) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Is was wondering if you ever found the answer to this... I am having the same problem. -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Shyan Fung Sent: Saturday, February 26, 2000 11:53 AM To: CS2604@LISTSERV.VT.EDU Subject: Pointers by reference Can someone tell me why I'm getting an error when I try to pass a pointer by reference for the insertHelp and removeHelp functions? This is what the error the compiler gave me: error C2664: 'insertHelp' : cannot convert parameter 1 from 'class QuadNode *' to 'class QuadNode *& ' A reference that is not to 'const' cannot be bound to a non-lvalue Thanks, Shyan Fung --Boundary_(ID_ElX9t1wHm/d62HtM/4GSaQ) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
   Is was wondering if you = ever found=20 the answer to this...
I am=20 having the same problem. 
-----Original Message-----
From: CS2604 discussion = list=20 [mailto:CS2604@listserv.vt.edu]On Behalf Of Shyan = Fung
Sent:=20 Saturday, February 26, 2000 11:53 AM
To:=20 CS2604@LISTSERV.VT.EDU
Subject: Pointers by=20 reference

Can someone tell me why I'm = getting an error=20 when I try to pass a pointer by reference for the insertHelp and = removeHelp=20 functions?  This is what the error the compiler gave = me:
 
 
error C2664: 'insertHelp' : cannot = convert=20 parameter 1 from 'class QuadNode *' to 'class QuadNode *&=20 '
        A reference that is = not to=20 'const' cannot be bound to a non-lvalue
 
 
Thanks,
 
Shyan=20 Fung
--Boundary_(ID_ElX9t1wHm/d62HtM/4GSaQ)-- ========================================================================= Date: Wed, 1 Mar 2000 13:11:22 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: Pointers by reference In-Reply-To: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII I think the reason this question was not answered the first time is because insufficient information was provided. However, based on other questions, and because it is a common bug, I will suggest that you check to see if the actual parameter is a function call rather than an address. You can't pass the result of a function call by reference, since there is no address (an l value) to assign to. If you simply took the model from the BST code in the book, and patched it to use access functions in place of the node data fields, you would get exactly this result. But, this is all speculation, since the problem code was not provided in the original email. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- On Wed, 1 Mar 2000, Jason Luck wrote: > Is was wondering if you ever found the answer to this... > I am having the same problem. > -----Original Message----- > From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of > Shyan Fung > Sent: Saturday, February 26, 2000 11:53 AM > To: CS2604@LISTSERV.VT.EDU > Subject: Pointers by reference > > > Can someone tell me why I'm getting an error when I try to pass a pointer > by reference for the insertHelp and removeHelp functions? This is what the > error the compiler gave me: > > > error C2664: 'insertHelp' : cannot convert parameter 1 from 'class > QuadNode *' to 'class QuadNode *& ' > A reference that is not to 'const' cannot be bound to a non-lvalue > > > Thanks, > > Shyan Fung > ========================================================================= Date: Mon, 1 Mar 0100 14:03:18 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brian Wagner Subject: Re: Question about Node Class In-Reply-To: <01BF831B.749D8860.mischaef@vt.edu> from "Mike Schaefer" at Mar 1, 0 01:14:11 am Content-Type: text > I beg to differ on that... I'm using inheritance with polymorphism and, > assuming you can understand what's going on, I found it made things very > nice. You don't have to know, nor do you care, what kind of node you're > working with, it's all taken care of at run time. It all depends on what > you are comfortable with. :) OK, maybe I should've prefaced my statements w/ "in my opinion" but... Using "inheritance w/ dynamic polymorphism" requires using pointers when dealing w/ the PRNode class when in your PRTree class. Like I've said before, I stay away from pointers as much as possible. On the inheritance issues in general, inheritance requires more time being spent on the design (ie, BEFORE implementing them) of the PRNode classes. While I am big into up-front-design, when considering that the PRNode class is a very small part of my system (just look at my class diagram for proof), it's not worth the time to do "inheritance w/ dynamic polymorphism." ... in my opinion But on my co-op tour, when I had to do a software system that needed Server and Client socket classes, SURE I USED INHERITANCE. ie: GeneralSocket ^ ^ | | Server Client CONCLUSION: All I'm saying is that I BELIEVE that using inheritance in P2 takes more time. And the time factors are of large importance to me when I came up w/ a project plan for P2. ... in my opinion :-) > > -----Original Message----- > From: Brian Wagner [SMTP:brwagne2@VT.EDU] > Sent: Wednesday, March 01, 2000 12:49 AM > To: CS2604@LISTSERV.VT.EDU > Subject: Re: Question about Node Class > > Umm, don't use inheritance w/ a project of this small of a scope. > (It's not worth the effort.) > > My solution (this only illustrates the most basic design concepts...): > (This has worked fine for me.) > > > class PRNode > { > > //Readers: > public: // both: > bool readIsLeaf(); > bool readIsInternal(); > > public: > bool IN_IsEmpty(); > bool LF_IsEmpty(); > > // Attributes: > private: > bool IsLeaf; > bool IsInternal; > > }; > > > bool PRNode::IN_IsEmpty() > { > if( IsInternal == false ) > return false; > // ... > } > > bool PRNode::LF_IsEmpty() > { > if( IsLeaf == false ) > return false; > // ... > } > > > > > > > > I am trying to use inheritance to have an internal and leaf node subclass > > built off of a main node class. (basic example used in notes) I have > two > > different questions. > > > > 1) Can we just create a single node class that has the 4 pointers and the > > data, or do we need to have 2 seperate types of node classes (as the form > of > > inheritance I am trying to do)... it would make coding a lot easier. > > > > 2) My problem is in the typecasting. Doing recursive transversals, i > either > > need to return a Node (the main class that internal and leaf are derived > > from) or pass a Node by reference. How would I typecast either of those? > > > > The example in the notes shows: > > class VarBinNode > > class LeafNode : public VarBinNode > > class IntlNode : public VarBinNode > > > > and then in a traverse function > > void traverse(VarBinNode *rt) > > and an example of a typecast there is traverse(((IntlNode > *)rt)->leftch()); > > > > how would i change that to pass rt by reference? or would i need to use > > a return command instead of using a void in the function? > > > > John > > > > > -- > // Brian Wagner, CpE WWW: http://www.bigfoot.com/~datatroi > First guy (proudly): "My wife's an angel!" > Second guy: "You're lucky, mine's still alive." :-) > ------------------------------------------------------------------------- > -- // Brian Wagner, CpE WWW: http://www.bigfoot.com/~datatroi TO VIRGINIA TECH STUDENTS ONLY: Wow, I'm impressed. "Bleaksburg" is hosting the band _Filter_ in April. :) ------------------------------------------------------------------------- ========================================================================= Date: Wed, 1 Mar 2000 14:02:20 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Mark Brauning Subject: Dr. Roach's Midterm Exam Info?? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Anybody know when Dr. Roach's exam is scheduled for? I think I wrote the time down wrong... thanks Mark B http://www.erols.com/mbraunin ========================================================================= Date: Mon, 1 Mar 0100 14:27:11 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brian Wagner Subject: Re: Dr. Roach's Midterm Exam Info?? In-Reply-To: <0FQR0097VBKYMC@gkar.cc.vt.edu> from "Mark Brauning" at Mar 1, 0 02:02:20 pm Content-Type: text > Anybody know when Dr. Roach's exam is scheduled for? I think I wrote the > time down wrong... > > thanks > > Mark B > > http://www.erols.com/mbraunin Hmm, he announces it each class period. 3/8/00: 7P: Litton Reaves 1670 (according to my "black book") -- // Brian Wagner, CpE WWW: http://www.bigfoot.com/~datatroi TO VIRGINIA TECH STUDENTS ONLY: Wow, I'm impressed. "Bleaksburg" is hosting the band _Filter_ in April. :) ------------------------------------------------------------------------- ========================================================================= Date: Wed, 1 Mar 2000 15:47:32 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Roberts Subject: searching MIME-version: 1.0 Content-type: MULTIPART/MIXED; BOUNDARY="Boundary_(ID_6yLjtaojuhPBnOL7dF9bbg)" This is a multi-part message in MIME format. --Boundary_(ID_6yLjtaojuhPBnOL7dF9bbg) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Okay here is the problem. For searching, how do we go about it. I have read the book and it doesn't seem to answer this problem very well. I have been able to traverse tree and find all coordinates that are within the search radius, the only problem is that I have to traverse the whole tree. My question is, how exactly do you know when to go down a path of the tree that is in the search radius. For example, if I have a tree in which the search radius only encompasses just one side of a rectangle and not the end points how do I know to search that node. I know I am sounding a little vague so I am attaching a picture to show what I am talking about. The picture should describe exactly what I am getting at. Basically how would I search this quadrant, seeing as how I would have to check just the few points that are actually in the radius of the circle. If you have an answer let me know, it will definitely help with the efficiency of my program. Thanks, Jason --Boundary_(ID_6yLjtaojuhPBnOL7dF9bbg) Content-type: image/gif; name=search.GIF Content-disposition: attachment; filename=search.GIF Content-transfer-encoding: base64 R0lGODlhAAKAAYAAAP///wAAACwAAAAAAAKAAQAC/4SPqcvtD6OctNqLs968+w+G4kiW5omm6sq2 7gvH8kzX9o3n+s73/g8MCofEovGITCqXzKbzCY1Kp9Sq9YrNarfcrvcLDovH5LL5jE6r1+y2+w2P y+f0uv2Oz+v3/L7/DxgoOEhYaHiImKi4yNjo+AgZKTlJWWl5iZmpucnZ6fkJGio6SlpqeoqaqrrK 2ur6ChsrO0tba3uLm6u7y9vr+wscLDxMXGx8jJysvMzc7PwMHS09TV1tfY2drb3N3e39DR4uPk5e bn6O/hewzt7u/g4fLz9PX29/jw+fDhqg05/0b1+ngDcIGjEoMBNCGguHNExY6WEMiUAoQoxk0UXG Hv8bLzbquAKkP4+aRKYwiQMlSUMqTbSs8XKloJgjaMqwKdMPThA7X/TMqednB6EsiAK1Y1RD0pNH KS3F8PRE1KZvplawSgIr1TVaJXQN8XXrmbAPyHowK3YMWgZrN7RN++VtArlQ4TqiewBv2XYG9NrF 4tfvXHaD1/1dFJgjxX6GDx9K7C9jwMaOB0FOOcGg4MpMLtsAiXAzZ4AjC15dIHr0wdKfTyvAmlo1 B88zTDa0Glu2Uta1LzyUSLgv5eCMhf9jHLpxcQDBmVPWDZP3Td8Nfudlfn2y877ZjyPQrjz7dejR c8hFab36ZL7ODWv/Pj4v4fXEm5Ofbr61hfQOvMP/5/5efASBFx93Bt6HH2YM1VUdW+IBKBx2By4n oYHuCSjhcwj6JB0MKgGnHn3yYTdgeAdGSGF7I+ZmF20eMujghnO4yCF1DcooB401uoYajjN2+OJ+ N/oIh44a2dgjkUUCuSMF/CnZhpFH8jgXlEvmZ5qTSVrphpRTZrYll2x4+WUEoYlZFZMJQqAZmmli aZ5kI7rZpZoMLbYdnW8qqJiG7Om5Z5ZBuHMioFHaWZGhV/J5BIuKrqkfEo4+GiSjq1E6JqI/TIpp C2T6wGmnIWkKqqhqfMqRqWmgykOoqkpFaqqvmsHqDq7OmlWsreJaRq268lpFPsIOS2yxxuYDrFq/ /y6bbBS+wtmsF89aGu0W0wpaLRfXRpqttcxS2+0V25YXrhbjLliuud9im64V5/bWLmDrchsvFe9C Wq8U906Ur7vzktuvvv+iG7DA0F5asLMDw5swFPtW2rATDzcZcWcL41sxaQcXcWvGYdLLscdNTFym yJJezK/JSpDsqcorowyxyyFvTETHMrNclMwn0+yQzo3CTLHPgwJdstCJ8iyEzS7jPKrRPSM9tNNJ E92y1FGD+7TVm1Kds9ZbQ32017JiPbXYY7M7s9m2ct202mzvprHbYAdds9xvZ6C00iozrYLeJvPN lN1kp7yz4CAT/LPhhzOcuOKIL16244xDfrXkhP+jXbflGE+etuZ0c565559vHrnoVQ8etuldo/61 6qtjnrXrfd+Ngt8iA1677K9TnrrusM5dqu+Bsx688L8Tf7bxuQKfvPIiHAt99NJPr4/z1l+Pffba b899995/D3744o9Pfvnmn49++uqvz3777r8Pf/zyz09//fbfj3/++u/Pf//+/w/AAApwgAQsoAEP iMAEKnCBDGygAx8IwQhKcIIUrKAFL4jBDGpwgxzsoAc/CMIQinCEJCyhCU+IwhSqcIUsbKELXwjD GMpwhjSsoQ1viMMc6nCHPOyhD38IxCAKcYhELKIRj4jEJCpxiUxsohOfCMUoSnGKVKyiFa+IxSyC anGLXOyiF78IxjCKcYxkLKMZz4jGNKpxjWxsoxvfCMc4ynGOdKyjHe+IxzzqcY987KMf/wjIQApy kIQspCEPichEKnKRjGykIx8JyUhKcpKUrKQlL4nJTGpyk5zspCc/CcpQinKUpCylKU+JylSqcpWs bKUrXwnLWMpylrSspSQLAAA7 --Boundary_(ID_6yLjtaojuhPBnOL7dF9bbg)-- ========================================================================= Date: Wed, 1 Mar 2000 16:34:45 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: r e duffy Subject: more search area questions In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit shaffer wrote: A bounding box is defined as the smallest rectangle (acually, square in this case) that completely encloses the object. the way this is worded, it sounds like a bounding box can intersect a node with out its circle intersecting the node say there is a search from 128,128 and radius 256 the bounding box for this search has corners (-128,-128) (-128,384) (384,-128) (384,384) now say there is an internal node whose upper left corner is inside the bounding box, but not inside the circle. ex- (352,352) dimension 32. it sounds like we should visit it (which i would prefer), but i want to know if the TAs will give us a case like this, and if so will my node count be right or wrong by doing this? thanks- duffy ========================================================================= Date: Wed, 1 Mar 2000 17:24:06 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: John Costigan Subject: Search questions In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit First of all, about the node count that we are supposed to use when searching for cities. We're supposed to count each node "checked" during the search. That includes internal nodes, if I understand correctly. That is, if a PR Quad tree has only two cities, but there are 10 internal nodes between those cities and the root, then we could conceivably check more than 10 nodes during the search, correct? Should we, however, "check" null nodes? That is, if a region is touched by the search radius circle, but it is NULL, does that count as a check or can we skip it entirely? Right now, my program skips it and does not count it, so it may turn up fewer "checked" nodes than the other implementation. My results are the same as in the sample file, but only because that case was not a factor because all touched nodes were either internal or city nodes. But what about when the TA's test our programs? Which is preferred? Also, I know we were only required to do the "easy" method of determining which regions to check, but I implemented it using the "hard" way. That means my implementation may check fewer nodes than than the other. Will the TA's take this into account, or should I change it to the easier way? Thanks. -- JC ========================================================================= Date: Wed, 1 Mar 2000 19:28:51 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Saam Tariverdi Subject: Lecture notes question MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit On Page 70 of the lecture notes (Titled "Alternate Approach"), regarding BST's, the function inserthelp() is of type void. However, the code states: if (rt == NULL) return new BinNode(); Can you please tell me why the function returns a value when it's of type void? Thanks. Saam Tariverdi ========================================================================= Date: Wed, 1 Mar 2000 20:26:39 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Joel Eiholzer Subject: curious about searching Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Why are we bothering with a bounding box at all? Why not use simple geometry to figure out if the distance between the nearest corner of any given quadrant and the search origin is less than or equal to the radius. And if so check the quadrant? That eliminates needlessly searching quadrants that are within the box but not the circle. That may be unlikely but is technically possible. Somewhere I missed that it was mandated we use a box and now I am worried that if I implement it my way I MIGHT visit less nodes than using a box. So why are we using a box? My other question would be about the output. The sample file outputs the number of nodes visited first. Does our output have to do that? I am assuming not. It would be much easier to output the cities as we visit them and count nodes. Then when we are done we could output the number of nodes visited. Otherwise it seams to me that I have to either do the search twice, once to count and once to output cities OR store the cities and output them afterwards. Thanx, Joel ========================================================================= Date: Wed, 23 Feb 2000 21:31:19 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: "Collin M. Stacy" Subject: command length In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" is there any particular maximum length that the the commands can be? i.e. can the city name be 100 characters long? Thank you, CM ========================================================================= Date: Wed, 1 Mar 2000 22:11:00 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: John Costigan Subject: Re: curious about searching In-Reply-To: <3.0.5.32.20000301202639.009a3de0@192.168.0.1> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit You can't just check the corners of the region, because what if the search origin is exactly RADIUS distance from the midpoint of one of the sides of the region? Then the origin is farther from the corners than RADIUS, but the region should still be checked... looks (kinda) like this: ______ | | | | | | |______| / \ | | \_/ I hope that makes sense... -- JC -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Joel Eiholzer Sent: Wednesday, March 01, 2000 8:27 PM To: CS2604@LISTSERV.VT.EDU Subject: curious about searching Why are we bothering with a bounding box at all? Why not use simple geometry to figure out if the distance between the nearest corner of any given quadrant and the search origin is less than or equal to the radius. And if so check the quadrant? That eliminates needlessly searching quadrants that are within the box but not the circle. That may be unlikely but is technically possible. Somewhere I missed that it was mandated we use a box and now I am worried that if I implement it my way I MIGHT visit less nodes than using a box. So why are we using a box? My other question would be about the output. The sample file outputs the number of nodes visited first. Does our output have to do that? I am assuming not. It would be much easier to output the cities as we visit them and count nodes. Then when we are done we could output the number of nodes visited. Otherwise it seams to me that I have to either do the search twice, once to count and once to output cities OR store the cities and output them afterwards. Thanx, Joel ========================================================================= Date: Wed, 1 Mar 2000 22:29:31 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Joel Eiholzer Subject: Re: curious about searching In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sure that makes sense but that is easy enough to check for also. I guess that I will use the box method since it seems to be the accepted idea and I don't want my output to be different from the graders. It just seems to me that if you abstract this out to a MUCH larger system it may check many many nodes that are not in the circle but in the box. I guess that is ok. Thank you very much for your prompt answer. At 10:11 PM 3/1/00 -0500, you wrote: >You can't just check the corners of the region, because what if the search >origin is exactly RADIUS distance from the midpoint of one of the sides of >the region? Then the origin is farther from the corners than RADIUS, but >the region should still be checked... looks (kinda) like this: > ______ >| | >| | >| | >|______| > / \ > | | > \_/ > >I hope that makes sense... > > -- JC > >-----Original Message----- >From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of >Joel Eiholzer >Sent: Wednesday, March 01, 2000 8:27 PM >To: CS2604@LISTSERV.VT.EDU >Subject: curious about searching > > > Why are we bothering with a bounding box at all? Why not use simple >geometry to figure out if the distance between the nearest corner of any >given quadrant and the search origin is less than or equal to the radius. >And if so check the quadrant? That eliminates needlessly searching >quadrants that are within the box but not the circle. That may be unlikely >but is technically possible. > Somewhere I missed that it was mandated we use a box and now I am >worried >that if I implement it my way I MIGHT visit less nodes than using a box. >So why are we using a box? > > My other question would be about the output. The sample file >outputs the >number of nodes visited first. Does our output have to do that? I am >assuming not. It would be much easier to output the cities as we visit >them and count nodes. Then when we are done we could output the number of >nodes visited. Otherwise it seams to me that I have to either do the >search twice, once to count and once to output cities OR store the cities >and output them afterwards. > >Thanx, >Joel > ========================================================================= Date: Wed, 1 Mar 2000 22:49:45 -0500 Reply-To: joowens@vt.edu Sender: CS2604 discussion list From: John Owens Subject: Re: curious about searching In-Reply-To: <3.0.5.32.20000301222931.009a3e30@192.168.0.1> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit I am in Dr. Shaffer's class, and this was discussed today. When traversing the tree, you perform 2 tests. Test1: Does the outlinebox intersect a quadrant? If so, visit that quadrant. Test2: If a leafnode is reached, and it is not Null/Flyweight, then run the if (radius^2) <= ((cityx-circlex)^2+(cityy-circley)^2)) thingy to see if a specific coordinate lies within the circle. The reason it is done this way is so you dont get complicated while finding what quadrants that are visited. Then it's just a simple check once you get to leafs if that coordinate lies within the circle. John Owens -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Joel Eiholzer Sent: Wednesday, March 01, 2000 10:30 PM To: CS2604@LISTSERV.VT.EDU Subject: Re: curious about searching Sure that makes sense but that is easy enough to check for also. I guess that I will use the box method since it seems to be the accepted idea and I don't want my output to be different from the graders. It just seems to me that if you abstract this out to a MUCH larger system it may check many many nodes that are not in the circle but in the box. I guess that is ok. Thank you very much for your prompt answer. At 10:11 PM 3/1/00 -0500, you wrote: >You can't just check the corners of the region, because what if the search >origin is exactly RADIUS distance from the midpoint of one of the sides of >the region? Then the origin is farther from the corners than RADIUS, but >the region should still be checked... looks (kinda) like this: > ______ >| | >| | >| | >|______| > / \ > | | > \_/ > >I hope that makes sense... > > -- JC > >-----Original Message----- >From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of >Joel Eiholzer >Sent: Wednesday, March 01, 2000 8:27 PM >To: CS2604@LISTSERV.VT.EDU >Subject: curious about searching > > > Why are we bothering with a bounding box at all? Why not use simple >geometry to figure out if the distance between the nearest corner of any >given quadrant and the search origin is less than or equal to the radius. >And if so check the quadrant? That eliminates needlessly searching >quadrants that are within the box but not the circle. That may be unlikely >but is technically possible. > Somewhere I missed that it was mandated we use a box and now I am >worried >that if I implement it my way I MIGHT visit less nodes than using a box. >So why are we using a box? > > My other question would be about the output. The sample file >outputs the >number of nodes visited first. Does our output have to do that? I am >assuming not. It would be much easier to output the cities as we visit >them and count nodes. Then when we are done we could output the number of >nodes visited. Otherwise it seams to me that I have to either do the >search twice, once to count and once to output cities OR store the cities >and output them afterwards. > >Thanx, >Joel > ========================================================================= Date: Wed, 1 Mar 2000 23:19:52 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: John Costigan Subject: Re: curious about searching In-Reply-To: <3.0.5.32.20000301222931.009a3e30@192.168.0.1> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit I agree, and I actually did use the more precise method. All it requires is testing nine different regions, (the nine areas created by the four sides of the region, looks like a TIC TAC TOE board), which was only 5 if statements the way I did it, and that was probably the inefficient way, hehehe... -- JC -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Joel Eiholzer Sent: Wednesday, March 01, 2000 10:30 PM To: CS2604@LISTSERV.VT.EDU Subject: Re: curious about searching Sure that makes sense but that is easy enough to check for also. I guess that I will use the box method since it seems to be the accepted idea and I don't want my output to be different from the graders. It just seems to me that if you abstract this out to a MUCH larger system it may check many many nodes that are not in the circle but in the box. I guess that is ok. Thank you very much for your prompt answer. At 10:11 PM 3/1/00 -0500, you wrote: >You can't just check the corners of the region, because what if the search >origin is exactly RADIUS distance from the midpoint of one of the sides of >the region? Then the origin is farther from the corners than RADIUS, but >the region should still be checked... looks (kinda) like this: > ______ >| | >| | >| | >|______| > / \ > | | > \_/ > >I hope that makes sense... > > -- JC > >-----Original Message----- >From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of >Joel Eiholzer >Sent: Wednesday, March 01, 2000 8:27 PM >To: CS2604@LISTSERV.VT.EDU >Subject: curious about searching > > > Why are we bothering with a bounding box at all? Why not use simple >geometry to figure out if the distance between the nearest corner of any >given quadrant and the search origin is less than or equal to the radius. >And if so check the quadrant? That eliminates needlessly searching >quadrants that are within the box but not the circle. That may be unlikely >but is technically possible. > Somewhere I missed that it was mandated we use a box and now I am >worried >that if I implement it my way I MIGHT visit less nodes than using a box. >So why are we using a box? > > My other question would be about the output. The sample file >outputs the >number of nodes visited first. Does our output have to do that? I am >assuming not. It would be much easier to output the cities as we visit >them and count nodes. Then when we are done we could output the number of >nodes visited. Otherwise it seams to me that I have to either do the >search twice, once to count and once to output cities OR store the cities >and output them afterwards. > >Thanx, >Joel > ========================================================================= Date: Wed, 1 Mar 2000 23:30:50 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Mike Schaefer Subject: Re: curious about searching MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I asked Dr. Shaffer in class today and he said the TAs would accept either method of searches. -----Original Message----- From: John Costigan [SMTP:jcostiga@VT.EDU] Sent: Wednesday, March 01, 2000 11:20 PM To: CS2604@LISTSERV.VT.EDU Subject: Re: curious about searching I agree, and I actually did use the more precise method. All it requires is testing nine different regions, (the nine areas created by the four sides of the region, looks like a TIC TAC TOE board), which was only 5 if statements the way I did it, and that was probably the inefficient way, hehehe... -- JC -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Joel Eiholzer Sent: Wednesday, March 01, 2000 10:30 PM To: CS2604@LISTSERV.VT.EDU Subject: Re: curious about searching Sure that makes sense but that is easy enough to check for also. I guess that I will use the box method since it seems to be the accepted idea and I don't want my output to be different from the graders. It just seems to me that if you abstract this out to a MUCH larger system it may check many many nodes that are not in the circle but in the box. I guess that is ok. Thank you very much for your prompt answer. At 10:11 PM 3/1/00 -0500, you wrote: >You can't just check the corners of the region, because what if the search >origin is exactly RADIUS distance from the midpoint of one of the sides of >the region? Then the origin is farther from the corners than RADIUS, but >the region should still be checked... looks (kinda) like this: > ______ >| | >| | >| | >|______| > / \ > | | > \_/ > >I hope that makes sense... > > -- JC > >-----Original Message----- >From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of >Joel Eiholzer >Sent: Wednesday, March 01, 2000 8:27 PM >To: CS2604@LISTSERV.VT.EDU >Subject: curious about searching > > > Why are we bothering with a bounding box at all? Why not use simple >geometry to figure out if the distance between the nearest corner of any >given quadrant and the search origin is less than or equal to the radius. >And if so check the quadrant? That eliminates needlessly searching >quadrants that are within the box but not the circle. That may be unlikely >but is technically possible. > Somewhere I missed that it was mandated we use a box and now I am >worried >that if I implement it my way I MIGHT visit less nodes than using a box. >So why are we using a box? > > My other question would be about the output. The sample file >outputs the >number of nodes visited first. Does our output have to do that? I am >assuming not. It would be much easier to output the cities as we visit >them and count nodes. Then when we are done we could output the number of >nodes visited. Otherwise it seams to me that I have to either do the >search twice, once to count and once to output cities OR store the cities >and output them afterwards. > >Thanx, >Joel > ========================================================================= Date: Wed, 1 Mar 2000 23:55:33 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: Re: curious about searching In-Reply-To: <01BF83D6.2E77B3E0.mischaef@vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii by that did he mean we could come up with different counts compared to the TAs output and still be ok?? At 11:30 PM 03/01/2000 -0500, you wrote: >I asked Dr. Shaffer in class today and he said the TAs would accept either method of searches. > >-----Original Message----- >From: John Costigan [SMTP:jcostiga@VT.EDU] >Sent: Wednesday, March 01, 2000 11:20 PM >To: CS2604@LISTSERV.VT.EDU >Subject: Re: curious about searching > >I agree, and I actually did use the more precise method. All it requires is >testing nine different regions, (the nine areas created by the four sides of >the region, looks like a TIC TAC TOE board), which was only 5 if statements >the way I did it, and that was probably the inefficient way, hehehe... > > -- JC > >-----Original Message----- >From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of >Joel Eiholzer >Sent: Wednesday, March 01, 2000 10:30 PM >To: CS2604@LISTSERV.VT.EDU >Subject: Re: curious about searching > > > Sure that makes sense but that is easy enough to check for also. I >guess >that I will use the box method since it seems to be the accepted idea and I >don't want my output to be different from the graders. It just seems to me >that if you abstract this out to a MUCH larger system it may check many >many nodes that are not in the circle but in the box. I guess that is ok. > > Thank you very much for your prompt answer. > >At 10:11 PM 3/1/00 -0500, you wrote: >>You can't just check the corners of the region, because what if the search >>origin is exactly RADIUS distance from the midpoint of one of the sides of >>the region? Then the origin is farther from the corners than RADIUS, but >>the region should still be checked... looks (kinda) like this: >> ______ >>| | >>| | >>| | >>|______| >> / \ >> | | >> \_/ >> >>I hope that makes sense... >> >> -- JC >> >>-----Original Message----- >>From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of >>Joel Eiholzer >>Sent: Wednesday, March 01, 2000 8:27 PM >>To: CS2604@LISTSERV.VT.EDU >>Subject: curious about searching >> >> >> Why are we bothering with a bounding box at all? Why not use >simple >>geometry to figure out if the distance between the nearest corner of any >>given quadrant and the search origin is less than or equal to the radius. >>And if so check the quadrant? That eliminates needlessly searching >>quadrants that are within the box but not the circle. That may be unlikely >>but is technically possible. >> Somewhere I missed that it was mandated we use a box and now I am >>worried >>that if I implement it my way I MIGHT visit less nodes than using a box. >>So why are we using a box? >> >> My other question would be about the output. The sample file >>outputs the >>number of nodes visited first. Does our output have to do that? I am >>assuming not. It would be much easier to output the cities as we visit >>them and count nodes. Then when we are done we could output the number of >>nodes visited. Otherwise it seams to me that I have to either do the >>search twice, once to count and once to output cities OR store the cities >>and output them afterwards. >> >>Thanx, >>Joel >> > ========================================================================= Date: Thu, 2 Mar 2000 00:45:29 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Mike Schaefer Subject: Re: curious about searching MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Meaning, one way to do the searches is the simple way of using a bounding box. This will give you a certain number of visited nodes. The other way is the more complex way of checking the circle, which gives you a second number of visited nodes. Either is acceptable. Other numbers would probably be incorrect. -----Original Message----- From: david [SMTP:daander5@VT.EDU] Sent: Wednesday, March 01, 2000 11:56 PM To: CS2604@LISTSERV.VT.EDU Subject: Re: curious about searching by that did he mean we could come up with different counts compared to the TAs output and still be ok?? At 11:30 PM 03/01/2000 -0500, you wrote: >I asked Dr. Shaffer in class today and he said the TAs would accept either method of searches. > >-----Original Message----- >From: John Costigan [SMTP:jcostiga@VT.EDU] >Sent: Wednesday, March 01, 2000 11:20 PM >To: CS2604@LISTSERV.VT.EDU >Subject: Re: curious about searching > >I agree, and I actually did use the more precise method. All it requires is >testing nine different regions, (the nine areas created by the four sides of >the region, looks like a TIC TAC TOE board), which was only 5 if statements >the way I did it, and that was probably the inefficient way, hehehe... > > -- JC > >-----Original Message----- >From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of >Joel Eiholzer >Sent: Wednesday, March 01, 2000 10:30 PM >To: CS2604@LISTSERV.VT.EDU >Subject: Re: curious about searching > > > Sure that makes sense but that is easy enough to check for also. I >guess >that I will use the box method since it seems to be the accepted idea and I >don't want my output to be different from the graders. It just seems to me >that if you abstract this out to a MUCH larger system it may check many >many nodes that are not in the circle but in the box. I guess that is ok. > > Thank you very much for your prompt answer. > >At 10:11 PM 3/1/00 -0500, you wrote: >>You can't just check the corners of the region, because what if the search >>origin is exactly RADIUS distance from the midpoint of one of the sides of >>the region? Then the origin is farther from the corners than RADIUS, but >>the region should still be checked... looks (kinda) like this: >> ______ >>| | >>| | >>| | >>|______| >> / \ >> | | >> \_/ >> >>I hope that makes sense... >> >> -- JC >> >>-----Original Message----- >>From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of >>Joel Eiholzer >>Sent: Wednesday, March 01, 2000 8:27 PM >>To: CS2604@LISTSERV.VT.EDU >>Subject: curious about searching >> >> >> Why are we bothering with a bounding box at all? Why not use >simple >>geometry to figure out if the distance between the nearest corner of any >>given quadrant and the search origin is less than or equal to the radius. >>And if so check the quadrant? That eliminates needlessly searching >>quadrants that are within the box but not the circle. That may be unlikely >>but is technically possible. >> Somewhere I missed that it was mandated we use a box and now I am >>worried >>that if I implement it my way I MIGHT visit less nodes than using a box. >>So why are we using a box? >> >> My other question would be about the output. The sample file >>outputs the >>number of nodes visited first. Does our output have to do that? I am >>assuming not. It would be much easier to output the cities as we visit >>them and count nodes. Then when we are done we could output the number of >>nodes visited. Otherwise it seams to me that I have to either do the >>search twice, once to count and once to output cities OR store the cities >>and output them afterwards. >> >>Thanx, >>Joel >> > ========================================================================= Date: Thu, 2 Mar 2000 10:16:19 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Richard Bowman Subject: Re: curious about searching MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit david wrote: > > by that did he mean we could come up with different counts compared to the > TAs output and still be ok?? > If you use the bounding box instead of circle to initially check to see whether to visit a quadrant, you still _need_ to use the circle method when you actually find a leaf. So no, your count should be exactly the same. Richard ========================================================================= Date: Thu, 2 Mar 2000 11:50:42 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: curious about searching In-Reply-To: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 1 Mar 2000, John Costigan wrote: > I agree, and I actually did use the more precise method. All it requires is > testing nine different regions, (the nine areas created by the four sides of > the region, looks like a TIC TAC TOE board), which was only 5 if statements > the way I did it, and that was probably the inefficient way, hehehe... Very good! That sounds exactly right. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Thu, 2 Mar 2000 11:58:35 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brian Wood Subject: Re: curious about searching MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_lzwjsbQEKdR/y02SmU8B4g)" This is a multi-part message in MIME format. --Boundary_(ID_lzwjsbQEKdR/y02SmU8B4g) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable > I am in Dr. Shaffer's class, and this was discussed today. When = traversing > the tree, you perform 2 tests. > Test1: Does the outlinebox intersect a quadrant? If so, visit that > quadrant. > Test2: If a leafnode is reached, and it is not Null/Flyweight, then > run the if (radius^2) <=3D = ((cityx-circlex)^2+(cityy-circley)^2)) > thingy to see if a specific coordinate lies within the = circle. I'm a little confused...with this test 2 will the outcome be TRUE if the = city coordinate is in the search circle? Take for example a search = circle with x =3D 0 , y =3D 0 and a radius of 10. If there is a city in = the map with coordinates (1, 1) wouldn't the results be 100 <=3D (1)^2 + (1)^2 which would be FALSE but isn't (1, 1) in the search circle??? should it be if (radius^2) >=3D ((cityx-circlex)^2+(cityy-circley)^2)) = ? --Boundary_(ID_lzwjsbQEKdR/y02SmU8B4g) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
> I am in Dr. Shaffer's class, and this was discussed = today.  When=20 traversing
> the tree, you perform 2 tests.
> Test1:  = Does the=20 outlinebox intersect a quadrant?  If so, visit that
>=20 quadrant.
> Test2:  If a leafnode is reached, and it is not=20 Null/Flyweight, then
>=20           run the if = (radius^2)=20 <=3D ((cityx-circlex)^2+(cityy-circley)^2))
>=20           thingy to see if = a=20 specific coordinate lies within the circle.

 
I'm a little confused...with this test 2 will the outcome be TRUE = if the=20 city coordinate is in the search circle?  Take for example a search = circle=20 with x =3D 0 , y =3D 0 and a radius of 10.  If there is a city = in the map=20 with coordinates (1, 1) wouldn't the results be
100 <=3D (1)^2 + (1)^2
which would be FALSE
 
but isn't (1, 1) in the search circle???
should it be  if (radius^2) >=3D=20 ((cityx-circlex)^2+(cityy-circley)^2)) ?
--Boundary_(ID_lzwjsbQEKdR/y02SmU8B4g)-- ========================================================================= Date: Thu, 2 Mar 2000 14:14:25 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: Lecture notes question In-Reply-To: <012c01bf83de$491bcbc0$124723d0@ntc.offcampus.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII This code in the lecture notes is incorrect (I didn't realize that the copy of the lecture notes being distributed still had the bug -- some of you noticed that the slides I use have the correction). The code should be as follows: BinNode* BST::inserthelp(BinNode* rt, const Belem val) { if (rt == NULL) return new BinNode(val, NULL, NULL); if (key(val) < key(rt->value())) rt->left = inserthelp(rt->left, val); else rt->right = inserthelp(rt->right, val); return rt; } root = inserthelp(root, newElem); -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- On Wed, 1 Mar 2000, Saam Tariverdi wrote: > On Page 70 of the lecture notes (Titled "Alternate Approach"), regarding > BST's, the function inserthelp() is of type void. However, the code states: > > if (rt == NULL) > return new BinNode(); > > Can you please tell me why the function returns a value when it's of type > void? Thanks. > > Saam Tariverdi > ========================================================================= Date: Thu, 2 Mar 2000 13:16:11 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brandon Horsley Subject: Debug Output MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit my program works fine except for debug in the sample output it displays: GGG100,200,Blacksburg3000,0,ChristiansburgEEE3000,5000,CharlotteEEGGG700,8500,Alabama1500,8500,DetroitEEE0,11000,Blacksburg3000,11000,McLeanEEE15000,15000,Washington and my output displays: GGG100,200,Blacksburg3000,0,ChristiansburgEEE3000,5000,CharlotteEEGEEGG700,8500,Alabama1500,8500,DetroitEEE0,11000,Blacksburg3000,11000,McLeanE15000,15000,Washington If anyone has any idea why my debug (or actual tree structure) could produce this output instead of the desired output -- please help! ========================================================================= Date: Thu, 2 Mar 2000 14:52:04 -0500 Reply-To: joowens@vt.edu Sender: CS2604 discussion list From: John Owens Subject: Re: curious about searching In-Reply-To: <025e01bf8468$8c282690$306352c6@wonxly> MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_6pPAWQoZ8dQTDkhvUHoCug)" This is a multi-part message in MIME format. --Boundary_(ID_6pPAWQoZ8dQTDkhvUHoCug) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Sorry, I wasn't giving a specific example, the equation i used there was simply from one of dr. shaffer's emails... i havent used it yet. Question Though : Nodes visited.. is this every internal node visited and every non-empty data node? for instance if we have this tree o | ---------------------------- | | | | A null o null | ------------------------ | | | | B null null null and all of the tree is included in the bounding box, how many nodes would be visited? -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Brian Wood Sent: Thursday, March 02, 2000 11:59 AM To: CS2604@LISTSERV.VT.EDU Subject: Re: curious about searching > I am in Dr. Shaffer's class, and this was discussed today. When traversing > the tree, you perform 2 tests. > Test1: Does the outlinebox intersect a quadrant? If so, visit that > quadrant. > Test2: If a leafnode is reached, and it is not Null/Flyweight, then > run the if (radius^2) <= ((cityx-circlex)^2+(cityy-circley)^2)) > thingy to see if a specific coordinate lies within the circle. I'm a little confused...with this test 2 will the outcome be TRUE if the city coordinate is in the search circle? Take for example a search circle with x = 0 , y = 0 and a radius of 10. If there is a city in the map with coordinates (1, 1) wouldn't the results be 100 <= (1)^2 + (1)^2 which would be FALSE but isn't (1, 1) in the search circle??? should it be if (radius^2) >= ((cityx-circlex)^2+(cityy-circley)^2)) ? -- --Boundary_(ID_6pPAWQoZ8dQTDkhvUHoCug) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
Sorry,=20 I wasn't giving a specific example, the equation i used there was = simply=20 from one
of dr.=20 shaffer's emails... i havent used it=20 yet.   
 
Question Though : Nodes visited.. is this = every=20 internal node visited and every non-empty data node? =
for=20 instance if we have this tree
 
       &nbs= p;      =20 o
       &nbs= p;      =20 |
----------------------------
|     =20 |          =20 |       |
A   null    = ;   =20 o    null
       &nbs= p;         =20 |
       &nbs= p;=20 ------------------------
       &nbs= p;=20 |      |      =20 |        |
       =20 B    null   null  =20 null
 
and=20 all of the tree is included in the bounding box, how many nodes would be = visited?
-----Original Message-----
From: CS2604 discussion = list=20 [mailto:CS2604@listserv.vt.edu]On Behalf Of Brian = Wood
Sent:=20 Thursday, March 02, 2000 11:59 AM
To:=20 CS2604@LISTSERV.VT.EDU
Subject: Re: curious about=20 searching

> I am in Dr. Shaffer's class, and this was discussed = today. =20 When traversing
> the tree, you perform 2 tests.
> = Test1: =20 Does the outlinebox intersect a quadrant?  If so, visit = that
>=20 quadrant.
> Test2:  If a leafnode is reached, and it is not = Null/Flyweight, then
>=20           run the if = (radius^2)=20 <=3D ((cityx-circlex)^2+(cityy-circley)^2))
>=20           thingy to see = if a=20 specific coordinate lies within the circle.

 
I'm a little confused...with this test 2 will the outcome be TRUE = if the=20 city coordinate is in the search circle?  Take for example a = search=20 circle with x =3D 0 , y =3D 0 and a radius of 10.  If there = is a city in=20 the map with coordinates (1, 1) wouldn't the results be
100 <=3D (1)^2 + (1)^2
which would be FALSE
 
but isn't (1, 1) in the search circle???
should it be  if (radius^2) >=3D=20 ((cityx-circlex)^2+(cityy-circley)^2)) ?

--
 
<= /BODY> --Boundary_(ID_6pPAWQoZ8dQTDkhvUHoCug)-- ========================================================================= Date: Thu, 2 Mar 2000 16:48:22 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: More on flyweight implementation MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII There was a discussion earlier about whether to create a separate class for the flyweight, or simply make it an object of the leafnode class. There turns out to be a strong argument for making it a separate class. This has nothing to do with design logic, but rather with getting along with C++. The problem with making the flyweight an object of the leafnode class is how to create the constructor. The most natual thing to do is something like: PRNode* ptr1 = new LeafNode(); // flyweight = empty node PRNode* ptr2 = new LeafNode(CityRec); // full leaf node The problem is that "new" doesn't see the parameter list, and the constructor cannot (at least, not without a lot of cleverness) control what "new" returns. If, instead, you do: PRNode* ptr1 = new EmptyLeaf(); // flyweight = empty node PRNode* ptr2 = new FullLeaf(); // full leaf node It is simple to implement, and you still get the desired benefit that, later on, there is no need for the code to understand the implementation internals of the nodes (only at node creation time to you need to know which type it is, which of course you have to know anyway). -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Thu, 2 Mar 2000 16:55:06 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: curious about searching In-Reply-To: <000801bf8480$c9346e00$0201a8c0@vtacs.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII You should count everytime you had to determine what the type of a node is. That is, you should count the empty nodes that the bounding box intersects, because you can't know that something is an empty node without "looking" at it in some way. It doesn't matter how you implement the node -- you still have to recognize that somebody's child is, in fact, empty, so that counts as a "node visit". For example, consider the case of a tree consisting of an internal node and four leaf children, such that the NW and NE children each contain a city. Now, consider a query circle that intersects the NE and SE nodes. Thus, the query circle intersects the internal node, the NW (full) leaf, and the SE (empty) leaf. As a result, the correct response is that 3 nodes are visited. It doesn't matter what implementation you use -- its a function of the logical representation, not the physical implementation. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Thu, 2 Mar 2000 16:00:53 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Saam Tariverdi Subject: Insert function MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Can someone look at this code and tell me if it's fairly correct? This is just code for inserting into the NW quadrant: Node* PRTree::inserthelp(Node *rt, Data data) { if (rt == NULL) return new LeafNode(data); // if inserting into NW quadrant if ((data.GetX() < (width / 2)) && ((data.GetY() < (width / 2))) { if (rt->isLeaf()) return new IntNode(((LeafNode *)rt), NULL, NULL, NULL); if (!rt->isLeaf()) ((IntNode *)rt)->NW = inserthelp(((IntNode *)rt)->NW, data); } I tried to run debugger to see if everything is getting inserted in properly, but I can't seem to actually what's pointing to what. Any help is appreciated. Thanks. Saam Tariverdi ========================================================================= Date: Thu, 2 Mar 2000 17:21:34 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: Insert function In-Reply-To: <006301bf848a$65cdc280$124723d0@ntc.offcampus.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Thu, 2 Mar 2000, Saam Tariverdi wrote: > Can someone look at this code and tell me if it's fairly correct? This is > just code for inserting into the NW quadrant: > > Node* PRTree::inserthelp(Node *rt, Data data) { > if (rt == NULL) > return new LeafNode(data); > > // if inserting into NW quadrant > if ((data.GetX() < (width / 2)) && ((data.GetY() < (width / 2))) { > if (rt->isLeaf()) > return new IntNode(((LeafNode *)rt), NULL, NULL, NULL); > if (!rt->isLeaf()) > ((IntNode *)rt)->NW = inserthelp(((IntNode *)rt)->NW, data); > } No, its not correct. You don't return a value as a result of inserting to an internal node. So, things must fail higher up in the tree. You should never have gotten to the debugging stage, since your compiler should have generated at least a warning that the function is ill-formed (not returning a value from some branch of a function with a return type). Better would be if compilers simply generated an error in this case, and didn't let the program compile, but we aren't that fortunate. Did you ignore the warning? If it didn't generate a warning, set the warning level higher in your options settings. BTW, the last "if" test is unnecessary. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Thu, 2 Mar 2000 16:34:54 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Saam Tariverdi Subject: Re: Insert function MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Actually, I didn't copy down the entire function (I forgot to put down that last return statement). Here it is in full-form: Node* PRTree::inserthelp(Node *rt, Data data) { if (rt == NULL) return new LeafNode(data); // if inserting into NW quadrant if ((data.GetX() < (width / 2)) && (data.GetY() < (width / 2))) { if (rt->isLeaf()) return new IntNode(((LeafNode *)rt), NULL, NULL, NULL); else ((IntNode *)rt)->NW = inserthelp(((IntNode *)rt)->NW, data); } return rt; } I fixed the last 'if' statement to make it into an 'else'. Are things correct now? Thanks. ----- Original Message ----- From: Cliff Shaffer To: Sent: Thursday, March 02, 2000 5:21 PM Subject: Re: Insert function > On Thu, 2 Mar 2000, Saam Tariverdi wrote: > > > Can someone look at this code and tell me if it's fairly correct? This is > > just code for inserting into the NW quadrant: > > > > Node* PRTree::inserthelp(Node *rt, Data data) { > > if (rt == NULL) > > return new LeafNode(data); > > > > // if inserting into NW quadrant > > if ((data.GetX() < (width / 2)) && ((data.GetY() < (width / 2))) { > > if (rt->isLeaf()) > > return new IntNode(((LeafNode *)rt), NULL, NULL, NULL); > > if (!rt->isLeaf()) > > ((IntNode *)rt)->NW = inserthelp(((IntNode *)rt)->NW, data); > > } > > No, its not correct. You don't return a value as a result of inserting to > an internal node. So, things must fail higher up in the tree. > You should never have gotten to the debugging stage, since your compiler > should have generated at least a warning that the function is ill-formed > (not returning a value from some branch of a function with a return type). > Better would be if compilers simply generated an error in this case, and > didn't let the program compile, but we aren't that fortunate. Did > you ignore the warning? If it didn't generate a warning, set the > warning level higher in your options settings. > > BTW, the last "if" test is unnecessary. > > -- > Cliff Shaffer, Associate Professor Phone: (540) 231-4354 > Department of Computer Science Email: shaffer@cs.vt.edu > Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer > ------------------------------------------------------------------------- ========================================================================= Date: Thu, 2 Mar 2000 16:39:57 -0500 Reply-To: joowens@vt.edu Sender: CS2604 discussion list From: John Owens Subject: Re: More on flyweight implementation In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Question. I am using inheritance. class Node class LeafNode : public Node class ParentNode : public Node now, considering i have a static LeafNode* flyweight and i am passing down Node*'s in my remove function. I want to check if there is 1 and only 1 data node and no internal nodes. first i would do checks on all 4 children isLeaf(), and if they are all true, to check if one of those leafs equaled the flyweight node would i have to do 1 or two typecasts here? Would I do this? if ( ((ParentNode*)node)->getNW()==flyweight) -OR- THIS if ( ((LeafNode*)((ParentNode*)node)->getNW())==flyweight) or am i going about the flyweight comparisons all wrong? I am confused on how to do this correctly. -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Cliff Shaffer Sent: Thursday, March 02, 2000 4:48 PM To: CS2604@LISTSERV.VT.EDU Subject: More on flyweight implementation There was a discussion earlier about whether to create a separate class for the flyweight, or simply make it an object of the leafnode class. There turns out to be a strong argument for making it a separate class. This has nothing to do with design logic, but rather with getting along with C++. The problem with making the flyweight an object of the leafnode class is how to create the constructor. The most natual thing to do is something like: PRNode* ptr1 = new LeafNode(); // flyweight = empty node PRNode* ptr2 = new LeafNode(CityRec); // full leaf node The problem is that "new" doesn't see the parameter list, and the constructor cannot (at least, not without a lot of cleverness) control what "new" returns. If, instead, you do: PRNode* ptr1 = new EmptyLeaf(); // flyweight = empty node PRNode* ptr2 = new FullLeaf(); // full leaf node It is simple to implement, and you still get the desired benefit that, later on, there is no need for the code to understand the implementation internals of the nodes (only at node creation time to you need to know which type it is, which of course you have to know anyway). -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Thu, 2 Mar 2000 16:38:31 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Mike Schaefer Subject: this pointer MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Does anyone know how to reassign "this"? ========================================================================= Date: Thu, 2 Mar 2000 18:04:00 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: Insert function In-Reply-To: <001901bf848f$26ae2540$124723d0@ntc.offcampus.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII I still see one problem, and one issue not addressed by the code fragment. The problem is: What do you do if the node is an empty leaf? If so, you should replace it with a full leaf, not make it internal with a new leaf. This is the trickiest part of the function to get right, in my opinion. The issue not addressed is: How do you know the bounding box for the node? The best bet is to pass this in (preferably as a "box object", or else as three int parameters). You have no such parameters. In fact, your test only works when the node's NW corner is the origin. You need something more like if ((city->x < nodebox->x + nodebox->width/2) && (city->y < nodebox->y + nodebox->width/2)) Do NW case; -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- On Thu, 2 Mar 2000, Saam Tariverdi wrote: > Actually, I didn't copy down the entire function (I forgot to put down that > last return statement). Here it is in full-form: > > Node* PRTree::inserthelp(Node *rt, Data data) { > if (rt == NULL) > return new LeafNode(data); > // if inserting into NW quadrant > > if ((data.GetX() < (width / 2)) && (data.GetY() < (width / 2))) { > if (rt->isLeaf()) > return new IntNode(((LeafNode *)rt), NULL, NULL, NULL); > else > ((IntNode *)rt)->NW = inserthelp(((IntNode *)rt)->NW, data); > } > return rt; > } > > > I fixed the last 'if' statement to make it into an 'else'. Are things > correct now? Thanks. > > ----- Original Message ----- > From: Cliff Shaffer > To: > Sent: Thursday, March 02, 2000 5:21 PM > Subject: Re: Insert function > > > > On Thu, 2 Mar 2000, Saam Tariverdi wrote: > > > > > Can someone look at this code and tell me if it's fairly correct? This > is > > > just code for inserting into the NW quadrant: > > > > > > Node* PRTree::inserthelp(Node *rt, Data data) { > > > if (rt == NULL) > > > return new LeafNode(data); > > > > > > // if inserting into NW quadrant > > > if ((data.GetX() < (width / 2)) && ((data.GetY() < (width / 2))) { > > > if (rt->isLeaf()) > > > return new IntNode(((LeafNode *)rt), NULL, NULL, NULL); > > > if (!rt->isLeaf()) > > > ((IntNode *)rt)->NW = inserthelp(((IntNode *)rt)->NW, data); > > > } > > > > No, its not correct. You don't return a value as a result of inserting to > > an internal node. So, things must fail higher up in the tree. > > You should never have gotten to the debugging stage, since your compiler > > should have generated at least a warning that the function is ill-formed > > (not returning a value from some branch of a function with a return type). > > Better would be if compilers simply generated an error in this case, and > > didn't let the program compile, but we aren't that fortunate. Did > > you ignore the warning? If it didn't generate a warning, set the > > warning level higher in your options settings. > > > > BTW, the last "if" test is unnecessary. > > > > -- > > Cliff Shaffer, Associate Professor Phone: (540) 231-4354 > > Department of Computer Science Email: shaffer@cs.vt.edu > > Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer > > ------------------------------------------------------------------------- > ========================================================================= Date: Thu, 2 Mar 2000 17:11:44 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: David Cook Subject: chordniate map MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_MuMHVPf/dBu6fF3L70E0fA)" This is a multi-part message in MIME format. --Boundary_(ID_MuMHVPf/dBu6fF3L70E0fA) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable Well I finally broke down and made the map for the sample input file in = Visio. It is a VERY helpful tool to see the whole map when tracing = through your remove functions so I'm going offer it to anyone who wants = it. I can put it in a word document (sorry StarOffice users, I don't = think it'll work) and send it to you, so if you want it email me = PRIVATELY (there is already LOTS of traffic on the list serv) and I'd be = happy to send it to you. Later, and good luck -Dave C --Boundary_(ID_MuMHVPf/dBu6fF3L70E0fA) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
Well I finally broke down and made the = map for the=20 sample input file in Visio.  It is a VERY helpful tool to see the = whole map=20 when tracing through your remove functions so I'm going offer it to = anyone who=20 wants it.  I can put it in a word document (sorry StarOffice users, = I don't=20 think it'll work) and send it to you, so if you want it email me = PRIVATELY=20 (there is already LOTS of traffic on the list serv) and I'd be happy to = send it=20 to you.
 
Later, and good luck
-Dave C
--Boundary_(ID_MuMHVPf/dBu6fF3L70E0fA)-- ========================================================================= Date: Thu, 2 Mar 2000 17:24:34 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: James Moniz Subject: Re: curious about searching Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" >You should count everytime you had to determine what the type of a node >is. That is, you should count the empty nodes that the bounding box >intersects, because you can't know that something is an empty node without >"looking" at it in some way. It doesn't matter how you implement the >node -- you still have to recognize that somebody's child is, in fact, >empty, so that counts as a "node visit". >For example, consider the case of a tree consisting of an internal node >and four leaf children, such that the NW and NE children each contain a >city. Now, consider a query circle that intersects the NE and SE nodes. >Thus, the query circle intersects the internal node, the NW (full) leaf, >and the SE (empty) leaf. As a result, the correct response is that 3 >nodes are visited. It doesn't matter what implementation you use -- its a >function of the logical representation, not the physical implementation. It would have been nice if at least one of the examples in the test input file actually came across an empty node so that we could see that this is how it is supposed to be. Personally, I believe that a "logical representation" of looking at a node is not just coming across it, but the actual act of checking to see if it has a position in space that might fall in the search range. Empty/blank nodes hold no coordinates, or even care about coordinates (like internal nodes), so why would I check it? Out on a leaf, only the city object knows about coordinates, so I would say that I didn't even check it. (I did not use the leaf node flyweight implementation, 'cause the whole checking memory address idea is kinda hinky to me, and you waste the space of an empty pointer that you cannot use. I did not use NULLs either.) Anyway, what is obvious in one person's head is not so obvious in everyone else's. James Moniz jmoniz@vt.edu ========================================================================= Date: Thu, 2 Mar 2000 19:48:44 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: =?iso-8859-1?Q?=A7=EDd=EBsm=E2=E7k?= Subject: Requesting Alternate Test files In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Would it be possible to provide subsequent Test data for our project so that we can be more assured of our code? Even one more set would be greatly appreciated. Thanks, - Їэdыsmтчk ========================================================================= Date: Thu, 2 Mar 2000 17:21:13 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jeremy Lerner Subject: Re: curious about searching In-Reply-To: MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=us-ascii Earlier this week, the TAs corrected an error in the sample output file wherein it listed 8 nodes visited rather than 6 on one of the search commands because they had been counting empty leaf nodes as having been visited. It seemed clear after the dust settled on that discussion that empty leaf nodes need not be counted towards the number of nodes visited during the search, and I wrote my search function accordingly. However, it seems that Dr. Shaffer's post contradicts this, indicating that yes, we do need to count empty nodes. If that's the case it's not any big change, should just be one extra line of code, tops, but it'd be nice to have one, final, official answer on this before that early bonus deadline so nobody gets points off for implementing their search function in accordance with the incorrect one of the conflicting answers. >You should count everytime you had to determine what the type of a node >is. That is, you should count the empty nodes that the bounding box >intersects, because you can't know that something is an empty node without >"looking" at it in some way. It doesn't matter how you implement the >node -- you still have to recognize that somebody's child is, in fact, >empty, so that counts as a "node visit". > >For example, consider the case of a tree consisting of an internal node >and four leaf children, such that the NW and NE children each contain a >city. Now, consider a query circle that intersects the NE and SE nodes. >Thus, the query circle intersects the internal node, the NW (full) leaf, >and the SE (empty) leaf. As a result, the correct response is that 3 >nodes are visited. It doesn't matter what implementation you use -- its a >function of the logical representation, not the physical implementation. > >-- >Cliff Shaffer, Associate Professor Phone: (540) 231-4354 >Department of Computer Science Email: shaffer@cs.vt.edu >Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer >------------------------------------------------------------------------- -- Jeremy Lerner - jlerner@vt.edu I'm going to live forever or die trying. ========================================================================= Date: Thu, 2 Mar 2000 20:19:13 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Mike Schaefer Subject: String problems MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I'm having a problem when the following function exits and tries to clean up istrstream. I can't for the life of me figure out what is going on. The error I get is "Unhandled exception in prqt.ext: 0xC0000005: Access Violation" Sounds like istrstream is trying to delete something it doesn't own, but I can't figure out what I'm doing wrong. I've sat here staring at the book and comparing it to my code, I've had a roommate look at it. I've tried using a local array instead of arg_string, and it did the same thing. Any help would be greatly appreciated. { int x_coord; int y_coord; char name[MAX_ARG_LEN + 1]; Record info; // char input[] = " 100 200 Blacksburg"; istrstream args(arg_string); bool result; memset(name, '/0', MAX_ARG_LEN); args >> x_coord >> y_coord >> name; info.SetInfo(x_coord, y_coord, name, strlen(name)); result = tree.Insert(info); return result; } ========================================================================= Date: Thu, 2 Mar 2000 22:27:28 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Mark Subject: echo MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_VN+dWNpH4XgAQYeqSA6MGA)" This is a multi-part message in MIME format. --Boundary_(ID_VN+dWNpH4XgAQYeqSA6MGA) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable The spec says we are to echo the input command and it's parameters. = While i know this is obviously not hard to do, I was just wondering = what's the point of it. If we put descriptive messages about the = execution each command, there should be no need to tell the user what = the command is. Just my two cents Mark --Boundary_(ID_VN+dWNpH4XgAQYeqSA6MGA) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
The spec says we are to echo the input = command and=20 it's parameters.  While i know this is obviously not hard to do, I = was just=20 wondering what's the point of it.  If we put descriptive messages = about the=20 execution each command, there should be no need to tell the user what = the=20 command is.  Just my two cents
 
Mark
--Boundary_(ID_VN+dWNpH4XgAQYeqSA6MGA)-- ========================================================================= Date: Thu, 2 Mar 2000 22:40:17 -0500 Reply-To: joowens@vt.edu Sender: CS2604 discussion list From: John Owens Subject: Re: echo In-Reply-To: <000f01bf84c0$674dc340$666152c6@darboy> MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_cA7DC+xZbvxfbnlyyyNTJQ)" This is a multi-part message in MIME format. --Boundary_(ID_cA7DC+xZbvxfbnlyyyNTJQ) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Is it ok if the echoed commands get rid of the whitespace? -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Mark Sent: Thursday, March 02, 2000 10:27 PM To: CS2604@LISTSERV.VT.EDU Subject: echo The spec says we are to echo the input command and it's parameters. While i know this is obviously not hard to do, I was just wondering what's the point of it. If we put descriptive messages about the execution each command, there should be no need to tell the user what the command is. Just my two cents Mark --Boundary_(ID_cA7DC+xZbvxfbnlyyyNTJQ) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
Is it=20 ok if the echoed commands get rid of the whitespace?
-----Original Message-----
From: CS2604 discussion = list=20 [mailto:CS2604@listserv.vt.edu]On Behalf Of = Mark
Sent:=20 Thursday, March 02, 2000 10:27 PM
To:=20 CS2604@LISTSERV.VT.EDU
Subject: echo

The spec says we are to echo the = input command=20 and it's parameters.  While i know this is obviously not hard to = do, I=20 was just wondering what's the point of it.  If we put descriptive = messages about the execution each command, there should be no need to = tell the=20 user what the command is.  Just my two cents
 
Mark
--Boundary_(ID_cA7DC+xZbvxfbnlyyyNTJQ)-- ========================================================================= Date: Thu, 2 Mar 2000 23:40:46 -0600 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Chris Tjoumas Subject: Concerning Es and Gs MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_EqONo5S7iBz7m3wE3LIpHQ)" This is a multi-part message in MIME format. --Boundary_(ID_EqONo5S7iBz7m3wE3LIpHQ) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable Im looking at the first debug command in the sample output file. I am = getting pretty much the same exact thing as the output for the debug, = the only difference is that I am printing my E's for empty nodes and G's = for internal nodes together. As I am going down an internal node, I = check to see how many E's there are and I print it out AFTER I print the = G's. This does not agree with the order they print their E's and G's, = but I am getting the same number of E's and G's (G's =3D 6 and E's =3D = 11). Does this need to be in order? I know the cities do, but I just = don't see the pattern the TAs are using. If it does need to be in = order, can someone please let me know what the pattern is? Thanks, Chris --Boundary_(ID_EqONo5S7iBz7m3wE3LIpHQ) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
Im looking at the first debug command = in the sample=20 output file.  I am getting pretty much the same exact thing as the = output=20 for the debug, the only difference is that I am printing my E's for = empty nodes=20 and G's for internal nodes together.  As I am going down an = internal node,=20 I check to see how many E's there are and I print it out AFTER I print = the=20 G's.  This does not agree with the order they print their E's and = G's, but=20 I am getting the same number of E's and G's (G's =3D 6 and E's =3D = 11).  Does=20 this need to be in order?  I know the cities do, but I just don't = see the=20 pattern the TAs are using.  If it does need to be in order, can = someone=20 please let me know what the pattern is?
 
Thanks,
 
Chris
--Boundary_(ID_EqONo5S7iBz7m3wE3LIpHQ)-- ========================================================================= Date: Thu, 2 Mar 2000 23:49:21 -0500 Reply-To: joowens@vt.edu Sender: CS2604 discussion list From: John Owens Subject: Re: curious about searching In-Reply-To: <200003022217.RAA14468@smtp-out1.bellatlantic.net> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit you dont have to check memory addresses, it's quite simple. If flyweight=node, then it is empty. my if statements do that, and it works fine. -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of James Moniz Sent: Thursday, March 02, 2000 5:25 PM To: CS2604@LISTSERV.VT.EDU Subject: Re: curious about searching >You should count everytime you had to determine what the type of a node >is. That is, you should count the empty nodes that the bounding box >intersects, because you can't know that something is an empty node without >"looking" at it in some way. It doesn't matter how you implement the >node -- you still have to recognize that somebody's child is, in fact, >empty, so that counts as a "node visit". >For example, consider the case of a tree consisting of an internal node >and four leaf children, such that the NW and NE children each contain a >city. Now, consider a query circle that intersects the NE and SE nodes. >Thus, the query circle intersects the internal node, the NW (full) leaf, >and the SE (empty) leaf. As a result, the correct response is that 3 >nodes are visited. It doesn't matter what implementation you use -- its a >function of the logical representation, not the physical implementation. It would have been nice if at least one of the examples in the test input file actually came across an empty node so that we could see that this is how it is supposed to be. Personally, I believe that a "logical representation" of looking at a node is not just coming across it, but the actual act of checking to see if it has a position in space that might fall in the search range. Empty/blank nodes hold no coordinates, or even care about coordinates (like internal nodes), so why would I check it? Out on a leaf, only the city object knows about coordinates, so I would say that I didn't even check it. (I did not use the leaf node flyweight implementation, 'cause the whole checking memory address idea is kinda hinky to me, and you waste the space of an empty pointer that you cannot use. I did not use NULLs either.) Anyway, what is obvious in one person's head is not so obvious in everyone else's. James Moniz jmoniz@vt.edu ========================================================================= Date: Fri, 3 Mar 2000 00:06:53 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Mike Schaefer Subject: Re: curious about searching MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit The change from 8 to 6 nodes had nothing to do with empty nodes as far as I know. It was a simple miscounting of nodes. -----Original Message----- From: Jeremy Lerner [SMTP:jlerner@VT.EDU] Sent: Thursday, March 02, 2000 5:21 PM To: CS2604@LISTSERV.VT.EDU Subject: Re: curious about searching Earlier this week, the TAs corrected an error in the sample output file wherein it listed 8 nodes visited rather than 6 on one of the search commands because they had been counting empty leaf nodes as having been visited. It seemed clear after the dust settled on that discussion that empty leaf nodes need not be counted towards the number of nodes visited during the search, and I wrote my search function accordingly. However, it seems that Dr. Shaffer's post contradicts this, indicating that yes, we do need to count empty nodes. If that's the case it's not any big change, should just be one extra line of code, tops, but it'd be nice to have one, final, official answer on this before that early bonus deadline so nobody gets points off for implementing their search function in accordance with the incorrect one of the conflicting answers. >You should count everytime you had to determine what the type of a node >is. That is, you should count the empty nodes that the bounding box >intersects, because you can't know that something is an empty node without >"looking" at it in some way. It doesn't matter how you implement the >node -- you still have to recognize that somebody's child is, in fact, >empty, so that counts as a "node visit". > >For example, consider the case of a tree consisting of an internal node >and four leaf children, such that the NW and NE children each contain a >city. Now, consider a query circle that intersects the NE and SE nodes. >Thus, the query circle intersects the internal node, the NW (full) leaf, >and the SE (empty) leaf. As a result, the correct response is that 3 >nodes are visited. It doesn't matter what implementation you use -- its a >function of the logical representation, not the physical implementation. > >-- >Cliff Shaffer, Associate Professor Phone: (540) 231-4354 >Department of Computer Science Email: shaffer@cs.vt.edu >Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer >------------------------------------------------------------------------- -- Jeremy Lerner - jlerner@vt.edu I'm going to live forever or die trying. ========================================================================= Date: Fri, 3 Mar 2000 00:59:18 -0500 Reply-To: joowens@vt.edu Sender: CS2604 discussion list From: John Owens Subject: Typecasting the circle check? In-Reply-To: <025e01bf8468$8c282690$306352c6@wonxly> MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_gvEpaa12U5P4NX43FqMFOA)" This is a multi-part message in MIME format. --Boundary_(ID_gvEpaa12U5P4NX43FqMFOA) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit (radius^2) > = ((cityx-circlex)^2+(cityy-circley)^2)) [John Owens] I have looked at this function and all the variables used are ints, but the data isnt being "stored" into anything. Well when this function gets passed the data for the first search, it comes out correct. However when the second search comes around radius=900, cityx=100, cityy=200, circlex=-10, circley=8200 Now, upon a simple calculation: if (810,000 >= 12,100+64,000,000 this would be false, but even after seeing the debugger with all these numbers in place, after the equation is checked, it runs the THEN statement (equation=true) instead of skipping it. Then when I get to the real node, it finds it false. when it is supposed to be true for Alabama. do I need to somehow typecast this to a long for this to work right? or what seems to be wrong here. I can see nothing wrong in the debugger, and i visit the right nodes, and the right about of nodes. What do I need to do? this is frustrating. --Boundary_(ID_gvEpaa12U5P4NX43FqMFOA) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable

(radius^2) =3D=20 ((cityx-circlex)^2+(cityy-circley)^2))
[John=20 Owens] 
I have looked at this function and all=20 the variables used are ints, but the data isnt being=20 "stored"
into anything.  Well when this = function gets=20 passed the data for the first = search,
it comes out correct.  However when = the second=20 search comes around
radius=3D900, cityx=3D100, cityy=3D200, = circlex=3D-10,=20 circley=3D8200
Now, upon a simple=20 calculation:
if (810,000 >=3D = 12,100+64,000,000   =20 this would be false, but even after seeing the debugger with all these = numbers in place, after the equation is checked, it runs = the THEN=20 statement (equation=3Dtrue) instead of skipping it.  Then when I = get to the=20 real node, it finds it false.  when it is supposed to be=20 true
for Alabama.  do I need to somehow = typecast this=20 to a long for this to work right? or what seems to be wrong = here.  I can=20 see nothing wrong in the debugger, and i visit the right nodes, = and the=20 right about of nodes.  What do I need to do? this is=20 frustrating.
 
 
--Boundary_(ID_gvEpaa12U5P4NX43FqMFOA)-- ========================================================================= Date: Fri, 3 Mar 2000 01:48:12 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Joseph Bowyer Subject: More String Problems MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_xajpO7OvZHyNsGFbj+YphA)" This is a multi-part message in MIME format. --Boundary_(ID_xajpO7OvZHyNsGFbj+YphA) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable i have the same problem, if anyone knows it would help me and the = previous sender --Boundary_(ID_xajpO7OvZHyNsGFbj+YphA) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
i have the same problem, if anyone = knows it would=20 help me and the previous sender
--Boundary_(ID_xajpO7OvZHyNsGFbj+YphA)-- ========================================================================= Date: Fri, 3 Mar 2000 10:32:32 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Joel Eiholzer Subject: Re: Requesting Alternate Test files In-Reply-To: <3.0.5.32.20000302194844.007d4100@mail.vt.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Very much appreciated. At 07:48 PM 3/2/00 -0500, you wrote: >Would it be possible to provide subsequent Test data for our project so >that we can be more assured of our code? >Even one more set would be greatly appreciated. > >Thanks, > - Їэdыsmтчk > ========================================================================= Date: Fri, 3 Mar 2000 12:13:50 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: curious about searching In-Reply-To: <200003022217.RAA14468@smtp-out1.bellatlantic.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Thu, 2 Mar 2000, James Moniz wrote: > Empty/blank nodes hold no coordinates, or even care about coordinates > (like internal nodes), so why would I check it? Answer 1: Because you can't know that until you look. Answer 2: Because that's what you were told to do. To some extent, any such counting mechanism is arbitrary, and what matters is that everyone do the same thing. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Fri, 3 Mar 2000 12:28:29 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: echo In-Reply-To: <000f01bf84c0$674dc340$666152c6@darboy> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Thu, 2 Mar 2000, Mark wrote: > The spec says we are to echo the input command and it's parameters. > While i know this is obviously not hard to do, I was just wondering > what's > the point of it. If we put descriptive messages about the execution > each > command, there should be no need to tell the user what the command is. To repeat my answer from an earlier post (which I shouldn't be needing to do!): We do not require that you "echo" the command in a literal sense. So long as you clearly reproduce the contents of the command, feel free to reformat it. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Fri, 3 Mar 2000 11:49:20 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Chuck Holbrook Subject: Alternate Test files In-Reply-To: <3.0.5.32.20000303103232.009ac8f0@192.168.0.1> MIME-version: 1.0 Content-type: MULTIPART/MIXED; BOUNDARY="Boundary_(ID_3gzSafyq4MrVAtcdnd+gzQ)" This is a multi-part message in MIME format. --Boundary_(ID_3gzSafyq4MrVAtcdnd+gzQ) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Here are some more test files that I made up myself. They are not garunteed to be correct. If you use these files and find an error with them please email me back. --Boundary_(ID_3gzSafyq4MrVAtcdnd+gzQ) Content-type: text/plain; CHARSET=US-ASCII; name=input.txt Content-disposition: attachment; filename=input.txt Content-transfer-encoding: 7bit debug makenull remove 3000 5000 insert 700 8500 Alabama insert 1500 8500 Detroit insert 3000 0 Christiansburg debug search 1500 8500 10 makenull search 1500 8500 10 debug insert 100 200 Blacksburg remove 100 200 insert 100 200 Jamesburg debug insert 3000 11000 McLean insert 0 11000 Blacksburg insert 3000 5000 Charlotte insert 15000 15000 Washington insert 700 8500 Alabama insert 1500 8500 Detroit insert 3000 0 Christiansburg debug remove 3000 5000 remove 3000 5000 debug remove 3000 0 debug remove 0 11000 debug search -100 -100 10 search 3100 11100 200 insert 0 0 Mexico search -10 0 10 search -10 8200 900 makenull makenull debug --Boundary_(ID_3gzSafyq4MrVAtcdnd+gzQ) Content-type: text/plain; CHARSET=US-ASCII; name=output.txt Content-disposition: attachment; filename=output.txt Content-transfer-encoding: quoted-printable debug The preorder listing is as follows: E makenull Database has been Initialized! remove 3000 5000=20 ERROR: No city to remove at (3000, 5000)! insert 700 8500 Alabama City Alabama inserted at (700, 8500) successfully insert 1500 8500 Detroit City Detroit inserted at (1500, 8500) successfully insert 3000 0 Christiansburg City Christiansburg inserted at (3000, 0) successfully debug The preorder listing is as follows: G3000,0,ChristiansburgEGGG700,8500,Alabama1500,8500,DetroitEEEEEEEEE search 1500 8500 10 The following cities lie within radius of 10 of the point (1500, 8500) (1500, 8500) Detroit Number of Nodes Visited =3D 5 makenull Database has been Initialized! search 1500 8500 10 The following cities lie within radius of 10 of the point (1500, 8500) Number of Nodes Visited =3D 1 debug The preorder listing is as follows: E insert 100 200 Blacksburg City Blacksburg inserted at (100, 200) successfully remove 100 200 Removed Blacksburg insert 100 200 Jamesburg City Jamesburg inserted at (100, 200) successfully debug The preorder listing is as follows: 100,200,Jamesburg insert 3000 11000 McLean City McLean inserted at (3000, 11000) successfully insert 0 11000 Blacksburg City Blacksburg inserted at (0, 11000) successfully insert 3000 5000 Charlotte City Charlotte inserted at (3000, 5000) successfully insert 15000 15000 Washington City Washington inserted at (15000, 15000) successfully insert 700 8500 Alabama City Alabama inserted at (700, 8500) successfully insert 1500 8500 Detroit City Detroit inserted at (1500, 8500) successfully insert 3000 0 Christiansburg City Christiansburg inserted at (3000, 0) successfully debug The preorder listing is as follows: GGG100,200,Jamesburg3000,0,ChristiansburgEEE3000,5000,CharlotteEEGGG700,8= 500,Alabama1500,8500,DetroitEEE0,11000,Blacksburg3000,11000,McLeanEEE1500= 0,15000,Washington remove 3000 5000=20 Removed Charlotte remove 3000 5000 ERROR: No city to remove at (3000, 5000)! debug The preorder listing is as follows: GGG100,200,Jamesburg3000,0,ChristiansburgEEEEEEGGG700,8500,Alabama1500,85= 00,DetroitEEE0,11000,Blacksburg3000,11000,McLeanEEE15000,15000,Washington= remove 3000 0 Removed Christiansburg debug The preorder listing is as follows: G100,200,JamesburgEGGG700,8500,Alabama1500,8500,DetroitEEE0,11000,Blacksb= urg3000,11000,McLeanEEE15000,15000,Washington remove 0 11000 Removed Blacksburg debug The preorder listing is as follows: G100,200,JamesburgEGGG700,8500,Alabama1500,8500,DetroitEEEE3000,11000,McL= eanEEE15000,15000,Washington search -100 -100 10 ERROR: Search at (-100, -100) is outside the range of the root node! search 3100 11100 200 The following cities lie within radius of 200 of the point (3100, 11100) (3000, 11000) McLean Number of Nodes Visited =3D 4 insert 0 0 Mexico City Mexico inserted at (0, 0) successfully search -10 0 10 The following cities lie within radius of 10 of the point (-10, 0) (0, 0) Mexico Number of Nodes Visited =3D 8 search -10 8200 900 The following cities lie within radius of 900 of the point (-10, 8200) (700, 8500) Alabama Number of Nodes Visited =3D 7 makenull Database has been Initialized! makenull Database has been Initialized! debug The preorder listing is as follows: E --Boundary_(ID_3gzSafyq4MrVAtcdnd+gzQ)-- ========================================================================= Date: Fri, 3 Mar 2000 12:44:43 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: Concerning Es and Gs In-Reply-To: <004a01bf84d3$0715d360$3e35ad80@computer> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Thu, 2 Mar 2000, Chris Tjoumas wrote: > Im looking at the first debug command in the sample output file. I am > getting pretty much the same exact thing as the output for the debug, > the > only difference is that I am printing my E's for empty nodes and G's for > internal nodes together. As I am going down an internal node, I check > to > see how many E's there are and I print it out AFTER I print the G's. > This > does not agree with the order they print their E's and G's, but I am > getting the same number of E's and G's (G's = 6 and E's = 11). Does > this > need to be in order? I know the cities do, but I just don't see the > pattern the TAs are using. If it does need to be in order, can someone > please let me know what the pattern is? The listing is generated by a standard pre-order traversal of the tree. No deviations from this will be considered correct. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- > > Thanks, > > Chris > ========================================================================= Date: Fri, 3 Mar 2000 12:04:21 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: "John Anthony Kazos Jr." Subject: Re: Typecasting the circle check? In-Reply-To: <000001bf84d5$9dd44d20$0201a8c0@vtacs.com> MIME-version: 1.0 Content-type: TEXT/PLAIN; charset=US-ASCII Does your code actually say > (radius^2) > = ((cityx-circlex)^2+(cityy-circley)^2)) or do you actually do "radius * radius"... or "pow(radius,2)"...? If you are using ^, that's your problem; ^ is bitwise XOR. If you're not doing that, I don't know what could be the problem. I'm using "signed int" and "unsigned int" in all places, and it works perfectly. ========================================================================= Date: Fri, 3 Mar 2000 17:05:56 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: 6th node on search 2 MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Does anyone know if the 6th node on search #2 is refering to (1500, 8500) Detroit?? ========================================================================= Date: Fri, 3 Mar 2000 20:06:53 -0500 Reply-To: csharp@vt.edu Sender: CS2604 discussion list From: Chris Sharp Subject: remove function MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit I need to some help on my remove function. Seems to work fine until you get into a situation in which you remove Charlotte and then remove Christiansburg....This results in Blacksburg being the only leafnode on a subtree two internal nodes deep. Thus my dilemma is that I must somehow remove these two internal nodes so that Blacksburg is the NW pointer off the root. And I am not sure how I can use recursion in the remove function since the function of the remove command is to remove one node. Also I thought about calling another function and cleaning up the part of the tree above me...but then I don't know what's above me without having some sort of parent pointer. Any help/suggestions would be greatly appreciated. Chris ========================================================================= Date: Fri, 3 Mar 2000 21:21:58 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Saam Tariverdi Subject: looking at tree values? MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit I have a quick question: How do I look at the city values in each Leaf Node in my tree, in the debugger? I tried using ((IntNode *)root) and then expanding it in the debugger..but it only goes down 1 level...Can someone shed some light on this? Thanks. Saam Tariverdi ========================================================================= Date: Sat, 4 Mar 2000 16:12:33 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Saam Tariverdi Subject: Insert bug.. MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit I've implemented my insert function and the debug function; however, when the debug function makes a printout of the tree, it appears that my tree is storing the same city name for each city node. Apparently, when I insert in a new city record, the city name that I pass into the insert function *overwrites* the city name variable in all the current city nodes in my tree.. so basically, the last city name that is inserted into the tree is what appears in ALL of my nodes during the printout of the tree. I can't figure out why it is doing this, so perhaps one of you could give me some input on this? Thanks in advance. Saam Tariverdi ========================================================================= Date: Sat, 4 Mar 2000 17:03:14 -0500 Reply-To: joowens@vt.edu Sender: CS2604 discussion list From: John Owens Subject: Re: Insert bug.. In-Reply-To: <001301bf861e$5c1b5820$124723d0@ntc.offcampus.vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Yes.. are you reading it in as a char city[num] num being any number and then passing a char*? well the char* just points to the city variable in your I/O function. So what you have to do is store the variable in your node as something like city[num] instead of char* otherwise everynode will point to whatever is in the char city[num] variable in your I/O function. You pass it as a char*, but you store it in a character array. -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Saam Tariverdi Sent: Saturday, March 04, 2000 4:13 PM To: CS2604@LISTSERV.VT.EDU Subject: Insert bug.. I've implemented my insert function and the debug function; however, when the debug function makes a printout of the tree, it appears that my tree is storing the same city name for each city node. Apparently, when I insert in a new city record, the city name that I pass into the insert function *overwrites* the city name variable in all the current city nodes in my tree.. so basically, the last city name that is inserted into the tree is what appears in ALL of my nodes during the printout of the tree. I can't figure out why it is doing this, so perhaps one of you could give me some input on this? Thanks in advance. Saam Tariverdi ========================================================================= Date: Sat, 4 Mar 2000 17:33:22 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Neal Hock Subject: Getting a new line In-Reply-To: <000001bf8625$710c32c0$0201a8c0@vtacs.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Okay, I have a questioin (probably stupid) about getting a new line on an output. I am using the std::string class and I do something like std::string s1; std::cin >> s1; std::cout << s1; I have tried doing std::cout << s1 << endl; and that gives me garbage tacked onto my string, and still doesn't give me a new line. Also, I have tried std::cout << s1 << '/n'; and that also gives me garbage. Please let me know how to get a new line if you know!!! Thanks in advance, Neal ========================================================================= Date: Sat, 4 Mar 2000 17:42:56 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Neal Hock Subject: Re: Getting a new line In-Reply-To: <000001bf8625$710c32c0$0201a8c0@vtacs.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Please disregard my last message, it was something very stupid. I needed to be using '\n', not '/n'. Sorry to be bothersome............ ========================================================================= Date: Sat, 4 Mar 2000 20:54:10 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: Insert bug.. In-Reply-To: <001301bf861e$5c1b5820$124723d0@ntc.offcampus.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII My guess is that you have one buffer for you name string that you keep passing to your city records, or nodes, or whatever, so that all of your nodes are pointing to the same memory space for the name. So, if you change it for one, you have changed it for all of them. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- On Sat, 4 Mar 2000, Saam Tariverdi wrote: > I've implemented my insert function and the debug function; however, when > the debug function makes a printout of the tree, it appears that my tree is > storing the same city name for each city node. > > Apparently, when I insert in a new city record, the city name that I pass > into the insert function *overwrites* the city name variable in all the > current city nodes in my tree.. so basically, the last city name that is > inserted into the tree is what appears in ALL of my nodes during the > printout of the tree. I can't figure out why it is doing this, so perhaps > one of you could give me some input on this? Thanks in advance. > > Saam Tariverdi > ========================================================================= Date: Sat, 4 Mar 2000 19:42:20 -0800 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Luck Subject: Setting pointer values MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit I was wandering how to set the actual data a pointer is pointing at, I have tried this already and it doesn't change the value of rt at all. void PRQuadTree::Set(Node*& rt,Node* value) { *rt = *value; } any suggestions? ========================================================================= Date: Sat, 4 Mar 2000 20:33:32 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Ben Allison Subject: Re: Setting pointer values MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Jason Luck asked this about pointer: > > I was wandering how to set the actual data a pointer is pointing at, > I have tried this already and it doesn't change the value of rt at all. > > void PRQuadTree::Set(Node*& rt,Node* value) { > *rt = *value; > } > > any suggestions? void blah::set(datatype **rt, datatype *value) { *rt=value; } and when you call it datatype *rt; datatype *value; blahobject.set(&rt, value); Rememeber that ** is a pointer to a pointer. And that using *rt means "set the data that rt points to". The & in the function call dereferences datatype * to datatype **. Hope that helps. Also keep in mind that making a function passing a variable by reference, such as void func(int &i) is only a C++ shortcut. It is not legal C code (I mention this because C tends to require the use of pointers more), and does not make any sense if you try to think of it in terms of how * and & work. And when you do anything more complex (like node*& rt), the "shortcut" no longer works as expected. Ben Allison ========================================================================= Date: Sun, 7 Mar 0100 21:12:34 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brian Wagner Subject: Re: Insert bug.. In-Reply-To: <000001bf8625$710c32c0$0201a8c0@vtacs.com> from "John Owens" at Mar 4, 0 05:03:14 pm Content-Type: text > Yes.. are you reading it in as a char city[num] num being any number and > then passing a char*? well the char* just points to the city variable in > your I/O function. So what you have to do is store the variable in your > node as something like city[num] instead of char* otherwise everynode will > point to whatever is in the char city[num] variable in your I/O function. > You pass it as a char*, but you store it in a character array. Wow, this "C string" (ie, "string.h") stuff is just pure silliness. I recommend you use "#include " and it's "string" class to do string stuff. C strings are just pure pain. (Be gone, "C strings"!!!) (The "string" class is NOT part of the STL, so it is NOT banned from usage by the wise Computer Science department.) > > -----Original Message----- > From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of > Saam Tariverdi > Sent: Saturday, March 04, 2000 4:13 PM > To: CS2604@LISTSERV.VT.EDU > Subject: Insert bug.. > > > I've implemented my insert function and the debug function; however, when > the debug function makes a printout of the tree, it appears that my tree is > storing the same city name for each city node. > > Apparently, when I insert in a new city record, the city name that I pass > into the insert function *overwrites* the city name variable in all the > current city nodes in my tree.. so basically, the last city name that is > inserted into the tree is what appears in ALL of my nodes during the > printout of the tree. I can't figure out why it is doing this, so perhaps > one of you could give me some input on this? Thanks in advance. > > Saam Tariverdi > -- // Brian Wagner, CpE WWW: http://www.bigfoot.com/~datatroi "After finding no qualified candidates for the position of principal, the school board is extremely pleased to announce the appointment of David Steele to the post." --Philip Streifer, Superintendent of Schools, Barrington, Rhode Island. ------------------------------------------------------------------------- ========================================================================= Date: Sat, 4 Mar 2000 22:26:07 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Saam Tariverdi Subject: Searching stuff MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit I've implemented my search function, however, it has to search through ALL the quadrants. What's a good way to determine which quadrants intersect with the "circle" the search coordinates makes in order to traverse through specified quadrants? Thanks. Saam Tariverdi ========================================================================= Date: Sun, 5 Mar 2000 10:43:56 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: mark Subject: command Line assumptions MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Will this project be similar to the previous one in that we assume that the file will be pipped into standard input -- allowing us to 'cin' input (Previous postings have 'hinted' this is the way it shall be done)? ========================================================================= Date: Sun, 5 Mar 2000 11:01:28 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: "Michael S. Moulton" Subject: Quick debug question In-Reply-To: <3.0.6.32.20000305104356.00927780@mail.vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii This may have been answered before, but I wanted to check, and there are tons of messages to go searching through... For debug we are doing a preorder traversal. When looking at children, what order should we go in? I was thinking NW, NE, SW, SE (compass points) b/c that seems natural to me. Obviously, the debug output relies on this being correct... --Mike --- Michael S. Moulton UZ 541+UUD Lord Bodak msmoulton@iname.com VT Class of 2001 http://www.ee.vt.edu/~mmoulton/ ========================================================================= Date: Sun, 5 Mar 2000 11:02:42 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Steve Mirman Subject: Re: command Line assumptions In-Reply-To: <3.0.6.32.20000305104356.00927780@mail.vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii This project has to read in from an input file and output to a file specified from the command line. At 10:43 AM 3/5/2000 -0500, you wrote: > Will this project be similar to the previous one in that we assume that the >file will be pipped into standard input -- allowing us to 'cin' input >(Previous postings >have 'hinted' this is the way it shall be done)? > ========================================================================= Date: Sun, 5 Mar 2000 13:56:46 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: keer Subject: Keller T TH 12:30 Test time/place MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Could someone please tell me when and where the test is for Keller's T TH 12 30 class? Thanks a lot ========================================================================= Date: Sun, 5 Mar 2000 15:08:33 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: Re: Quick debug question In-Reply-To: <3.0.5.32.20000305110128.008dda90@mail.vt.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Its in the modified spec I think, download the new spec. At 11:01 AM 3/5/00 -0500, you wrote: >This may have been answered before, but I wanted to check, and there are >tons of messages to go searching through... > >For debug we are doing a preorder traversal. When looking at children, >what order should we go in? I was thinking NW, NE, SW, SE (compass points) >b/c that seems natural to me. Obviously, the debug output relies on this >being correct... > >--Mike > >--- >Michael S. Moulton UZ 541+UUD Lord Bodak >msmoulton@iname.com VT Class of 2001 >http://www.ee.vt.edu/~mmoulton/ > ========================================================================= Date: Sun, 5 Mar 2000 15:59:52 -0800 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Luck Subject: problems with exponents MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit I seem to be having troulbe when I use the exponent calculation I have been using syntax like: int width = 2^14; This doesn't give me the correct value for with, i get some small number. I have tried using longs instead of ints and get the same problem. Any suggestions? Thanks, Jason Luck ========================================================================= Date: Sun, 5 Mar 2000 16:15:58 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Blain Subject: Re: problems with exponents In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit I believe someone mentioned that the ^ operator actually doesn't perform exponents. just includ the math header and use the pow() function I think it is pow(base,exponent) => -----Original Message----- => From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of => Jason Luck => Sent: Sunday, March 05, 2000 7:00 PM => To: CS2604@LISTSERV.VT.EDU => Subject: problems with exponents => => => I seem to be having troulbe when I use the exponent calculation => I have been using syntax like: => int width = 2^14; => => This doesn't give me the correct value for with, i get some small number. => I have tried using longs instead of ints and get the same problem. => Any suggestions? => => Thanks, => Jason Luck ========================================================================= Date: Sun, 5 Mar 2000 16:24:19 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Saam Tariverdi Subject: Re: problems with exponents MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit You have to use the pow() function: int pow(number, power), e.g., int width = pow(2, 14), or something like that. Don't forget to include as well. ----- Original Message ----- From: Jason Luck To: Sent: Sunday, March 05, 2000 6:59 PM Subject: problems with exponents > I seem to be having troulbe when I use the exponent calculation > I have been using syntax like: > int width = 2^14; > > This doesn't give me the correct value for with, i get some small number. > I have tried using longs instead of ints and get the same problem. > Any suggestions? > > Thanks, > Jason Luck ========================================================================= Date: Sun, 5 Mar 2000 22:22:49 +0000 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Dmitry Bocharnikov Subject: Sample input MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Can someone please run this sample input and post the results. Thank you insert 100 200 Blacksburg debug insert 3000 11000 McLean debug insert 0 11000 Blacksburg debug insert 3000 5000 Charlotte debug insert 15000 15000 Washington debug insert 700 8500 Alabama debug insert 1500 8500 Detroit debug insert 3000 0 Christiansburg debug remove 3000 5000 debug remove 3000 0 debug remove 0 11000 debug search 3100 11100 200 search -10 8200 900 makenull ========================================================================= Date: Sun, 5 Mar 2000 18:42:19 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Ryan Turner Subject: Re: Sample input In-Reply-To: <38C2DE39.726DC20@vt.edu> MIME-version: 1.0 Content-type: MULTIPART/MIXED; BOUNDARY="Boundary_(ID_YmYq9V2iVI+m3ZnSWt0CPA)" This is a multi-part message in MIME format. --Boundary_(ID_YmYq9V2iVI+m3ZnSWt0CPA) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit This is what I got: insert city "Blacksburg" at location 100,200 Inserted city "Blacksburg" at postion 100,200 into the tree. debug 100,200,Blacksburg insert city "McLean" at location 3000,11000 Inserted city "McLean" at postion 3000,11000 into the tree. debug G100,200,BlacksburgE3000,11000,McLeanE insert city "Blacksburg" at location 0,11000 Inserted city "Blacksburg" at postion 0,11000 into the tree. debug G100,200,BlacksburgEGGEE0,11000,Blacksburg3000,11000,McLeanEEEE insert city "Charlotte" at location 3000,5000 Inserted city "Charlotte" at postion 3000,5000 into the tree. debug GG100,200,BlacksburgE3000,5000,CharlotteEEGGEE0,11000,Blacksburg3000,11000,M cLeanEEEE insert city "Washington" at location 15000,15000 Inserted city "Washington" at postion 15000,15000 into the tree. debug GG100,200,BlacksburgE3000,5000,CharlotteEEGGEE0,11000,Blacksburg3000,11000,M cLeanEEE15000,15000,Washington insert city "Alabama" at location 700,8500 Inserted city "Alabama" at postion 700,8500 into the tree. debug GG100,200,BlacksburgE3000,5000,CharlotteEEGG700,8500,AlabamaE0,11000,Blacksb urg3000,11000,McLeanEEE15000,15000,Washington insert city "Detroit" at location 1500,8500 Inserted city "Detroit" at postion 1500,8500 into the tree. debug GG100,200,BlacksburgE3000,5000,CharlotteEEGGG700,8500,Alabama1500,8500,Detro itEEE0,11000,Blacksburg3000,11000,McLeanEEE15000,15000,Washington insert city "Christiansburg" at location 3000,0 Inserted city "Christiansburg" at postion 3000,0 into the tree. debug GGG100,200,Blacksburg3000,0,ChristiansburgEEE3000,5000,CharlotteEEGGG700,850 0,Alabama1500,8500,DetroitEEE0,11000,Blacksburg3000,11000,McLeanEEE15000,150 00,Washington remove city at location 3000,5000 Removed city "Charlotte" at postion 3000,5000 from the tree. debug GGG100,200,Blacksburg3000,0,ChristiansburgEEEEEEGGG700,8500,Alabama1500,8500 ,DetroitEEE0,11000,Blacksburg3000,11000,McLeanEEE15000,15000,Washington remove city at location 3000,0 Removed city "Christiansburg" at postion 3000,0 from the tree. debug G100,200,BlacksburgEGGG700,8500,Alabama1500,8500,DetroitEEE0,11000,Blacksbur g3000,11000,McLeanEEE15000,15000,Washington remove city at location 0,11000 Removed city "Blacksburg" at postion 0,11000 from the tree. debug G100,200,BlacksburgEGGG700,8500,Alabama1500,8500,DetroitEEEE3000,11000,McLea nEEE15000,15000,Washington search location 3100,11100 with radius 200 3000,11000 McLean Visited 4 nodes. search location -10,8200 with radius 900 700,8500 Alabama Visited 6 nodes. makenull The database has been initialize. -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Dmitry Bocharnikov Sent: Sunday, March 05, 2000 5:23 PM To: CS2604@LISTSERV.VT.EDU Subject: Sample input Can someone please run this sample input and post the results. Thank you insert 100 200 Blacksburg debug insert 3000 11000 McLean debug insert 0 11000 Blacksburg debug insert 3000 5000 Charlotte debug insert 15000 15000 Washington debug insert 700 8500 Alabama debug insert 1500 8500 Detroit debug insert 3000 0 Christiansburg debug remove 3000 5000 debug remove 3000 0 debug remove 0 11000 debug search 3100 11100 200 search -10 8200 900 makenull --Boundary_(ID_YmYq9V2iVI+m3ZnSWt0CPA) Content-type: text/plain; CHARSET=US-ASCII; name=out.txt Content-disposition: attachment; filename=out.txt Content-transfer-encoding: quoted-printable insert city "Blacksburg" at location 100,200 Inserted city "Blacksburg" at postion 100,200 into the tree. debug 100,200,Blacksburg insert city "McLean" at location 3000,11000 Inserted city "McLean" at postion 3000,11000 into the tree. debug G100,200,BlacksburgE3000,11000,McLeanE insert city "Blacksburg" at location 0,11000 Inserted city "Blacksburg" at postion 0,11000 into the tree. debug G100,200,BlacksburgEGGEE0,11000,Blacksburg3000,11000,McLeanEEEE insert city "Charlotte" at location 3000,5000 Inserted city "Charlotte" at postion 3000,5000 into the tree. debug GG100,200,BlacksburgE3000,5000,CharlotteEEGGEE0,11000,Blacksburg3000,1100= 0,McLeanEEEE insert city "Washington" at location 15000,15000 Inserted city "Washington" at postion 15000,15000 into the tree. debug GG100,200,BlacksburgE3000,5000,CharlotteEEGGEE0,11000,Blacksburg3000,1100= 0,McLeanEEE15000,15000,Washington insert city "Alabama" at location 700,8500 Inserted city "Alabama" at postion 700,8500 into the tree. debug GG100,200,BlacksburgE3000,5000,CharlotteEEGG700,8500,AlabamaE0,11000,Blac= ksburg3000,11000,McLeanEEE15000,15000,Washington insert city "Detroit" at location 1500,8500 Inserted city "Detroit" at postion 1500,8500 into the tree. debug GG100,200,BlacksburgE3000,5000,CharlotteEEGGG700,8500,Alabama1500,8500,De= troitEEE0,11000,Blacksburg3000,11000,McLeanEEE15000,15000,Washington insert city "Christiansburg" at location 3000,0 Inserted city "Christiansburg" at postion 3000,0 into the tree. debug GGG100,200,Blacksburg3000,0,ChristiansburgEEE3000,5000,CharlotteEEGGG700,= 8500,Alabama1500,8500,DetroitEEE0,11000,Blacksburg3000,11000,McLeanEEE150= 00,15000,Washington remove city at location 3000,5000 Removed city "Charlotte" at postion 3000,5000 from the tree. debug GGG100,200,Blacksburg3000,0,ChristiansburgEEEEEEGGG700,8500,Alabama1500,8= 500,DetroitEEE0,11000,Blacksburg3000,11000,McLeanEEE15000,15000,Washingto= n remove city at location 3000,0 Removed city "Christiansburg" at postion 3000,0 from the tree. debug G100,200,BlacksburgEGGG700,8500,Alabama1500,8500,DetroitEEE0,11000,Blacks= burg3000,11000,McLeanEEE15000,15000,Washington remove city at location 0,11000 Removed city "Blacksburg" at postion 0,11000 from the tree. debug G100,200,BlacksburgEGGG700,8500,Alabama1500,8500,DetroitEEEE3000,11000,Mc= LeanEEE15000,15000,Washington search location 3100,11100 with radius 200 3000,11000 McLean Visited 4 nodes. search location -10,8200 with radius 900 700,8500 Alabama Visited 6 nodes. makenull The database has been initialize. --Boundary_(ID_YmYq9V2iVI+m3ZnSWt0CPA)-- ========================================================================= Date: Sun, 5 Mar 2000 18:52:53 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Sidney Bennett Subject: Re: Quick debug question MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit As far as the preorder traversal goes, NW, NE, SW, SE is what the spec says. ========================================================================= Date: Mon, 6 Mar 2000 00:29:08 +0000 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Dmitry Bocharnikov Subject: X and Y? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This didn't come to my mind untill I manually traced the provided output file. The spec never mentioned how X and Y axises are positioned. I assumed that X points down and Y is horizontal. (I think the ancient C graphical libraries use that convention). However, for the sample output file it seems like X is horizontal and Y points down. Although it will not take me much time to rewrite the code to change that, in principal I do not intend to do so because the spec did not restrict us to how to position axises. Did anyone else have the similar situation arise? Thanks Dmitry ========================================================================= Date: Sun, 5 Mar 2000 19:50:37 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Kevin Sharp Subject: Re: X and Y? In-Reply-To: <38C2FBD4.4FE54ADB@vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit The usual convention for coordinates is with positive X coordinates going toward the right and positive Y coordinates going down. I would assume that same convention holds for this project. Kevin -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Dmitry Bocharnikov Sent: Sunday, March 05, 2000 7:29 PM To: CS2604@LISTSERV.VT.EDU Subject: X and Y? This didn't come to my mind untill I manually traced the provided output file. The spec never mentioned how X and Y axises are positioned. I assumed that X points down and Y is horizontal. (I think the ancient C graphical libraries use that convention). However, for the sample output file it seems like X is horizontal and Y points down. Although it will not take me much time to rewrite the code to change that, in principal I do not intend to do so because the spec did not restrict us to how to position axises. Did anyone else have the similar situation arise? Thanks Dmitry ========================================================================= Date: Sun, 5 Mar 2000 20:16:39 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Alan Lattimer Subject: Re: problems with exponents In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Just another thought... You can use a bitwise shift to the right. Each shift is the equivalent to multiplying a number by 2. For example 1 << 5 => 2^5 or 32 = 1*2*2*2*2*2. -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Jason Luck Sent: Sunday, March 05, 2000 7:00 PM To: CS2604@LISTSERV.VT.EDU Subject: problems with exponents I seem to be having troulbe when I use the exponent calculation I have been using syntax like: int width = 2^14; This doesn't give me the correct value for with, i get some small number. I have tried using longs instead of ints and get the same problem. Any suggestions? Thanks, Jason Luck ========================================================================= Date: Sun, 5 Mar 2000 20:39:34 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Joel Eiholzer Subject: Re: problems with exponents In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Don't do the calculation at all in your program. Use your calculator and a #define statement. Besides the spec says "You should always use named constants or enumerated types instead of literal constants in code." under the programming standards section. It is a one time thing so why make the computer do any work when you can just as easily give it the direct value. If you change that value in the future you are just going to have to manuallly change it then so again why not calculate the value by hand and just set it. So even if you want to do the calculation it should be something like int width = pow(PROGRAM_BASE,PROGRAM_POWER); where PROGRAM_BASE and PROGRAM_POWER are defined using #define. At 03:59 PM 3/5/00 -0800, you wrote: >I seem to be having troulbe when I use the exponent calculation > I have been using syntax like: > int width = 2^14; > >This doesn't give me the correct value for with, i get some small number. >I have tried using longs instead of ints and get the same problem. >Any suggestions? > >Thanks, >Jason Luck > ========================================================================= Date: Sun, 5 Mar 2000 20:44:10 -0500 Reply-To: jcovin@vt.edu Sender: CS2604 discussion list From: Jon Covin Subject: Re: X and Y? In-Reply-To: <38C2FBD4.4FE54ADB@vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Yes that's right, the upper left hand corner of your box is thought of as the origin (0,0), but you can also think about it the other way with the lower left hand corner being (0,0) and X going up horizontally and Y going up vertically. If you do it this way the only thing that changes is the way you need to traverse the tree. Instead of the usual NW NE SW SE traversal you would need to do SW SE NW NE. Dr. Shaffer mentioned this in an earlier post. So just make sure your debug prints out the correct information (matching the sample output given on the webpage) and you should be fine. > This didn't come to my mind untill I manually traced the provided output > file. > The spec never mentioned how X and Y axises are positioned. I assumed > that X points down and Y is horizontal. (I think the ancient C graphical > libraries use that convention). > However, for the sample output file it seems like X is horizontal and Y > points down. > Although it will not take me much time to rewrite the code to change > that, in principal I do not intend to do so because the spec did not > restrict us to how to position axises. > Did anyone else have the similar situation arise? > Thanks > Dmitry ========================================================================= Date: Sun, 5 Mar 2000 22:42:32 -0800 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Convry Subject: Searching questions MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_2vMmfD6RAJfAIpIQ4Tmliw)" This is a multi-part message in MIME format. --Boundary_(ID_2vMmfD6RAJfAIpIQ4Tmliw) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable Hey I'm having problems with my searching. Well, more like problems = understanding how it works. I've seen examples of a box circle method or = whatever, but don't really understand. Could someone could write me back = privately as to not fill up listserv space with answers to a question = that probably everyone but me already understands? Thanks in advance. Jason --Boundary_(ID_2vMmfD6RAJfAIpIQ4Tmliw) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
Hey I'm having problems with my = searching. Well,=20 more like problems understanding how it works. I've seen examples = of a box=20 circle method or whatever, but don't really understand. Could = someone could=20 write me back privately as to not fill up listserv space with answers to = a=20 question that probably everyone but me already understands? Thanks in=20 advance.
 
Jason
 
--Boundary_(ID_2vMmfD6RAJfAIpIQ4Tmliw)-- ========================================================================= Date: Mon, 6 Mar 2000 01:21:21 -0800 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Stephen Hoskins Subject: another sample input MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit With this input file I was able to correct at least 3 mistakes (most likely more). Now, I'm not saying that this is the best input file for testing in the entire world and I'm not necessarily saying that this is the most intelligent input file in the world either. I pretty much just typed it at random. But I think it can help out somewhat if your debugging. insert 123 234 Tulip_Craze insert 1500 1600 Gatchaman insert 1500 1600 Battle_of_the_Planets insert 1500 1600 G-Force insert 1500 1600 Eagle_Riders insert 1232 98 Pokemon insert 9877 16000 Digimon insert 3433 3444 Tamagotchi insert 1399 7988 Nano insert 0 0 Origin insert 16383 16383 SomeREAllyFarLocation debug remove 98 34 debug remove 1500 1600 debug remove 1500 1600 debug remove 0 0 debug remove 3433 3444 debug search 3433 3444 200 search 9877 16000 1500 search 0 0 500 makenull ========================================================================= Date: Mon, 6 Mar 2000 05:44:34 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: Re: Searching questions In-Reply-To: <001401bf8737$2762ca40$7d35ad80@jason> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" I am also having problems with the bounding box thing. I understand what we are supposed to do, I am just not sure what kind of checks we should be doing to accomplish it. My first attempt is to check the corners of the quadrant, and see if any of the four corners fall into the search box. I wound up with an if statment like this: searchX, searchY=upper left corner of bounding box searchWidth=width of bounding box if ((( (cornerX >= searchX) && (cornerX<= searchX+searchWidth ))&& (cornerY >= searchY) && (cornerY<= searchY+searchWidth ))|| (( (cornerX+width >= searchX) && (cornerX+width<= searchX+searchWidth ))&& (cornerY >= searchY) && (cornerY<= searchY+searchWidth ))|| (( (cornerX >= searchX) && (cornerX<= searchX+searchWidth ))&& (cornerY+width >= searchY) && (cornerY+width<= searchY+searchWidth ))|| (( (cornerX+width >= searchX) && (cornerX+width<= searchX+searchWidth ))&& (cornerY+width >= searchY) && (cornerY+width<= searchY+searchWidth ))) Whew.... anyway, that is pretty cumbersome, but it works, IF the search area contains a corner of the quadrant in it. What it doesn't do is check for a bounding box that is totally contained in the quadrant, and doesn't intersect it at all. That would be another huge compound if statement. Am I on the right track here? It seems like there is a better way I am missing. ========================================================================= Date: Mon, 6 Mar 2000 08:09:30 -0800 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Stephen Hoskins Subject: matching output file MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Sorry about that! Here's the matching output file (keep in mind that this is the output generated from my program and may not be completely correct. If you receive different output please let me know!): insert 123 234 Tulip_Craze City Tulip_Craze inserted at (123, 234) successfully insert 1500 1600 Gatchaman City Gatchaman inserted at (1500, 1600) successfully insert 1500 1600 Battle_of_the_Planets --ERROR-- The following coordinate: (1500, 1600) already exist in the database. insert 1500 1600 G-Force --ERROR-- The following coordinate: (1500, 1600) already exist in the database. insert 1500 1600 Eagle_Riders --ERROR-- The following coordinate: (1500, 1600) already exist in the database. insert 1232 98 Pokemon City Pokemon inserted at (1232, 98) successfully insert 9877 16000 Digimon City Digimon inserted at (9877, 16000) successfully insert 3433 3444 Tamagotchi City Tamagotchi inserted at (3433, 3444) successfully insert 1399 7988 Nano City Nano inserted at (1399, 7988) successfully insert 0 0 Origin City Origin inserted at (0, 0) successfully insert 16383 16383 SomeREAllyFarLocation City SomeREAllyFarLocation inserted at (16383, 16383) successfully debug The preorder listing is as follows: GGGGGGG0,0,OriginE123,234,Tulip_CrazeEEEEEEE1232,98,PokemonE1500,1600,GatchamanEE3433,3444,TamagotchiE1399,7988,NanoEEEGEE9877,16000,Digimon16383,16383,SomeREAllyFarLocation remove 98 34 --ERROR-- The following coordinate: (98, 34) does NOT exist in the database. debug The preorder listing is as follows: GGGGGGG0,0,OriginE123,234,Tulip_CrazeEEEEEEE1232,98,PokemonE1500,1600,GatchamanEE3433,3444,TamagotchiE1399,7988,NanoEEEGEE9877,16000,Digimon16383,16383,SomeREAllyFarLocation remove 1500 1600 Removed Gatchaman debug The preorder listing is as follows: GGGGGGG0,0,OriginE123,234,Tulip_CrazeEEEEEEE1232,98,PokemonEEEE3433,3444,TamagotchiE1399,7988,NanoEEEGEE9877,16000,Digimon16383,16383,SomeREAllyFarLocation remove 1500 1600 --ERROR-- The following coordinate: (1500, 1600) does NOT exist in the database. debug The preorder listing is as follows: GGGGGGG0,0,OriginE123,234,Tulip_CrazeEEEEEEE1232,98,PokemonEEEE3433,3444,TamagotchiE1399,7988,NanoEEEGEE9877,16000,Digimon16383,16383,SomeREAllyFarLocation remove 0 0 Removed Origin debug The preorder listing is as follows: GGGG123,234,Tulip_Craze1232,98,PokemonEEEE3433,3444,TamagotchiE1399,7988,NanoEEEGEE9877,16000,Digimon16383,16383,SomeREAllyFarLocation remove 3433 3444 Removed Tamagotchi debug The preorder listing is as follows: GGGG123,234,Tulip_Craze1232,98,PokemonEEEEEE1399,7988,NanoEEEGEE9877,16000,Digimon16383,16383,SomeREAllyFarLocation search 3433 3444 200 No cities were found that lie within radius 200 of the point (3433, 3444) search 9877 16000 1500 The following cities lie within radius of 1500 of the point (9877, 16000) (9877, 16000) Digimon Number of nodes visited = 3 search 0 0 500 The following cities lie within radius of 500 of the point (0, 0) (123, 234) Tulip_Craze Number of nodes visited = 5 makenull The database has been initialized. ========================================================================= Date: Mon, 6 Mar 2000 09:54:04 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brandon Horsley Subject: Re: Searching questions MIME-version: 1.0 Content-type: text/html; charset=us-ascii Content-transfer-encoding: 7bit
searchX, searchY=upper left corner of bounding box
searchWidth=width of bounding box

if ((( (cornerX >= searchX) && (cornerX<= searchX+searchWidth ))&&
(cornerY >= searchY) && (cornerY<= searchY+searchWidth ))||
(( (cornerX+width >= searchX) && (cornerX+width<= searchX+searchWidth ))&&
(cornerY >= searchY) && (cornerY<= searchY+searchWidth ))||
(( (cornerX >= searchX) && (cornerX<= searchX+searchWidth ))&&
(cornerY+width >= searchY) && (cornerY+width<= searchY+searchWidth ))||
(( (cornerX+width >= searchX) && (cornerX+width<= searchX+searchWidth ))&&
(cornerY+width >= searchY) && (cornerY+width<= searchY+searchWidth )))
 

It seems like there is a better way I am
missing.
I pretty much did the same thing, but I only checked to see if the corners of the little box were in the big box

determine which one is bigger using width

ie:

** WARNING ** ASCII Text Art Ahead

+--------------------------+
|                    |
|   [  ]             |
|                    | The little box contains corners in the big one.
|                    |
|                    |
|    Search Box      |
+--------------------------+
 

or  ..

+--------------------------+
|                    |
|   [Search Box]     |
|                    | The little box STILL contains corners in bigbox.
|                    |
|                    |
|    Node Box        |
+--------------------------+

i think that works ========================================================================= Date: Mon, 6 Mar 2000 10:19:01 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Ben Allison Subject: Re: matching output file MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Stephen Hoskins graciously offered more input and output: > > Sorry about that! Here's the matching output file (keep in mind that > this is the output generated from my program and may not be completely > correct. If you receive different output please let me know!): Hey Stephen (and the list), I got the exact same output except for one small difference: > search 3433 3444 200 > No cities were found that lie within radius 200 of the point (3433, > 3444) You don't display the number of nodes searched here. Ben Allison ========================================================================= Date: Mon, 6 Mar 2000 12:30:13 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: Searching questions In-Reply-To: <3.0.6.32.20000306054434.0080b6a0@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII How about something like the following? (Warning: I have not actually tested this.) bool boxintersect(Box* b1, Box* b2) { return (b1->x < (b2->x + b2->width)) && (b2->x < (b1->x + b1->width)) && (b1->y < (b2->y + b2->width)) && (b2->y < (b1->y + b1->width)); } -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- On Mon, 6 Mar 2000, Jason Giglio wrote: > I am also having problems with the bounding box thing. I understand what > we are supposed to do, I am just not sure what kind of checks we should be > doing to accomplish it. My first attempt is to check the corners of the > quadrant, and see if any of the four corners fall into the search box. I > wound up with an if statment like this: > > searchX, searchY=upper left corner of bounding box > searchWidth=width of bounding box > > if ((( (cornerX >= searchX) && (cornerX<= searchX+searchWidth ))&& > (cornerY >= searchY) && (cornerY<= searchY+searchWidth ))|| > (( (cornerX+width >= searchX) && (cornerX+width<= searchX+searchWidth ))&& > (cornerY >= searchY) && (cornerY<= searchY+searchWidth ))|| > (( (cornerX >= searchX) && (cornerX<= searchX+searchWidth ))&& > (cornerY+width >= searchY) && (cornerY+width<= searchY+searchWidth ))|| > (( (cornerX+width >= searchX) && (cornerX+width<= searchX+searchWidth ))&& > (cornerY+width >= searchY) && (cornerY+width<= searchY+searchWidth ))) > > Whew.... anyway, that is pretty cumbersome, but it works, IF the search > area contains a corner of the quadrant in it. What it doesn't do is check > for a bounding box that is totally contained in the quadrant, and doesn't > intersect it at all. That would be another huge compound if statement. Am > I on the right track here? It seems like there is a better way I am > missing. > ========================================================================= Date: Mon, 6 Mar 2000 11:44:14 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brandon Horsley Subject: Re: Searching questions MIME-version: 1.0 Content-type: text/html; charset=us-ascii Content-transfer-encoding: 7bit  

bool boxintersect(Box* b1, Box* b2) {
  return (b1->x < (b2->x + b2->width)) &&
         (b2->x < (b1->x + b1->width)) &&
         (b1->y < (b2->y + b2->width)) &&
         (b2->y < (b1->y + b1->width));
}
would that work in the case :

+-------------------+
|                   |
|               +---------+
|               |         |
|               |         |
|               +---------+
|                   |
+-------------------+

i don't think it would
  ========================================================================= Date: Mon, 6 Mar 2000 16:54:54 +0000 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Dmitry Bocharnikov Subject: More input and output files MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit How about this one ---------------input------------------- insert 0 0 Moscow insert 1 1 New_York insert 14999 14999 Blah debug remove 0 0 debug --------------output------------------- insert-0-0-Moscow City Moscow at (0, 0) inserted successfully. insert-1-1-New_York City New_York at (1, 1) inserted successfully. insert-14999-14999-Blah City Blah at (14999, 14999) inserted successfully. debug The preorder listing is as follows: GGGGGGGGGGGGGG0,0,MoscowEE1,1,New_YorkEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE14999,14999,Blah remove-0-0- Removed Moscow debug The preorder listing is as follows: G1,1,New_YorkEE14999,14999,Blah ========================================================================= Date: Mon, 6 Mar 2000 12:03:43 -0800 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Stephen Hoskins Subject: Re: matching output file MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit w0w! Thanks a lot! I'm definitely fixing that. I appreciate your feedback. It appears that posting this input file has been more beneficial for me than it has been for anyone else! =D Ben Allison wrote: > Stephen Hoskins graciously offered more input and output: > > > > Sorry about that! Here's the matching output file (keep in mind that > > this is the output generated from my program and may not be completely > > correct. If you receive different output please let me know!): > > Hey Stephen (and the list), > I got the exact same output except for one small difference: > > > search 3433 3444 200 > > No cities were found that lie within radius 200 of the point (3433, > > 3444) > > You don't display the number of nodes searched here. > > Ben Allison ========================================================================= Date: Mon, 6 Mar 2000 15:42:17 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Sidney Bennett Subject: Dr. Roach's test summary? MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Would it be possible to obtain a brief summary of the topics to be covered on the test given Wednesday evening for Dr. Roach's sections? ========================================================================= Date: Mon, 6 Mar 2000 21:22:37 +0000 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Dmitry Bocharnikov Subject: Re: Dr. Roach's test summary? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Ch 1-6, 12.4, 13.3.2 - Dr.Roach said to know everything. I think he also said that some examples will be discussed on Wed. Dmitry Sidney Bennett wrote: > > Would it be possible to obtain a brief summary of the topics to be covered > on the test given Wednesday evening for Dr. Roach's sections? ========================================================================= Date: Mon, 6 Mar 2000 18:01:23 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: P2 Grading question In-Reply-To: <38C4219D.849C9B7D@vt.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" For those of us that are having problems getting the search to only visit the correct nodes, how much are we going to be peanalized if we turn it in with the algorithm still visiting all the nodes? My real question is, is it worth it to turn it in one day late just to try to fix the number of nodes visited by the regionsearch function? ========================================================================= Date: Mon, 6 Mar 2000 20:22:57 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: P2 Grading question In-Reply-To: <3.0.6.32.20000306180123.0089b4d0@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII To be honest, I don't recall the precise number of points for that aspect of search, but the penalty is almost certainly going to be within a couple of points one way or the other of the 1-day-late penalty. So you will have to use your judgement on whether the time spent getting it right is worth what you will learn from doing it (and don't forget that, if you don't fix it for P4, you will get penalized again). -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- On Mon, 6 Mar 2000, Jason Giglio wrote: > For those of us that are having problems getting the search to only visit > the correct nodes, how much are we going to be peanalized if we turn it in > with the algorithm still visiting all the nodes? > > My real question is, is it worth it to turn it in one day late just to try > to fix the number of nodes visited by the regionsearch function? > ========================================================================= Date: Mon, 6 Mar 2000 22:20:55 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: James Fonseca Subject: submitter problem MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit hi, I was wondering if anyone else has had any trouble with the submitter for project 2. It worked fine for me for project 1 and hw1, but now it brings up the applet window but it has an error message saying that i do not have sufficient priviledges. Please let me know if you have any ideas why this is happening. thanks, jimmy ========================================================================= Date: Mon, 6 Mar 2000 22:51:02 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brad Friedman Subject: Re: submitter problem In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit I use the online version. Can't remember the exact URL, but if you download the fall 99 client configuration tool and run it, it will give you the URL. I just used it, so it works fine. -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of James Fonseca Sent: Monday, March 06, 2000 10:21 PM To: CS2604@LISTSERV.VT.EDU Subject: submitter problem hi, I was wondering if anyone else has had any trouble with the submitter for project 2. It worked fine for me for project 1 and hw1, but now it brings up the applet window but it has an error message saying that i do not have sufficient priviledges. Please let me know if you have any ideas why this is happening. thanks, jimmy ========================================================================= Date: Mon, 6 Mar 2000 22:47:55 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Dmitry Bocharnikov Subject: Re: submitter problem MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Try to run the configuration application again. James Fonseca wrote: > hi, > I was wondering if anyone else has had any trouble with the submitter for > project 2. It worked fine for me for project 1 and hw1, but now it brings > up the applet window but it has an error message saying that i do not have > sufficient priviledges. Please let me know if you have any ideas why this > is happening. > thanks, > jimmy ========================================================================= Date: Mon, 6 Mar 2000 22:54:31 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Michael Leatherman Subject: Re: submitter problem In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit try running the configurator again -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of James Fonseca Sent: Monday, March 06, 2000 10:21 PM To: CS2604@LISTSERV.VT.EDU Subject: submitter problem hi, I was wondering if anyone else has had any trouble with the submitter for project 2. It worked fine for me for project 1 and hw1, but now it brings up the applet window but it has an error message saying that i do not have sufficient priviledges. Please let me know if you have any ideas why this is happening. thanks, jimmy ========================================================================= Date: Tue, 7 Mar 2000 09:55:55 -0500 Reply-To: jjustice@vt.edu Sender: CS2604 discussion list From: Jesse Justice Subject: Re: Searching questions In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Cliff Shaffer Sent: Monday, March 06, 2000 12:30 PM To: CS2604@LISTSERV.VT.EDU Subject: Re: Searching questions How about something like the following? (Warning: I have not actually tested this.) bool boxintersect(Box* b1, Box* b2) { return (b1->x < (b2->x + b2->width)) && (b2->x < (b1->x + b1->width)) && (b1->y < (b2->y + b2->width)) && (b2->y < (b1->y + b1->width)); } -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- On Mon, 6 Mar 2000, Jason Giglio wrote: > I am also having problems with the bounding box thing. I understand what > we are supposed to do, I am just not sure what kind of checks we should be > doing to accomplish it. My first attempt is to check the corners of the > quadrant, and see if any of the four corners fall into the search box. I > wound up with an if statment like this: > > searchX, searchY=upper left corner of bounding box > searchWidth=width of bounding box > > if ((( (cornerX >= searchX) && (cornerX<= searchX+searchWidth ))&& > (cornerY >= searchY) && (cornerY<= searchY+searchWidth ))|| > (( (cornerX+width >= searchX) && (cornerX+width<= searchX+searchWidth ))&& > (cornerY >= searchY) && (cornerY<= searchY+searchWidth ))|| > (( (cornerX >= searchX) && (cornerX<= searchX+searchWidth ))&& > (cornerY+width >= searchY) && (cornerY+width<= searchY+searchWidth ))|| > (( (cornerX+width >= searchX) && (cornerX+width<= searchX+searchWidth ))&& > (cornerY+width >= searchY) && (cornerY+width<= searchY+searchWidth ))) > > Whew.... anyway, that is pretty cumbersome, but it works, IF the search > area contains a corner of the quadrant in it. What it doesn't do is check > for a bounding box that is totally contained in the quadrant, and doesn't > intersect it at all. That would be another huge compound if statement. Am > I on the right track here? It seems like there is a better way I am > missing. > ========================================================================= Date: Wed, 8 Mar 2000 14:40:43 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Project 3 spec posted MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII The P3 spec has now been posted to the website. The on-time due date is Friday, March 31. Some people asked me about the relationship between the P3 due date and Spring Break. Its not a big project, so if you start on Monday, March 20, most people should find that they have plenty of time. If you already have experience with C++ file I/O, project 3 should be a breeze. However, most people in the class do not have this experience, and it is quite possible that you will get hung up on getting file I/O to work. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Wed, 8 Mar 2000 17:55:42 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: P3 spec correction MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII I have made a correction to the P3 spec to make the name of the "get" command consistent throughout. If you downloaded the spec prior to 5:00pm Wednesday, grab another copy. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Thu, 9 Mar 2000 00:37:46 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Joseph Bowyer Subject: Pledge Statement in Project 2 MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_/Nvd0VsO5rB1c3eG+qRyJw)" This is a multi-part message in MIME format. --Boundary_(ID_/Nvd0VsO5rB1c3eG+qRyJw) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable Mainly to the TAs and Profs: I forgot to put the pledge in my project 2 submission when I submitted. = What should I do? --Boundary_(ID_/Nvd0VsO5rB1c3eG+qRyJw) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable

Mainly to the TAs and = Profs:
I forgot to put the pledge in my = project 2=20 submission when I submitted. What should I = do?
--Boundary_(ID_/Nvd0VsO5rB1c3eG+qRyJw)-- ========================================================================= Date: Thu, 9 Mar 2000 11:01:39 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Ali Asghar Zafer Subject: Please note (unavailable on friday from 3:30 to 4:00pm) In-Reply-To: <005001bf8989$99bb7f70$917252c6@majere666> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Hi I will not be available betwen 3:30 to 4:00pm this friday. Instead i will be there upto 7:30pm instead of regular 7:00pm. Hence please take this into consideration if you are planning to see me this friday. Thanks Ali Asghar Zafer ========================================================================= Date: Thu, 9 Mar 2000 13:41:39 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jordan Chavez Subject: buffer pool for insert command MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Do we use the buffer pool for the insert command? or do we just write the data directly to the disk? Jordan Chavez jchavez@vt.edu ========================================================================= Date: Thu, 9 Mar 2000 15:01:44 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Submission fixes MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII If you neglect to include a mechanical element, such as the pledge statement or the project workspace, in your program submission, the general procedure is to just go ahead and re-submit a corrected version ASAP, and send a note to your GTA. That is no big deal, so long as we have the material before we do grading. If you forgot something like a code file, design document, etc, you should also re-submit ASAP when you discover the error, and send email to the GTA. In cases such as that, we will need to decide whether we think some sort of abuse is going on (i.e., whether it appears that something was created after the fact), but generally we will accept such corrections without penalty. If you correct code for some reason (such as a claim that an obsolete version of a file was submitted originally), once again the best thing is to get it submitted ASAP and a message to the GTA. Here, we will need to determine on a case-by-case basis how to deal with the situation. Bottom line: If you have any sort of submission problem, be sure to get a corrected version onto the books ASAP, and we'll negotiate afterward how to give credit for special cases. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Thu, 9 Mar 2000 15:04:15 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: buffer pool for insert command In-Reply-To: <3.0.6.32.20000309134139.008fd420@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Thu, 9 Mar 2000, Jordan Chavez wrote: > Do we use the buffer pool for the insert command? or do we just write the > data directly to the disk? ALL interactions with the disk file are handled strictly by the bufferpool. That is the purpose of the bufferpool -- it is an intermediary between the client and the diskfile. The client never has access to the disk file (or even knows that it exists). -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Thu, 9 Mar 2000 17:58:36 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: James Moniz Subject: Buufers Implementation Question Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Hello, Is there a certain way to implement the way a buffer keeps track of the buffer ID it is supposed to write to? Can it just be stored in the variable of a buffer node, or is it supposed to be stored inside the buffer or tracked in a seperate list or something? And can the meaning of this be explained, please... // Insert from space sz bytes begining at pos // of the buffered store void insert(void* space, int sz, int pos); // Put into space sz bytes beginning at position pos // of the buffered store void getbytes(void* space, int sz, int pos); Thanks. James Moniz jmoniz@vt.edu ========================================================================= Date: Thu, 9 Mar 2000 21:50:09 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jordan Chavez Subject: p3 question MIME-version: 1.0 Content-type: text/plain; charset=us-ascii let's say that the buffer length is set to be 10, with 2 buffers. Then these commands are executed: insert 0, "01234" insert 1, "56789" When we finally write to the file I'm assuming the "01234" starts at offset 0 and "56789" starts at offset 10. So we have 0 1 2 3 4 \n ? ? ? ? 5 6 7 8 9 \n ? ? ? ? What do we fill the intermediate ? bytes with? Jordan Chavez jchavez@vt.edu ========================================================================= Date: Fri, 10 Mar 2000 06:54:05 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: James Moniz Subject: Buffer Implementation, Again Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Hello, Is the pool of buffers assumed to be one continuous block of something, like char*'s, as it was in P1, or can it be implemented any way we want, such individual buffer objects stored in a linked list, each with their own, distinct buffer, completely seperate from the rest? Thanks. James Moniz jmoniz@vt.edu ========================================================================= Date: Fri, 10 Mar 2000 12:54:25 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: p3 question In-Reply-To: <3.0.6.32.20000309215009.008fbc50@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Thu, 9 Mar 2000, Jordan Chavez wrote: > let's say that the buffer length is set to be 10, with 2 buffers. Then > these commands are executed: > insert 0, "01234" > insert 1, "56789" > > When we finally write to the file I'm assuming the "01234" starts at offset > 0 and "56789" starts at offset 10. So we have > 0 1 2 3 4 \n ? ? ? ? 5 6 7 8 9 \n ? ? ? ? Correct. > What do we fill the intermediate ? bytes with? It doesn't matter. You can initialize it with something (to help you debug) or you can not do anything with it. It shouldn't affect the program either way. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Mon, 13 Mar 2000 02:49:32 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: MIN LIANG Subject: P2 Grade for section 1370, TuTh 12:30 MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_gNMDcEJWNsTT8RE7zi5q3Q)" This is a multi-part message in MIME format. --Boundary_(ID_gNMDcEJWNsTT8RE7zi5q3Q) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable P2 Grade for section 1370, TTh 12:30, The grading sheets of P2 have sent out. If you have questions or didn't = receive it, pls contact with me. Don't send e-mail to list. The web for = grade will update soon. Have a nice break. Thanx. Min Liang --Boundary_(ID_gNMDcEJWNsTT8RE7zi5q3Q) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable

P2 Grade for section 1370, TTh 12:30,

The grading sheets of P2 have sent out. If you = have=20 questions or didn't receive it, pls contact with me. Don't send e-mail = to list.=20 The web for grade will update soon.

Have a nice break.

Thanx.

Min Liang

 

--Boundary_(ID_gNMDcEJWNsTT8RE7zi5q3Q)-- ========================================================================= Date: Tue, 14 Mar 2000 01:31:09 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: P3 clarifications Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" 1. How does the bufferpool know where things are in the file? Does it keep another linked list to store the blockIDs and offsets of the buffers that are written? 2. If the client doesn't remember how long the strings were, how can the getbytes method of the sample bufferpool object take a size parameter? Shouldn't the client know the blocksize and allocate that amount of bytes to the char*/void* passed to the getbytes function, and then the Bufferpool should just copy the whole block to that memory? I know you all are probably not thinking about the project right now, but I would appreciate any answers. ========================================================================= Date: Tue, 14 Mar 2000 16:54:40 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: P3 clarifications In-Reply-To: <3.0.6.32.20000314013109.008095d0@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 14 Mar 2000, Jason Giglio wrote: > 1. How does the bufferpool know where things are in the file? Does it keep > another linked list to store the blockIDs and offsets of the buffers that > are written? The bufferpool needs to keep various information about its buffers. At a minimum, the block ID, and some indication about whether the buffer is "dirty", that is, been modified and must be written back to disk if it gets flushed from the pool. > 2. If the client doesn't remember how long the strings were, how can the > getbytes method of the sample bufferpool object take a size parameter? > Shouldn't the client know the blocksize and allocate that amount of bytes > to the char*/void* passed to the getbytes function, and then the Bufferpool > should just copy the whole block to that memory? Exactly. The client knows how big the buffers are, because that parameter is specified when the buffer pool is created. The "messages" passed between the client and the buffer pool can just the size of an entire buffer. Actually, when writing the string to the pool, you could stick to string length. But when "reading" from the pool, you just get the whole buffer. Then, just use "cout" to dump the string (since it is null terminated). -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Tue, 14 Mar 2000 18:28:10 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: Re: P3 clarifications In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Thanks for your response during break, I have a few more questions though. >> 1. How does the bufferpool know where things are in the file? Does it keep >> another linked list to store the blockIDs and offsets of the buffers that >> are written? > >The bufferpool needs to keep various information about its buffers. >At a minimum, the block ID, and some indication about whether the buffer >is "dirty", that is, been modified and must be written back to disk if it >gets flushed from the pool. I am kind of fuzzy still on the implementation of this. Would a linked list that had bufferNodes, with the information about the buffer that each node contains in LRU order be ok for the "in memory" buffers? That way when one needs to be flushed to disk, its buffer section would be written to the file, and then another seperate linked list that had the blockIDs and offsets of the buffers that are on disk would be updated, then the node would be deleted. This way, you traverse the "in memory" linked list of buffers, and if you don't find the blockID you are looking for in those, you continue on to look at the other linked list of IDs and offsets of the buffers on disk. If its on disk and needed, a node object would be created and appended to the live list, and the oldest node flushed if necessary to keep the number of buffers at the max. The record in the on-disk list would have to be retained even after you pull it into memory, so that if it is overwritten, you know not to put a new record on disk and to use the old space. Is this a valid implementation? The spec seems pretty open ended. This program is not at all as trivial as I first thought. > >> 2. If the client doesn't remember how long the strings were, how can the >> getbytes method of the sample bufferpool object take a size parameter? >> Shouldn't the client know the blocksize and allocate that amount of bytes >> to the char*/void* passed to the getbytes function, and then the Bufferpool >> should just copy the whole block to that memory? > >Exactly. The client knows how big the buffers are, because that parameter >is specified when the buffer pool is created. The "messages" passed >between the client and the buffer pool can just the size of an entire >buffer. Actually, when writing the string to the pool, you could stick to >string length. But when "reading" from the pool, you just get the whole >buffer. Then, just use "cout" to dump the string (since it is null >terminated). > >-- >Cliff Shaffer, Associate Professor Phone: (540) 231-4354 >Department of Computer Science Email: shaffer@cs.vt.edu >Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer >------------------------------------------------------------------------- > ========================================================================= Date: Wed, 15 Mar 2000 07:30:43 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Matt Stec Subject: P3 questions MIME-version: 1.0 Content-type: text/plain; charset=us-ascii I'm not sure I really understand what's to be done in this project. Let me start at the beginning. Invoking the program with "buffer 16 16" will create 16 buffers of 16 bytes, and this will stay constant throughout this instance of the program...ie, no insertion or deletion of buffers, correct? When insert is called, I will find the least recently used buffer and insert the string into it. Do I write this buffer to the file immediately? The output command: this will pull a string into a buffer, and then print out the buffer's contents. These commands seem to violate the principle of a buffer, which I thought was to avoid constant access to the disk. But as I see it, this buffer is more or less just writing to/from a file...not really acting like the buffer pool mentioned in the text. there is also a line in the spec: "After completing all commands in the input file, all unwritten blocks in the bufferpool should be written to disk..." What does that mean? Aren't we writing to the file immediately? So what's unwritten? I apologize if these are fairly obvious questions, but I'm a little confused as to what's happening here. thanks, matt ========================================================================= Date: Wed, 15 Mar 2000 11:49:24 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: P3 clarifications In-Reply-To: <3.0.6.32.20000314182810.0080bae0@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 14 Mar 2000, Jason Giglio wrote: > Thanks for your response during break, I have a few more questions though. > > >> 1. How does the bufferpool know where things are in the file? Does it keep > >> another linked list to store the blockIDs and offsets of the buffers that > >> are written? > > > >The bufferpool needs to keep various information about its buffers. > >At a minimum, the block ID, and some indication about whether the buffer > >is "dirty", that is, been modified and must be written back to disk if it > >gets flushed from the pool. > > I am kind of fuzzy still on the implementation of this. Would a linked > list that had bufferNodes, with the information about the buffer that each > node contains in LRU order be ok for the "in memory" buffers? > > That way when one needs to be flushed to disk, its buffer section would be > written to the file, and then another seperate linked list that had the > blockIDs and offsets of the buffers that are on disk would be updated, then > the node would be deleted. > > This way, you traverse the "in memory" linked list of buffers, and if you > don't find the blockID you are looking for in those, you continue on to > look at the other linked list of IDs and offsets of the buffers on disk. > If its on disk and needed, a node object would be created and appended to > the live list, and the oldest node flushed if necessary to keep the number > of buffers at the max. > > The record in the on-disk list would have to be retained even after you > pull it into memory, so that if it is overwritten, you know not to put a > new record on disk and to use the old space. > > Is this a valid implementation? The spec seems pretty open ended. > > This program is not at all as trivial as I first thought. Well, its actually a bit simpler than what I understand from reading the above. Let's say the bufferpool has 5 buffers. You create a linked list (or an array-based list, it doesn't matter) of 5 links, with each link containing a (pointer to a?) buffer. When appropriate, you read data into the buffer, or write data from a buffer. You never "destroy" buffers, and you only allocate the buffers once at initialization time. The buffers are always there, you just copy data in and out as appropriate, and change their position within the list as appropriate. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Wed, 15 Mar 2000 11:56:07 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: P3 questions In-Reply-To: <3.0.1.32.20000315073043.0069933c@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 15 Mar 2000, Matt Stec wrote: > I'm not sure I really understand what's to be done in this project. Let me > start at the beginning. > > Invoking the program with "buffer 16 16" will create 16 buffers of 16 > bytes, 16 bytes *each* > and this will stay constant throughout this instance of the > program...ie, no insertion or deletion of buffers, correct? Correct. > When insert is called, I will find the least recently used buffer and > insert the string into it. When insert is called, you check to see if the requested block is already stored in a buffer in the pool. If it is, move that buffer to the front of the list and do the insert. If not, then replace the contents of the least recently used buffer with the new string. Note that if the block being replaced had its contents modified previously, *it must be written to disk!* >Do I write this buffer to the file immediately? No. You write to file when (a) the contents of the buffer have previously been modified, and (b) the buffer is "flushed". A "flush" happens when either (i) the buffer is least recently used, and is about to be overwritten, or (ii) the program is ready to terminate. > The output command: this will pull a string into a buffer, and then print > out the buffer's contents. > > These commands seem to violate the principle of a buffer, which I thought > was to avoid constant access to the disk. But as I see it, this buffer is > more or less just writing to/from a file...not really acting like the > buffer pool mentioned in the text. All requrests go through the bufferpool. If a request comes for a block that is already in the bufferpool, then no disk I/O need be done. That's the whole point of a buffer pool. > there is also a line in the spec: "After completing all commands in the > input file, all unwritten blocks in the bufferpool should be written to > disk..." What does that mean? Aren't we writing to the file immediately? > So what's unwritten? See above. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Wed, 15 Mar 2000 15:37:24 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: Re: P3 clarifications In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" >Well, its actually a bit simpler than what I understand from reading the >above. Let's say the bufferpool has 5 buffers. You create a linked list >(or an array-based list, it doesn't matter) of 5 links, with each link >containing a (pointer to a?) buffer. When appropriate, you read data into >the buffer, or write data from a buffer. You never "destroy" buffers, and >you only allocate the buffers once at initialization time. The buffers >are always there, you just copy data in and out as appropriate, and change >their position within the list as appropriate. Ok I see this much of it, that way you never "traverse" the buffers, you would keep another array (or list) of information on what buffer contained which blockID and if it was dirty or not, and traverse that. Upon writing the buffer out however, wouldn't you still need another data structure that would track the offsets of a certain blockID on file? So at minimum you would have the following, an array of buffers or buffer pointers, an array of the same size that has buffer information, and a variable length linked list of structs or nodes that simply contains an int for blockID and a long for offset, for each block on disk? The only other way I can think of is to write the block ID on disk, in an index section of the file, or immediately preceeding the block data in the file, either way the overhead of scanning that would probably negate the speedup the buffer system gives. ========================================================================= Date: Wed, 15 Mar 2000 17:14:35 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: P3 clarifications In-Reply-To: <3.0.6.32.20000315153724.0080ea10@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 15 Mar 2000, Jason Giglio wrote: > Upon writing the buffer out however, wouldn't you still need another data > structure that would track the offsets of a certain blockID on file? > > So at minimum you would have the following, an array of buffers or buffer > pointers, an array of the same size that has buffer information, and a > variable length linked list of structs or nodes that simply contains an int > for blockID and a long for offset, for each block on disk? Yes, you need to keep information about each buffer. But, what would that be, other than the block ID currently associated with the buffer, and the "dirty page" bit? Note that "offset" and "block ID" are functionally equivalent, since the actual seek offset within the file should be: blockID * blocksize where blocksize is a private, non-changing data member for the buffer pool, received via the constructor at the time of creation. So, a reasonable design has each buffer in the bufferpool be an object that contains the blockID, the dirty page indicator, and the space for the buffer contents. This list, and a couple of data members (such as the blocksize and number of buffers), is all that the bufferpool class should need. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Wed, 15 Mar 2000 16:08:56 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: John Subject: binary I/O In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" is the binary file supposed to be the p3bin.dat file? Or are all files to be dealt with in binary? Thanks, John ========================================================================= Date: Wed, 15 Mar 2000 17:40:20 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: binary I/O In-Reply-To: <3.0.1.32.20000315160856.00802210@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 15 Mar 2000, John wrote: > is the binary file supposed to be the p3bin.dat file? Or are all files to > be dealt with in binary? Thanks, John For this project there are *three* distinct files. One is the input (command) file. Another is the output file. Those are both ASCII text files, with the input read from standard input, and the output written to standard output. So far, so good -- this is just the same as the first two projects. The third file is the backing store for the buffer pool, or, more accurately, the disk file that the buffer pool is the intermediary for. This is a binary file (even though, for this project, it just so happens that all of the data contents being passed from the client are ASCII strings). It is this third file that is named "p3bin.dat". It is created when the program starts. Note that it is important that all buffers be flushed to this file (if they are dirty) and the file closed at the end of the project. DO NOT DELETE THE FILE AT PROGRAM TERMINATION. The GTAs will use this file to help them grade the project. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Wed, 15 Mar 2000 16:50:59 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: Re: P3 clarifications In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" >Yes, you need to keep information about each buffer. But, what would that >be, other than the block ID currently associated with the buffer, and the >"dirty page" bit? Note that "offset" and "block ID" are functionally >equivalent, since the actual seek offset within the file should be: > >blockID * blocksize Woah, for this to be true, the blocks would have to be written to the file in order, starting at blockID 0. Suppose in the example in the spec, another insert is done "insert 3" after the get 1... assuming we only have 2 buffers for this example, this would make 2 the LRU buffer, and 2 would be written to disk, 1 would stay in memory. Then blockID 2 has offset 0, being the first block written.... or even if blockID 1 is written, you couldn't use the above formula, since 1*blocksize isn't 0, which would be the offset of the first block written... Maybe I am misunderstanding something major. A fixed length file would allow us to write the blocks at blockID*blocksize, but it would waste space and limit the number of blocks we can work with. > >where blocksize is a private, non-changing data member for the buffer >pool, received via the constructor at the time of creation. > >So, a reasonable design has each buffer in the bufferpool be an object >that contains the blockID, the dirty page indicator, and the space for the >buffer contents. This list, and a couple of data members (such as >the blocksize and number of buffers), is all that the bufferpool class >should need. So then assuming I am wrong above, and you can derive the offset from blockID, are you saying we should cast this object to char* and dump the whole object to file? ========================================================================= Date: Thu, 16 Mar 2000 11:57:06 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Patrick O'day Subject: getbytes MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit What happens when a BlockID is requested after it has moved out of the buffer? Should the data at BlockID * blocksize be returned? That then leads to keeping all valid BlockIDs in a dynamic structure so as to know which ones are valid and which just point to the space between valid data. example with a 2 buffers of size 16 bytes each: insert 1 hello world! insert 2 XXX insert 5 Nebraska get 3 {Not a valid entry} get 1 {1 has passed out of the buffer and on to disk} for get 3 an error should be written, but what about get 1? it is a valid ID but the buffer doesn't know that without keeping a list of all valid IDs. Patrick O'Day ========================================================================= Date: Thu, 16 Mar 2000 13:22:46 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: P3 clarifications In-Reply-To: <3.0.6.32.20000315165059.0080fbc0@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII First, let me say to everyone that this project, once you get the right mental model of what is supposed to happen, is pretty easy. But, for some reason the concept of a buffer pool is hard to "get". So, if things are looking to confusing, DO NOT start hacking away -- you should instead be putting the effort into figuring out what is really supposed to happen. At some point, it should all snap into place. You will save a lot of time in the long run. On Wed, 15 Mar 2000, Jason Giglio wrote: > >Yes, you need to keep information about each buffer. But, what would that > >be, other than the block ID currently associated with the buffer, and the > >"dirty page" bit? Note that "offset" and "block ID" are functionally > >equivalent, since the actual seek offset within the file should be: > > > >blockID * blocksize > > > Woah, for this to be true, the blocks would have to be written to the file > in order, starting at blockID 0. Suppose in the example in the spec, > another insert is done "insert 3" after the get 1... assuming we only have > 2 buffers for this example, this would make 2 the LRU buffer, and 2 would > be written to disk, 1 would stay in memory. Then blockID 2 has offset 0, > being the first block written.... or even if blockID 1 is written, you > couldn't use the above formula, since 1*blocksize isn't 0, which would be > the offset of the first block written... > > Maybe I am misunderstanding something major. OK, here's the problem (I hope this makes sense...). Ignore the buffer pool for the moment. The buffer pool is purely a cache, used for efficiency purposes. If there was NO buffer pool, everything would be the same. The block with block ID 0 is, by definition, at block position 0 in the file. For example, if the block size is 1K bytes, then the first 1K bytes constitute block 0 (with blockID 0), the next 1K bytes are block 1, and so on. Now, the bufferpool holds some of the blocks in memory, so that a block that gets used a lot doesn't need to be read/written to disk on every access. Where/if a block will be in the bufferpool has NOTHING to do with its BlockID (that is, its position in the file). It has ONLY to do with the pattern of accesses. >A fixed length file would > allow us to write the blocks at blockID*blocksize, but it would waste space > and limit the number of blocks we can work with. The file is NOT fixed length. It grows as necessary, driven by the "insert" commands. For example, if the first insert command is to block 1, then the file is two blocks long (block 0 and block 1). If the next insert command is to block 5, then the file becomes 6 blocks long. > So then assuming I am wrong above, and you can derive the offset from > blockID, are you saying we should cast this object to char* and dump the > whole object to file? Correct, if I understand what you are asking. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Thu, 16 Mar 2000 13:30:47 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: getbytes In-Reply-To: <38D11262.9B3EFE9F@vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Thu, 16 Mar 2000, Patrick O'day wrote: > What happens when a BlockID is requested after it has moved out of the buffer? > Should the data at BlockID * blocksize be returned? Correct. > That then leads to keeping > all valid BlockIDs in a dynamic structure so as to know which ones are valid > and which just point to the space between valid data. > example with a 2 buffers of size 16 bytes each: > insert 1 hello world! > insert 2 XXX > insert 5 Nebraska > get 3 {Not a valid entry} > get 1 {1 has passed out of the buffer and on to disk} > > for get 3 an error should be written, but what about get 1? it is a valid ID > but the buffer doesn't know that without keeping a list of all valid IDs. You are correct that the spec does not make this clear. What I suggest you do is keep, for the bufferpool, a variable that tells the max size for the file at the current moment. If a "get" request comes for a block beyond that max size, return some sort of error. (Note that it is perfectly OK to "insert" past the current end of the file -- that is the only way to make the file grow.) On the other hand, if a request comes for a block WITHIN the file bounds, that block should just be filled with nulls and its not the business of the bufferpool to be concerned with the semantics of the client's data requests. I certainly don't intend for you to keep a separate data structure of "valid" block IDs within the (current) legal bounds of the file. Just let the "natural" thing happen. On the other hand, if Block 3 has previously been written to, subsequently falls out of the bufferpool, and then gets requested, that is just how things work. There is nothing logically wrong with this sequence of events, and will happen pretty often, depending on how much locality-of-reference there is in the pattern of data accesses. The block just gets read back into a buffer. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Thu, 16 Mar 2000 12:40:09 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Mike Schaefer Subject: Re: P3 clarifications MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable As I understand it, you have a linked list with all the info, i.e. block = ID, indication if buffer has been modified, and a pointer to the data. = That's it. The position in the linked list indicates the order they = have been accessed. What else do you need? -----Original Message----- From: Jason Giglio [SMTP:jgiglio@VT.EDU] Sent: Wednesday, March 15, 2000 3:37 PM To: CS2604@LISTSERV.VT.EDU Subject: Re: P3 clarifications >Well, its actually a bit simpler than what I understand from reading = the >above. Let's say the bufferpool has 5 buffers. You create a linked = list >(or an array-based list, it doesn't matter) of 5 links, with each link >containing a (pointer to a?) buffer. When appropriate, you read data = into >the buffer, or write data from a buffer. You never "destroy" buffers, = and >you only allocate the buffers once at initialization time. The buffers >are always there, you just copy data in and out as appropriate, and = change >their position within the list as appropriate. Ok I see this much of it, that way you never "traverse" the buffers, you would keep another array (or list) of information on what buffer = contained which blockID and if it was dirty or not, and traverse that. Upon writing the buffer out however, wouldn't you still need another = data structure that would track the offsets of a certain blockID on file? So at minimum you would have the following, an array of buffers or = buffer pointers, an array of the same size that has buffer information, and a variable length linked list of structs or nodes that simply contains an = int for blockID and a long for offset, for each block on disk? The only other way I can think of is to write the block ID on disk, in = an index section of the file, or immediately preceeding the block data in = the file, either way the overhead of scanning that would probably negate the speedup the buffer system gives. ========================================================================= Date: Thu, 16 Mar 2000 13:42:11 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: Re: P3 clarifications In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" At 01:22 PM 3/16/00 -0500, you wrote: >First, let me say to everyone that this project, once you get the right >mental model of what is supposed to happen, is pretty easy. But, for some >reason the concept of a buffer pool is hard to "get". So, if things are >looking to confusing, DO NOT start hacking away -- you should instead be >putting the effort into figuring out what is really supposed to happen. >At some point, it should all snap into place. You will save a lot of time >in the long run. > I agree. However I think that some of what you are expecting in this project, that we have talked on about here, should be (should have been?) in the spec. The book really doesn't cover LRU write buffers, it is more concerned with read only buffers, and the spec seems pretty fuzzy on some of these areas. Only after reading this last message can I say that I really finally understand what you want us to do here. Maybe I am just dense. > >The block with block ID 0 is, by definition, at block position 0 in the >file. For example, if the block size is 1K bytes, then the first 1K bytes >constitute block 0 (with blockID 0), the next 1K bytes are block 1, and so >on. So we are going to have to output blank buffers to make them fit into the proper blockID "slot" in the file. This is the part that I didn't understand. >> So then assuming I am wrong above, and you can derive the offset from >> blockID, are you saying we should cast this object to char* and dump the >> whole object to file? > >Correct, if I understand what you are asking. Let me clarify to be sure, I think I was wrong. I meant to say "Should we output the whole buffer 'node' object, that includes the BlockID and dirty flag, or should it be rebuilt after a read?" I realize now that it is just as easy to keep a fixed number of node objects around and just reassign the contents and only write the actual data section to the file. ========================================================================= Date: Thu, 16 Mar 2000 15:08:50 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: P3 clarifications In-Reply-To: <3.0.6.32.20000316134211.0080f950@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Thu, 16 Mar 2000, Jason Giglio wrote: > >The block with block ID 0 is, by definition, at block position 0 in the > >file. For example, if the block size is 1K bytes, then the first 1K bytes > >constitute block 0 (with blockID 0), the next 1K bytes are block 1, and so > >on. > > So we are going to have to output blank buffers to make them fit into the > proper blockID "slot" in the file. This is the part that I didn't understand. As I said in an earlier posting, you only need to write blocks that are (i) dirty and (2) flushed from the bufferpool. > Let me clarify to be sure, I think I was wrong. I meant to say "Should we > output the whole buffer 'node' object, that includes the BlockID and dirty > flag, or should it be rebuilt after a read?" > I realize now that it is just as easy to keep a fixed number of node > objects around and just reassign the contents and only write the actual > data section to the file. You only write data contents to file. The blockID *is* the position of the block, so that need not be stored. And, when it is read in from disk, the block cannot be "dirty", since "dirty" means that the in-memory data contents have been modified from what is presently stored on disk. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Thu, 16 Mar 2000 17:50:54 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Shalaka Tendulkar Subject: P2 Grades:Section 1368 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Hi, P2 grades for section 1368 have been posted on the website. If you have any problems, contact me. The grading sheets will be distributed shortly. Shalaka ========================================================================= Date: Thu, 16 Mar 2000 19:26:32 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: MIN LIANG Subject: P2 grading sheets: section 1368 MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_MK2Hh2B9IBFnlKlpxak9RA)" This is a multi-part message in MIME format. --Boundary_(ID_MK2Hh2B9IBFnlKlpxak9RA) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable Hi, P2 grading sheets for section 1368 have been sent out. If you have any = problems, contact with stendulk@csgrad.cs.vt.edu. Thanks, Min Liang --Boundary_(ID_MK2Hh2B9IBFnlKlpxak9RA) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
Hi,

P2 grading sheets for = section 1368 have=20 been sent out. If you have any problems, contact with stendulk@csgrad.cs.vt.edu.<= /FONT>
 
Thanks,
 
Min=20 Liang
--Boundary_(ID_MK2Hh2B9IBFnlKlpxak9RA)-- ========================================================================= Date: Fri, 17 Mar 2000 13:59:54 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Section 1371 Project 2 gradesheets MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII The P2 gradesheets from my section for those students for whom the GTA did not have any problems doing the grading have now been emailed. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Fri, 17 Mar 2000 14:09:50 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Ali Asghar Zafer Subject: Spresdsheet of grades In-Reply-To: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII The spreadsheet for 1371 has now been updated to show marks for P2. Please contact me if you find any inconsistency between what is posted and what shows on your grade sheets. Thanks Ali Asghar Zafer ========================================================================= Date: Sat, 18 Mar 2000 13:22:33 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Will Boyle Subject: Question about the diskfile MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Hi I know that we create and manage the diskfile for this program. I also know that we close the file at the end of the program. But my question is do we reuse the contents of the diskfile again once we restart the program? Thanks Will ========================================================================= Date: Sun, 19 Mar 2000 15:21:21 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Ali Asghar Zafer Subject: P3 Sample data/P2 grading data In-Reply-To: <0FRM0002OQHQ17@gkar.cc.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 1..The P3 sample test files have been put on the web. 2..The P2 test files that GTA's had used for grading are also on the web at courses.cs.vt.edu/~cs2604/p2FinalTestData.zip Thanks Ali Asghar Zafer ========================================================================= Date: Mon, 20 Mar 2000 12:20:26 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Dr. Shaffer's class cancelled today (Monday, 3/20) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII My section (1:00) will be cancelled today. I apologize for the late notice, but this is the first time since yesterday afternoon that I've been healthy enough to sit at a keyboard. I hope to see you all Wednesday! If you haven't already, be sure to read the series of email messages regarding P3. I hope they make things clearer. I'll try to answer more email questions tonight, but if I am unable to, then certainly I will tomorrow. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Mon, 20 Mar 2000 11:33:23 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Andy Strassburg Subject: Re: Dr. Shaffer's class cancelled today (Monday, 3/20) In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Hi, Don't you mean your 2:00 section? I don't think you meant 1. Andy ========================================================================= Date: Mon, 20 Mar 2000 11:42:26 -0800 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: John Subject: writing to disk MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Can someone explain exactly what it means for the buffer to be dirty? I understand this means it has been "previously modified" but this is still unclear to me because it seems that any time you write to buffer it has been modified (?). Also can someone explain at which times that we write to the disk file. I am unsure as to if we expand the file immediately on an insert, or only when the buffer is dirty or replaced. Thanks a lot, JOHN ========================================================================= Date: Mon, 20 Mar 2000 14:43:40 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Pratima Aiyagari Subject: sections 1368 and 1369 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII Grades for Sections 1368 and 1369 have been updated on the course web-page. If there is a problem please meet Shalaka or me during our office hours. Thanks, Pratima ========================================================================= Date: Mon, 20 Mar 2000 16:00:45 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: Re: writing to disk In-Reply-To: <000d01bf92a4$6c019c80$4f21fea9@default> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" A buffer is dirty if it has been modified *since the last time it was written to disk*. A buffer is 'born dirty' when you first put data into it, since it isn't on disk yet. It can become clean by being pushed off the end of the buffer pool, but then it isn't a buffer anymore, it is just the data on disk. The only time you have a clean buffer is after the data is written to disk, and then you read it back into the buffer pool. Unless it is overwritten, it stays clean, and if it is pushed off the end of the bufferpool when it is clean, you just junk it, it is still on the disk. You only write to the disk when all your buffers are full, and you need to insert another one. To make a free space, the Least Recently Used buffer is flushed. This means, if it is dirty you write it on disk, expanding the file if necessary, if it is clean you just replace it. Remember to move the most recently used buffer to the head of the list. This will likely be the newly flushed buffer that was the least recently used. At 11:42 AM 3/20/00 -0800, you wrote: >Can someone explain exactly what it means for the buffer to be dirty? I >understand this means it has been "previously modified" but this is still >unclear to me because it seems that any time you write to buffer it has been >modified (?). > Also can someone explain at which times that we write to the disk file. >I am unsure as to if we expand the file immediately on an insert, or only >when the buffer is dirty or replaced. Thanks a lot, JOHN > ========================================================================= Date: Mon, 8 Mar 0100 01:27:41 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brian Wagner Subject: Re: Question about the diskfile In-Reply-To: <0FRM0002OQHQ17@gkar.cc.vt.edu> from "Will Boyle" at Mar 18, 0 01:22:33 pm Content-Type: text > I know that we create and manage the diskfile for this program. I also know > that we close the file at the end of the program. But my question is do we > reuse the contents of the diskfile again once we restart the program? Excellent question. By the way it's written, I assume that we "clobber" the file if it previously existed (upon starting up the program). That's what I'm going w/... I belive the I/O streams options is called "truncate." I'm not sure though... -- // Brian Wagner, CpE WWW: http://www.bigfoot.com/~datatroi "[Source code] documentation is like sex... When it's good, it's great. And when it's bad, it's better than nothing..." ------------------------------------------------------------------------- ========================================================================= Date: Tue, 21 Mar 2000 12:00:30 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: writing to disk In-Reply-To: <3.0.6.32.20000320160045.0081ac70@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Mon, 20 Mar 2000, Jason Giglio wrote: > A buffer is dirty if it has been modified *since the last time it was > written to disk*. A buffer is 'born dirty' when you first put data into > it, since it isn't on disk yet. It can become clean by being pushed off > the end of the buffer pool, but then it isn't a buffer anymore, it is just > the data on disk. The only time you have a clean buffer is after the data > is written to disk, and then you read it back into the buffer pool. Unless > it is overwritten, it stays clean, and if it is pushed off the end of the > bufferpool when it is clean, you just junk it, it is still on the disk. > > You only write to the disk when all your buffers are full, and you need to > insert another one. To make a free space, the Least Recently Used buffer > is flushed. This means, if it is dirty you write it on disk, expanding the > file if necessary, if it is clean you just replace it. Remember to move > the most recently used buffer to the head of the list. This will likely be > the newly flushed buffer that was the least recently used. Very good! -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Tue, 21 Mar 2000 12:01:13 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: Question about the diskfile In-Reply-To: <0FRM0002OQHQ17@gkar.cc.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII You create the file new again each time you start the program -- you do NOT want to be using data from a previous run of the program. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- On Sat, 18 Mar 2000, Will Boyle wrote: > Hi > > I know that we create and manage the diskfile for this program. I also know > that we close the file at the end of the program. But my question is do we > reuse the contents of the diskfile again once we restart the program? > > Thanks > Will > ========================================================================= Date: Tue, 21 Mar 2000 11:17:52 -0500 Reply-To: csharp@vt.edu Sender: CS2604 discussion list From: Chris Sharp Subject: Re: writing to disk In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Just a quick question that came to mind when looking at the sample output and this message....When a buffer is pushed off the end of the buffer and written to disk, and is then later requested using a get command, is the data then read from the file p3bin.dat? So if this is the case then in p3bin.dat we would need to have the string as well as the blockID? I have a feeling I am missing something. Can anyone fill me in? Thanks, Chris -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu] On Behalf Of Cliff Shaffer Sent: Tuesday, March 21, 2000 12:01 PM To: CS2604@LISTSERV.VT.EDU Subject: Re: writing to disk On Mon, 20 Mar 2000, Jason Giglio wrote: > A buffer is dirty if it has been modified *since the last time it was > written to disk*. A buffer is 'born dirty' when you first put data into > it, since it isn't on disk yet. It can become clean by being pushed off > the end of the buffer pool, but then it isn't a buffer anymore, it is just > the data on disk. The only time you have a clean buffer is after the data > is written to disk, and then you read it back into the buffer pool. Unless > it is overwritten, it stays clean, and if it is pushed off the end of the > bufferpool when it is clean, you just junk it, it is still on the disk. > > You only write to the disk when all your buffers are full, and you need to > insert another one. To make a free space, the Least Recently Used buffer > is flushed. This means, if it is dirty you write it on disk, expanding the > file if necessary, if it is clean you just replace it. Remember to move > the most recently used buffer to the head of the list. This will likely be > the newly flushed buffer that was the least recently used. Very good! -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Tue, 21 Mar 2000 12:32:28 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: writing to disk In-Reply-To: <000001bf9351$02c0ff60$92d5c026@dogbert> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 21 Mar 2000, Chris Sharp wrote: > Just a quick question that came to mind when looking at the sample output > and this message....When a buffer is pushed off the end of the buffer and > written to disk, and is then later requested using a get command, is the > data then read from the file p3bin.dat? Yes. > So if this is the case then in > p3bin.dat we would need to have the string as well as the blockID? I have a > feeling I am missing something. Can anyone fill me in? p3bin.dat stores the string -- it does not store a blockID. The request comes as a request for a given block. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Tue, 21 Mar 2000 17:51:27 -0800 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: John Subject: file size MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit In the notes on the website, it talks about including a header file #include in order to get the size of the file. Is there a header without the .h extention? Also is this the only way to get the size? Thanks, John ========================================================================= Date: Tue, 21 Mar 2000 19:00:06 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jonathan Pryor Subject: Re: file size In-Reply-To: <004d01bf93a1$236e1d60$4f21fea9@default> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit There is no standard header without the extension (that I know of). is defined by POSIX, not by the C/C++ languages, so new language versions aren't likely to change the header. Is it the only way? Of course not. But it's the fastest way. Another way that comes to mind is to open the file, and read through it, counting every byte you encounter. Ugly, inefficient, but it should work... What's wrong with using stat()? - Jon > -----Original Message----- > From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of > John > Sent: Tuesday, March 21, 2000 8:51 PM > To: CS2604@LISTSERV.VT.EDU > Subject: file size > > > In the notes on the website, it talks about including a header file > > #include > > in order to get the size of the file. Is there a header without the .h > extention? Also is this the only way to get the size? > Thanks, John ========================================================================= Date: Tue, 21 Mar 2000 19:35:13 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: more on the bin file MIME-version: 1.0 Content-type: text/plain; charset=us-ascii > You only write to the disk when all your buffers are full, and you need to > insert another one. To make a free space, the Least Recently Used buffer > is flushed. This means, if it is dirty you write it on disk, expanding the > file if necessary, if it is clean you just replace it. Remember to move > the most recently used buffer to the head of the list. This will likely be > the newly flushed buffer that was the least recently used. expanding the file if necessary? so will the binary file have *at most* 16 records in it if there are 16 buffers?? or will the binary file keep expanding until the program ends?? ========================================================================= Date: Tue, 21 Mar 2000 19:39:13 -0800 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Stephen Hoskins Subject: Re: writing to disk MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_bpoD1QZG50wIbESyj0wJqg)" --Boundary_(ID_bpoD1QZG50wIbESyj0wJqg) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit wHat?!!! If the "p3bin.dat" file does not store the blockID, then how do you determine if the string in the file is the correct string for the blockID that is being requested from the "get" command? It is stated at the end of this letter, "The request comes as a request for a given block." What does that mean? I think this answers my question but I don't understand it. Anyway, PLEASE HELP ME! Thank you. =D -Stephen Hoskins Cliff Shaffer wrote: > On Tue, 21 Mar 2000, Chris Sharp wrote: > > > Just a quick question that came to mind when looking at the sample output > > and this message....When a buffer is pushed off the end of the buffer and > > written to disk, and is then later requested using a get command, is the > > data then read from the file p3bin.dat? > > Yes. > > > So if this is the case then in > > p3bin.dat we would need to have the string as well as the blockID? I have a > > feeling I am missing something. Can anyone fill me in? > > p3bin.dat stores the string -- it does not store a blockID. The request > comes as a request for a given block. > > -- > Cliff Shaffer, Associate Professor Phone: (540) 231-4354 > Department of Computer Science Email: shaffer@cs.vt.edu > Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer > ------------------------------------------------------------------------- --Boundary_(ID_bpoD1QZG50wIbESyj0wJqg) Content-type: text/html; charset=us-ascii Content-transfer-encoding: 7bit wHat?!!!  If the "p3bin.dat" file does not store the blockID, then how do you determine if the string in the file is the correct string for the blockID that is being requested from the "get" command?  It is stated at the end of this letter, "The request
comes as a request for a given block."  What does that mean?  I think this answers my question but I don't understand it.  Anyway, PLEASE HELP ME!  <ehem>  Thank you. =D
-Stephen Hoskins

Cliff Shaffer wrote:

On Tue, 21 Mar 2000, Chris Sharp wrote:

> Just a quick question that came to mind when looking at the sample output
> and this message....When a buffer is pushed off the end of the buffer and
> written to disk, and is then later requested using a get command, is the
> data then read from the file p3bin.dat?

Yes.

> So if this is the case then in
> p3bin.dat we would need to have the string as well as the blockID?  I have a
> feeling I am missing something.  Can anyone fill me in?

p3bin.dat stores the string -- it does not store a blockID.  The request
comes as a request for a given block.

--
Cliff Shaffer, Associate Professor          Phone: (540) 231-4354
Department of Computer Science              Email: shaffer@cs.vt.edu
Virginia Tech, Blacksburg, VA 24061-0106    WWW:   www.cs.vt.edu/~shaffer
-------------------------------------------------------------------------

--Boundary_(ID_bpoD1QZG50wIbESyj0wJqg)-- ========================================================================= Date: Tue, 21 Mar 2000 20:03:27 -0500 Reply-To: jcovin@vt.edu Sender: CS2604 discussion list From: Jon Covin Subject: Re: writing to disk In-Reply-To: <38D84061.B8CDE2DD@vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT blocksize * blockID that will give you the correct spot in the .dat file to read from, you read the whole block which should be some string terminated by a null character, then you can output it. Ex: trying to get block5 from the file your bufferpool get method looks at position 5 * blocksize of the file and reads that whole block into an empty buffer node. then you output that string. -Jon > wHat?!!! If the "p3bin.dat" file does not store the blockID, then how do you > determine if the string in the file is the correct string for the blockID that is > being requested from the "get" command? It is stated at the end of this letter, > "The request > comes as a request for a given block." What does that mean? I think this answers > my question but I don't understand it. Anyway, PLEASE HELP ME! Thank > you. =D > -Stephen Hoskins > > Cliff Shaffer wrote: > > > On Tue, 21 Mar 2000, Chris Sharp wrote: > > > > > Just a quick question that came to mind when looking at the sample output > > > and this message....When a buffer is pushed off the end of the buffer and > > > written to disk, and is then later requested using a get command, is the > > > data then read from the file p3bin.dat? > > > > Yes. > > > > > So if this is the case then in > > > p3bin.dat we would need to have the string as well as the blockID? I have a > > > feeling I am missing something. Can anyone fill me in? > > > > p3bin.dat stores the string -- it does not store a blockID. The request > > comes as a request for a given block. > > > > -- > > Cliff Shaffer, Associate Professor Phone: (540) 231-4354 > > Department of Computer Science Email: shaffer@cs.vt.edu > > Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer > > ------------------------------------------------------------------------- > ========================================================================= Date: Tue, 21 Mar 2000 20:05:40 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: "J.p. Lien" Subject: Re: writing to disk In-Reply-To: <38D84061.B8CDE2DD@vt.edu> MIME-version: 1.0 Content-type: text/enriched; charset=us-ascii wHat?!!! If the "p3bin.dat" file does not store the blockID, then how do you determine if the string in the file is the correct string for the blockID that is being requested from the "get" command? It is stated at the end of this letter, "The request comes as a request for a given block." What does that mean? I think this answers my question but I don't understand it. Anyway, PLEASE HELP ME! < Thank you. =D As has been mentioned on this list before, the position of the record within the file is (BlockID * sizeofrecord). So if you want a particular block, you seek to that position in the file. J.p. ========================================================================= Date: Tue, 21 Mar 2000 20:25:01 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Garrett Berneche Subject: creating dat file MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit i don't see where any one has asked this before, so maybe i am the only person that doesn't know, but how do you get the program to actually create the dat file? if i make the dat file manually it can manipulate it, but if i do not create the file outside of the program then no file gets created. ========================================================================= Date: Tue, 21 Mar 2000 21:10:44 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Curtis Berry Subject: invalid gets MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit i'm a little unclear about what should happen when the buffer pool receives an invalid "get" request. Shaffer said earlier that invalid requests to the interior of the file will be ok because the blocks without data there will just be filled with nulls, but my file is very definitely not filled with nulls... it's filled with crap. This works in general because the nulls exist where they should, that is, at the end of a record, but i'm still left with the problem of invalid requests. i'm not really excited by the idea of filling the file with nulls myself, so my question then is this, is it alright if we go ahead and keep track of the valid ID's and then print errors if the requested ID isn't in the list? Thanks. curtis ========================================================================= Date: Tue, 21 Mar 2000 23:01:46 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Ali Asghar Zafer Subject: Re: more on the bin file In-Reply-To: <3.0.6.32.20000321193513.0091c680@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 21 Mar 2000, david wrote: > > You only write to the disk when all your buffers are full, and you need to > > insert another one. To make a free space, the Least Recently Used buffer > > is flushed. This means, if it is dirty you write it on disk, expanding the > > file if necessary, if it is clean you just replace it. Remember to move > > the most recently used buffer to the head of the list. This will likely be > > the newly flushed buffer that was the least recently used. > > > expanding the file if necessary? > > so will the binary file have *at most* 16 records in it if there are 16 > buffers?? > or will the binary file keep expanding until the program ends?? The size of the binary file can be unlimited. But at a time you can store at most 16 records in the buffers. ========================================================================= Date: Wed, 22 Mar 2000 00:42:05 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: tabs in input file MIME-version: 1.0 Content-type: text/plain; charset=us-ascii the spec says "an arbitrary number of additional spaces may be interspersed between parameters." this line from the input file has tabs: insert 18 Good you have reached 3rd so are tabs being counted as spaces in this spec?? ========================================================================= Date: Wed, 22 Mar 2000 08:21:24 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jordan Chavez Subject: Re: tabs in input file In-Reply-To: <3.0.6.32.20000322004205.0090dac0@mail.vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Yes, tabs count as white space. At 12:42 AM 3/22/00 -0500, you wrote: >the spec says "an arbitrary number of additional spaces may be interspersed >between parameters." > >this line from the input file has tabs: >insert 18 Good you have reached 3rd > >so are tabs being counted as spaces in this spec?? > ========================================================================= Date: Wed, 22 Mar 2000 11:13:38 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: tabs in input file In-Reply-To: <3.0.6.32.20000322004205.0090dac0@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 22 Mar 2000, david wrote: > the spec says "an arbitrary number of additional spaces may be interspersed > between parameters." > > this line from the input file has tabs: > insert 18 Good you have reached 3rd > > so are tabs being counted as spaces in this spec?? While it is always wise to write your program so that it can handle things like tabs, it was not our intention to put tabs in the test data. I have corrected the sample data file. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Wed, 22 Mar 2000 11:30:29 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: CHANGE TO SPEC (Was: invalid gets) In-Reply-To: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 21 Mar 2000, Curtis Berry wrote: > .. but my file is very definitely not filled with > nulls... it's filled with crap. This is bothersome -- certainly not what I expected! The old C-style routines definitely null-filled intervening portions of the file, I just assumed C++ maintained that convention. No matter. To avoid any possibility for ambiguity, or potential for failure in the semantics of the commands, the following change has been made to the specs (the revised version has now been posted to the website). This is trivial to implement. Note that it does NOT require you to keep a list of blocks that have/have not been written to, but only a "high water mark" value. Addition to spec for "insert" command: Your bufferpool should keep track of the highest-numbered block written to so far. If a new "insert" command writes beyond that, then the file should grow in size accordingly. Any intervening blocks should be filled with null values to insure that future "get" requests will work properly. For example, if the highest-numbered block so far written had been 10, and an "insert" command is given for block 13, then blocks 11 and 12 should be filled with nulls. Addition to the "get" command: If $blockID$ refers to a block beyond the highest-numbered block so far written to by an {\bf insert} command, an error should be returned. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Wed, 22 Mar 2000 11:32:14 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: creating dat file In-Reply-To: <001701bf939d$71ce0960$2b6052c6@hellhound> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 21 Mar 2000, Garrett Berneche wrote: > i don't see where any one has asked this before, so maybe i am the only > person that doesn't know, but how do you get the program to actually create > the dat file? Look up the documentation for the fstream class, in particular the constructor. A good place to start is the notes posted at the course website. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Wed, 22 Mar 2000 10:43:55 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brandon Horsley Subject: Re: file size MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit i guess that's why i like old c style fseek( FileName, 0, SEEK_END ); FileSize = ftell( FileName ); and no additional includes > There is no standard header without the extension (that I know of). > is defined by POSIX, not by the C/C++ languages, so > new language versions aren't likely to change the header. > > Is it the only way? Of course not. But it's the fastest way. > Another way that comes to mind is to open the file, and read through > it, counting every byte you encounter. Ugly, inefficient, but it > should work... > > What's wrong with using stat()? ========================================================================= Date: Wed, 22 Mar 2000 10:56:49 -0800 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: John Subject: Re: file size MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit what would FileName be? "p3bin.dat" ? I get errors on the first parameter... John ----- Original Message ----- From: Brandon Horsley To: Sent: Wednesday, March 22, 2000 7:43 AM Subject: Re: file size > i guess that's why i like old c style > > fseek( FileName, 0, SEEK_END ); > FileSize = ftell( FileName ); > > and no additional includes > > > > > There is no standard header without the extension (that I know of). > > is defined by POSIX, not by the C/C++ languages, so > > new language versions aren't likely to change the header. > > > > Is it the only way? Of course not. But it's the fastest way. > > Another way that comes to mind is to open the file, and read through > > it, counting every byte you encounter. Ugly, inefficient, but it > > should work... > > > > What's wrong with using stat()? ========================================================================= Date: Wed, 22 Mar 2000 11:21:04 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brandon Horsley Subject: Re: file size MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit > what would FileName be? "p3bin.dat" ? I get errors on the first > parameter... John > FileName would be of type FILE * -- sorry, FileName was a *bad* variable name #include //(the c equivilant of iostream.h) void main () { FILE *File = fopen ("p3bin.dat", "b"); // <== I think that's how to do a c open fseek( File, 0, SEEK_END ); FileSize = ftell( File ); printf ("%d\n", FileSize); } ========================================================================= Date: Wed, 22 Mar 2000 12:45:46 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: file size In-Reply-To: <38D8F2F0.A85EFEEE@vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 22 Mar 2000, Brandon Horsley wrote: > > what would FileName be? "p3bin.dat" ? I get errors on the first > > parameter... John > > > > FileName would be of type FILE * -- sorry, FileName was a *bad* variable > name > > #include //(the c equivilant of iostream.h) > void main () { > FILE *File = fopen ("p3bin.dat", "b"); // <== I think that's how to do > a c open > fseek( File, 0, SEEK_END ); > FileSize = ftell( File ); > printf ("%d\n", FileSize); > } But, don't do this. Use C++ streams. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Wed, 22 Mar 2000 12:41:32 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brandon Horsley Subject: Re: file size MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit > But, don't do this. Use C++ streams. sure, but why not? I mean, other than because you asked me to, are there drawbacks to doing it with regular c opposed to c++? ========================================================================= Date: Wed, 22 Mar 2000 12:50:53 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Mark Subject: Re: CHANGE TO SPEC (Was: invalid gets) MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Two things... first of all, say the command get 8 is used in the sample input file. Is this considered an error, since there was never a record 8, or should a blank string be returned since that space should be filled with NULLs now? Second, i see no need to use the highest block written so far. That's what you use the size of the file for. The only thing to this is, the file has to be closed when you check the file size. meaning you open and close the p3bin.dat file at each read/write. Is that ok to do, or should we avoid doing that? Mark ========================================================================= Date: Wed, 22 Mar 2000 14:01:03 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: file size In-Reply-To: <38D905CC.D581EBD0@vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 22 Mar 2000, Brandon Horsley wrote: > > But, don't do this. Use C++ streams. > > sure, but why not? I mean, other than because you asked me to, are there > drawbacks to doing it with regular c opposed to c++? Mainly because you want to be sure to be familiar with what is now the more commonly used (and better supported) idiom. If you are already well familiar with both (meaning you have written several programs with each the competing approaches), then it doesn't matter. If that is not the case, then you are far better off practicing fstream. One is not particularly harder to use than the other. If you are familiar with C-style FILEs and you considering taking the easy way out by not learning fstream, you are definiately making a bad decision. Most people come to this project not knowing either. For those people it is certainly better to start off using fstream. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Wed, 22 Mar 2000 14:06:42 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: CHANGE TO SPEC (Was: invalid gets) In-Reply-To: <002601bf9427$2b476d80$666152c6@darboy> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 22 Mar 2000, Mark wrote: > Two things... first of all, say the command get 8 is used in the sample > input file. Is this considered an error, since there was never a record 8, > or should a blank string be returned since that space should be filled with > NULLs now? That depends on when the request takes place. The sample input file has insert commands all the way up to 18. If the "get" to 8 took place AFTER an insert to some block with a higher ID then 8, then the result is a null string. If the "get" took place prior to an "insert" to block 8 or higher, then it is an error. > Second, i see no need to use the highest block written so far. That's what > you use the size of the file for. The only thing to this is, the file has > to be closed when you check the file size. meaning you open and close the > p3bin.dat file at each read/write. Is that ok to do, or should we avoid > doing that? It comes to the same thing. Seems to me that storing/updating an integer is faster than opening/closing a file, though. Especially since closing the file will probably make the disk cache flush unnecessarily. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Wed, 22 Mar 2000 13:35:40 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Ago Sukanovic Subject: Re: CHANGE TO SPEC (Was: invalid gets) MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit > > Two things... first of all, say the command get 8 is used in the sample > > input file. Is this considered an error, since there was never a record 8, > > or should a blank string be returned since that space should be filled with > > NULLs now? > > That depends on when the request takes place. The sample input file has > insert commands all the way up to 18. If the "get" to 8 took place AFTER > an insert to some block with a higher ID then 8, then the result is a null > string. If the "get" took place prior to an "insert" to block 8 or > higher, then it is an error. > OK. But you said that the only time that we write to the disk is when the buffer is pushed out, or at the end of the program. At the beginning the file is empty, right? Consider this input (5 buffers, block size 15): insert 0 something insert 5 something else // as of now the file is still empty get 3 Now, the first thing to do is to look through the list of the buffers to see if there is a block with ID 3. Since there is no such block the next reasonable thing is to read the block from the disk, but the disk is still empty. Ups, crash... The only way to avoid this is to write the new blocks to the disk immediately, but that is against the spec. Help. Ago Sukanovic ========================================================================= Date: Wed, 22 Mar 2000 14:49:27 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: CHANGE TO SPEC (Was: invalid gets) In-Reply-To: <009b01bf942d$6cb58da0$66b952c6@narnia.math.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 22 Mar 2000, Ago Sukanovic wrote: > > > Two things... first of all, say the command get 8 is used in the sample > > > input file. Is this considered an error, since there was never a record > 8, > > > or should a blank string be returned since that space should be filled > with > > > NULLs now? > > > > That depends on when the request takes place. The sample input file has > > insert commands all the way up to 18. If the "get" to 8 took place AFTER > > an insert to some block with a higher ID then 8, then the result is a null > > string. If the "get" took place prior to an "insert" to block 8 or > > higher, then it is an error. > > > > OK. But you said that the only time that we write to the disk is when the > buffer is pushed out, or at the end of the program. At the beginning the > file is empty, right? > Consider this input (5 buffers, block size 15): > > insert 0 something > insert 5 something else > // as of now the file is still empty > get 3 > > Now, the first thing to do is to look through the list of the buffers to see > if there is a block with ID 3. > Since there is no such block the next reasonable thing is to read the block > from the disk, but the disk is still empty. Ups, crash... > > The only way to avoid this is to write the new blocks to the disk > immediately, but that is against the spec. Here, again, is the wording of the addition to the "insert" command: > Your bufferpool should keep track of the highest-numbered block > written to so far. > If a new "insert" command writes beyond that, then the file should > grow in size accordingly. > Any intervening blocks should be filled with null values to insure that > future "get" requests will work properly. > For example, if the highest-numbered block so far written had been 10, > and an "insert" command is given for block 13, then blocks 11 and > 12 should be filled with nulls. I *do* intend for you to interpret this as immediately initializing the new blocks that extend the file. Yes, this is a terrible hack intended merely to keep the project simple. Note that this action should have no effect on the operation of your bufferpool. You simply insert a couple of lines of code to the effect of: while (new_insert_request > high_water_mark) writenullblock(high_water_mark++); -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Wed, 22 Mar 2000 14:03:29 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Patrick O'day Subject: Re: CHANGE TO SPEC (Was: invalid gets) MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Ago Sukanovic wrote: > OK. But you said that the only time that we write to the disk is when the > buffer is pushed out, or at the end of the program. At the beginning the > file is empty, right? > Consider this input (5 buffers, block size 15): > > insert 0 something > insert 5 something else > // as of now the file is still empty > get 3 > > Now, the first thing to do is to look through the list of the buffers to see > if there is a block with ID 3. > Since there is no such block the next reasonable thing is to read the block > from the disk, but the disk is still empty. Ups, crash... > > The only way to avoid this is to write the new blocks to the disk > immediately, but that is against the spec. > > Help. > > Ago Sukanovic Actually it's really easy to get around this without changing the spec. (I believe it was already stated earlier on the list serv) You keep a value of the size of the file (starts at 0 since you create the file every time the program starts) and is kept set to the highest blockID or blockID*blocksize. If a get request something higher then the size of the file you return an error, otherwise you get from the file regardless if it's a valid blockID or not. Though you probably should stop looking once you find a clean node, since you know that nothing else has been written except the dirty ones, things are only written to disk when the buffer is overfilled. ========================================================================= Date: Wed, 22 Mar 2000 15:19:19 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: "previously modified" MIME-version: 1.0 Content-type: text/plain; charset=us-ascii >When insert is called, you check to see if the requested block is already >stored in a buffer in the pool. If it is, move that buffer to the front >of the list and do the insert. If not, then replace the contents of the >least recently used buffer with the new string. Note that if the block >being replaced had its contents modified previously, *it must be written >to disk!* This all makes sense except: Note that if the block being replaced had its contents modified previously, *it must be written to disk!* What do you mean "modified previously"?? I assume this has something to do with when we write to disk. Where are all the rules written that explain when we write to disk?? As far as I can tell, you write to disk when a buffer gets pushed out, and at the end of the program. When else?? ========================================================================= Date: Wed, 22 Mar 2000 16:58:02 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: "previously modified" In-Reply-To: <3.0.6.32.20000322151919.009167a0@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII > What do you mean "modified previously"?? I assume this has something to do > with when we write to disk. > Where are all the rules written that explain when we write to disk?? As far > as I can tell, you write to disk when a buffer gets pushed out, and at the > end of the program. > When else?? That's it. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Wed, 22 Mar 2000 15:42:28 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: Re: "previously modified" In-Reply-To: <3.0.6.32.20000322151919.009167a0@mail.vt.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" >as I can tell, you write to disk when a buffer gets pushed out, and at the >end of the program. >When else?? > Never, unless you use Dr. Shaffer's method of expanding the file with NULLs even when no block is being written to disk. "Note that if the block being replaced had its contents modified previously, it must be written to disk!" This is slightly ambigous... by "replaced" he doesn't mean the block that is being overwritten, he means the block being pushed out, at least I am 99% sure he means that. :) Meaning: If the block being pushed off of the buffers is dirty, it needs to be written to disk. ========================================================================= Date: Wed, 22 Mar 2000 17:35:44 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: "previously modified" In-Reply-To: <3.0.6.32.20000322154228.00822430@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 22 Mar 2000, Jason Giglio wrote: > >as I can tell, you write to disk when a buffer gets pushed out, and at the > >end of the program. > >When else?? > > > > Never, unless you use Dr. Shaffer's method of expanding the file with NULLs > even when no block is being written to disk. Ah, Ok. You are right - this mechanism for writing to disk is separate from "when a buffer gets pushed out, and at the end of the program." > "Note that if the block being replaced had its contents modified > previously, it must be written to disk!" > > This is slightly ambigous... by "replaced" he doesn't mean the block that > is being overwritten, he means the block being pushed out, at least I am > 99% sure he means that. :) Correct. > Meaning: > If the block being pushed off of the buffers is dirty, it needs to be > written to disk. Correct. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Mon, 22 Mar 0100 10:23:29 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brian Wagner Subject: Re: file size In-Reply-To: <004d01bf93a1$236e1d60$4f21fea9@default> from "John" at Mar 21, 0 05:51:27 pm Content-Type: text > In the notes on the website, it talks about including a header file > > #include > > in order to get the size of the file. Is there a header without the .h > extention? Also is this the only way to get the size? > Thanks, John Umm, why do we need to know the size of the file? (Perhaps, the spec doesn't require us to, but your individual implementation uses the file size?) -- // Brian Wagner, CpE WWW: http://www.bigfoot.com/~datatroi "[Source code] documentation is like sex... When it's good, it's great. And when it's bad, it's better than nothing..." ------------------------------------------------------------------------- ========================================================================= Date: Mon, 22 Mar 0100 10:34:26 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brian Wagner Subject: Re: file size In-Reply-To: <38D905CC.D581EBD0@vt.edu> from "Brandon Horsley" at Mar 22, 0 12:41:32 pm Content-Type: text > > But, don't do this. Use C++ streams. > sure, but why not? I mean, other than because you asked me to, are there > drawbacks to doing it with regular c opposed to c++? (1) C++ streams are much more readable and easy to maintain! (Maintenance is of prime importance, of course) (2) Also, I find the printf() to be silly. (All the %d and %f and %i, etc, etc) In C++ the following is trivial: int integer_number; float float_number; double double_number; cout << integer_number << float_number << double_number << endl; In C, you have to remember "All the %d and %f and %i, etc, etc" stuff. (3) C++ iostreams library has inheritance. So you can do this: extern istream *fin; // input stream; initially "cin" obj extern ostream *fout; // output stream; initially "cout" obj int main() { *fout << "Output to wherever; if _fout_ points to a file, output there" << "... or if _fout_ points to _cout_, output there!!" << endl; *fout << "Woo hoo, my code can dynamically change from outputing" << "to _cout_, to outputing to a file!" } ... Besides, it's fun to come up w/ different pronunciations of "cin". :-) ("sin", "C - in", "kin", yadda, yadda) I think iostreams is the *CLEAR* winner. -- // Brian Wagner, CpE WWW: http://www.bigfoot.com/~datatroi "[Source code] documentation is like sex... When it's good, it's great. And when it's bad, it's better than nothing..." ------------------------------------------------------------------------- ========================================================================= Date: Wed, 22 Mar 2000 22:50:28 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: Re: file size In-Reply-To: <200003221523.KAA01552@brwagne2.campus.vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii I think it has to do with him making the changes to the spec. He basically took the option away (in the spec revision) of keeping a list of stored blocks. You now have to "pad" the binary file with NULLS for blocks that do not contain data. To do this, you may need to know the file size. You will need to know how many blocks to pad before you can write a dirty buffer to the binary file- to its correct block location. kinda like, if you want to write block 4 to the file and the file looks like: block 0 block 1 you gotta pad NULLS, so it looks like: block 0 block 1 NULL NULL block 4 Im pretty sure thats how it works. If it aint, holler at me before I code too much. At 10:23 AM 03/22/2000 -0500, you wrote: >> In the notes on the website, it talks about including a header file >> >> #include >> >> in order to get the size of the file. Is there a header without the .h >> extention? Also is this the only way to get the size? >> Thanks, John >Umm, why do we need to know the size of the file? > >(Perhaps, the spec doesn't require us to, but your individual implementation >uses the file size?) > >-- >// Brian Wagner, CpE WWW: http://www.bigfoot.com/~datatroi >"[Source code] documentation is like sex... When it's good, it's great. >And when it's bad, it's better than nothing..." >------------------------------------------------------------------------- > ========================================================================= Date: Wed, 22 Mar 2000 23:24:19 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: David Cook Subject: Weird behavior when piping input MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Ok, i've set my command line parameters to 5 15 Sender: CS2604 discussion list From: Ben Keller Subject: NOTE on get and put pointers in fstream MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This issue may cause problems for p3 so you should be aware of it: The get and put pointers in an fstream are in theory independent. However, when you use them (at least with Visual C++) they do not act that way: When you do a seekg the put pointer becomes invalid, and when you do a seekp the get pointer becomes invalid. You can avoid this problem by always doing a seek before the read or write, but you need to be aware of the problem if you are trying to avoid doing a seek when the file block doesn't change from one read to the next (or one write to the next). I cannot find anything about this in Stroustrup, 3rd Ed., but I'm guessing that it is another one of the stream details that is left to the compiler implementor (due to OS differences). If someone wants to play language lawyer, I'll be happy to defer to them. BK -- Ben Keller email: keller@cs.vt.edu Visiting Assistant Professor phone: 540-231-9367 Computer Science Dept (0106) web: www.cs.vt.edu/~keller Virginia Tech Blacksburg, VA 24061 USA ========================================================================= Date: Wed, 23 Feb 2000 12:14:09 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Curtis Berry Subject: Re: CHANGE TO SPEC (Was: invalid gets) In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit Hahaha, terrible hack indeed. This defeats the purpose of having a buffer pool in the first place. That purpose, as i understand it, is to limit disk access. Now it seems that we are required to write to the disk each and every time we receive an insert command. Wouldn't a better "hack" be to keep a list of the valid ID's. This maintains the buffer pool idea AND would allow one to return real error messages for invalid gets to the interior of the file. Bah... what do i know... i just codes what they tells me. curtis -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Cliff Shaffer Sent: Wednesday, March 22, 2000 2:49 PM To: CS2604@LISTSERV.VT.EDU Subject: Re: CHANGE TO SPEC (Was: invalid gets) On Wed, 22 Mar 2000, Ago Sukanovic wrote: > > > Two things... first of all, say the command get 8 is used in the sample > > > input file. Is this considered an error, since there was never a record > 8, > > > or should a blank string be returned since that space should be filled > with > > > NULLs now? > > > > That depends on when the request takes place. The sample input file has > > insert commands all the way up to 18. If the "get" to 8 took place AFTER > > an insert to some block with a higher ID then 8, then the result is a null > > string. If the "get" took place prior to an "insert" to block 8 or > > higher, then it is an error. > > > > OK. But you said that the only time that we write to the disk is when the > buffer is pushed out, or at the end of the program. At the beginning the > file is empty, right? > Consider this input (5 buffers, block size 15): > > insert 0 something > insert 5 something else > // as of now the file is still empty > get 3 > > Now, the first thing to do is to look through the list of the buffers to see > if there is a block with ID 3. > Since there is no such block the next reasonable thing is to read the block > from the disk, but the disk is still empty. Ups, crash... > > The only way to avoid this is to write the new blocks to the disk > immediately, but that is against the spec. Here, again, is the wording of the addition to the "insert" command: > Your bufferpool should keep track of the highest-numbered block > written to so far. > If a new "insert" command writes beyond that, then the file should > grow in size accordingly. > Any intervening blocks should be filled with null values to insure that > future "get" requests will work properly. > For example, if the highest-numbered block so far written had been 10, > and an "insert" command is given for block 13, then blocks 11 and > 12 should be filled with nulls. I *do* intend for you to interpret this as immediately initializing the new blocks that extend the file. Yes, this is a terrible hack intended merely to keep the project simple. Note that this action should have no effect on the operation of your bufferpool. You simply insert a couple of lines of code to the effect of: while (new_insert_request > high_water_mark) writenullblock(high_water_mark++); -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Thu, 23 Mar 2000 13:35:18 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: CHANGE TO SPEC (Was: invalid gets) In-Reply-To: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 23 Feb 2000, Curtis Berry wrote: > Hahaha, terrible hack indeed. This defeats the purpose of having a buffer > pool in the first place. That purpose, as i understand it, is to limit disk > access. Now it seems that we are required to write to the disk each and > every time we receive an insert command. It is only one additional disk access per block in the file (at most), it has nothing to do with the number of insert commands. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Thu, 23 Mar 2000 16:24:30 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: r duffy Subject: file problems MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 8BIT im having trouble getting the data in and out of the file this is a small program: int main(int argc, char* argv[]) { char* strings[5]; char* file_data[5]; fstream myFile ("data.bin", ios::in | ios::out | ios::binary); strings[0] = new char[20]; strings[1] = new char[20]; strings[2] = new char[20]; strings[3] = new char[20]; strings[4] = new char[20]; file_data[0] = new char[20]; file_data[1] = new char[20]; file_data[2] = new char[20]; file_data[3] = new char[20]; file_data[4] = new char[20]; strings[0] = "first"; strings[1] = "second"; strings[2] = "third"; strings[3] = "fourth"; strings[4] = "fifth"; for (int loop = 0;loop < 5;loop++){ myFile.seekp (loop * 20); myFile.write (strings[loop], 20); } for (loop = 0;loop < 5;loop++){ myFile.seekg (loop * 20); myFile.write (file_data[loop], 20); cout << file_data[loop] << endl; } return 0; } this is the output: ЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭ§§§§A ЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭ§§§§A ЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭ§§§§A ЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭ§§§§A ЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭ§§§§A Press any key to continue ========================================================================= Date: Thu, 23 Mar 2000 16:26:48 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: r duffy Subject: Re: File Problems -- ignore last email MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit i changed the write in the last loop to read and it works sorry- duffy ========================================================================= Date: Thu, 23 Mar 2000 16:23:07 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Richard Bowman Subject: insert command MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit This might have been mentioned already in the listserv, but I couldn't find anything. When a item is inserted, is it just inserted into the pool, or is written to both the pool and the file, or just the file? Thanks Richard ========================================================================= Date: Thu, 23 Mar 2000 18:57:44 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: binary file MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Is there something special you have to do if you open a binary as binFile.open("p3bin.dat", ios::in|ios::out|ios::binary); and you want to read and write to it. What I mean is, is there something you have to do "switch" between "input mode" and "output mode"?? The problem I am having is this: If I leave it like it is above, and I write to the stream, the file *will not even be created*, and therefore contains nothing at programs end. However, if I change it to: binFile.open("p3bin.dat", ios::out|ios::binary); Then the binary file is created, and has the proper "junk" written to it at programs end. That IS the only change I made, and Im unsure as to why it doesnt work the first way. Any ideas? David ========================================================================= Date: Thu, 23 Mar 2000 19:15:58 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: Re: binary file In-Reply-To: <3.0.6.32.20000323185744.00913100@mail.vt.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" <<< No Message Collected >>> ========================================================================= Date: Thu, 23 Mar 2000 21:44:58 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: David Cook Subject: Re: binary file MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit I am having that exact same problem, I declare my file as type fstream and if I open it w/ both the ios::in and ios::out options it is just never created. If it's just ios::out the file is created like it should be. This does however mean that I would have to close and re-open it with just the ios::in parameter if I wanted to read from the file right? That sounds like a pain....there must be a better way. Thanks -Dave ----- Original Message ----- From: "david" To: Sent: Thursday, March 23, 2000 6:57 PM Subject: binary file > Is there something special you have to do if you open a binary as > > binFile.open("p3bin.dat", ios::in|ios::out|ios::binary); > > and you want to read and write to it. > What I mean is, is there something you have to do "switch" between "input > mode" and "output mode"?? > > The problem I am having is this: > If I leave it like it is above, and I write to the stream, the file *will > not even be created*, and therefore contains nothing at programs end. > However, if I change it to: > > binFile.open("p3bin.dat", ios::out|ios::binary); > > Then the binary file is created, and has the proper "junk" written to it at > programs end. > That IS the only change I made, and Im unsure as to why it doesnt work the > first way. > > Any ideas? > David ========================================================================= Date: Thu, 23 Mar 2000 22:03:48 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: Re: binary file In-Reply-To: <01ac01bf953a$f2d04340$20d8c026@redrum> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Thats what I ended up doing. (opening it and closing it as needed) Its not bad, because you only open it to read or write in a couple of places. At 09:44 PM 03/23/2000 -0500, you wrote: >I am having that exact same problem, I declare my file as type fstream and >if I open it w/ both the ios::in and ios::out options it is just never >created. If it's just ios::out the file is created like it should be. This >does however mean that I would have to close and re-open it with just the >ios::in parameter if I wanted to read from the file right? That sounds like >a pain....there must be a better way. > >Thanks >-Dave >----- Original Message ----- >From: "david" >To: >Sent: Thursday, March 23, 2000 6:57 PM >Subject: binary file > > >> Is there something special you have to do if you open a binary as >> >> binFile.open("p3bin.dat", ios::in|ios::out|ios::binary); >> >> and you want to read and write to it. >> What I mean is, is there something you have to do "switch" between "input >> mode" and "output mode"?? >> >> The problem I am having is this: >> If I leave it like it is above, and I write to the stream, the file *will >> not even be created*, and therefore contains nothing at programs end. >> However, if I change it to: >> >> binFile.open("p3bin.dat", ios::out|ios::binary); >> >> Then the binary file is created, and has the proper "junk" written to it >at >> programs end. >> That IS the only change I made, and Im unsure as to why it doesnt work the >> first way. >> >> Any ideas? >> David > ========================================================================= Date: Thu, 23 Mar 2000 22:20:40 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: David Cook Subject: Insert taking void* MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_ebzn29O997tsS2dnby0bnQ)" This is a multi-part message in MIME format. --Boundary_(ID_ebzn29O997tsS2dnby0bnQ) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable Ok, ostream.write takes a char* and an int as it parameters, so why = wouldn't the insert just take the (in this case text) data as a char* = instead of a void*? If we take it as a void star we just have to cast = it to back to char* (at least my compiler makes me cast it) to use in = the write statement. Also, when I call my insert, which takes type = void*, I have to explicitly cast from const char* to void*. I thought = void* would take any type but it still makes me cast it. If someone = could shed some light on this it'd appreciate it. Thanks -Dave C --Boundary_(ID_ebzn29O997tsS2dnby0bnQ) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
Ok, ostream.write takes a char* and an = int as it=20 parameters, so why wouldn't the insert just take the (in this case text) = data as=20 a char* instead of a void*?  If we take it as a void star we just = have to=20 cast it to back to char* (at least my compiler makes me cast it) to use = in the=20 write statement.  Also, when I call my insert, which takes type = void*, I=20 have to explicitly cast from const char* to void*.  I thought void* = would=20 take any type but it still makes me cast it.  If someone could shed = some=20 light on this it'd appreciate it.
 
Thanks
-Dave C
--Boundary_(ID_ebzn29O997tsS2dnby0bnQ)-- ========================================================================= Date: Thu, 23 Mar 2000 23:04:14 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jonathan Pryor Subject: Re: binary file In-Reply-To: <3.0.6.32.20000323185744.00913100@mail.vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit The reason is that you can't open non-existent files for reading. For example: ifstream in ("this-does-not-exist"); if (!in.good()) cout << "can't open input file" << endl; This will never open the input file, since it doesn't exist. This also happens to be the only way (using C++ iostreams) to tell if a file exists. (At least, it's the only way I know of that's within the confines of the language, and not some other standard such as POSIX. ANSI C FILE handles would also work.) Extrapolating this behavior suggests that if you try to open any non-existent file for reading, you'll get an error. At least, this is the case for MSVC. GCC, on the other hand, perfectly allows you to open a previously non-existent file for both reading and writing. Personally, I prefer this approach, as it allows you to open a file once, write to it, reposition the read pointer, and read what you wrote. If you're using MSVC, you'll either have to: 1) Do what David Cook suggested, and just reopen the file each time you access it. 2) Open the file for writing, write some (garbage) value, close it (so it'll exist), and re-open for reading and writing. I actually haven't tried (2) yet, but I think it should work. :-) It still seems ugly, though. I much prefer the GCC behavior. - Jon > -----Original Message----- > From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of > david > Sent: Thursday, March 23, 2000 6:58 PM > To: CS2604@LISTSERV.VT.EDU > Subject: binary file > > > Is there something special you have to do if you open a binary as > > binFile.open("p3bin.dat", ios::in|ios::out|ios::binary); > > and you want to read and write to it. > What I mean is, is there something you have to do "switch" between "input > mode" and "output mode"?? > > The problem I am having is this: > If I leave it like it is above, and I write to the stream, the file *will > not even be created*, and therefore contains nothing at programs end. > However, if I change it to: > > binFile.open("p3bin.dat", ios::out|ios::binary); > > Then the binary file is created, and has the proper "junk" > written to it at > programs end. > That IS the only change I made, and Im unsure as to why it doesnt work the > first way. > > Any ideas? > David ========================================================================= Date: Thu, 23 Mar 2000 22:57:20 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jonathan Pryor Subject: Re: Insert taking void* In-Reply-To: <01b501bf953f$ef26a9f0$20d8c026@redrum> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit I can't say why write() takes a ``char*'' instead of a ``void*''. I'd have preferred void*, but they didn't ask me... :-) As for casting from ``const char*'' to ``void*'', the compiler complains because you're discarding the ``const''. Either: (1) Assign it to a ``const void*'' pointer: const char* a = "foo"; const void* cpv = a; // fine (2) Use a C-style cast: const char* a = "foo"; void* pv = (void*) a; (3) Use const_cast to remove the const, and static_cast the result: const char* a = "foo"; void* pv = static_cast(const_cast(a)); hth - Jon -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of David Cook Sent: Thursday, March 23, 2000 10:21 PM To: CS2604@LISTSERV.VT.EDU Subject: Insert taking void* Ok, ostream.write takes a char* and an int as it parameters, so why wouldn't the insert just take the (in this case text) data as a char* instead of a void*? If we take it as a void star we just have to cast it to back to char* (at least my compiler makes me cast it) to use in the write statement. Also, when I call my insert, which takes type void*, I have to explicitly cast from const char* to void*. I thought void* would take any type but it still makes me cast it. If someone could shed some light on this it'd appreciate it. Thanks -Dave C ========================================================================= Date: Thu, 23 Mar 2000 23:49:28 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jonathan Pryor Subject: Re: binary file In-Reply-To: <3.0.6.32.20000323185744.00913100@mail.vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit OK, so I'm answering again. There's a third choice, that's actually more portable. Too bad I had to read the standard to figure it out... Low and behold, if you actually look at the C++ language standard (Section 27.8.1.3, table 92), there's a table that specifies the ios flags, and their mapping to C FILE I/O. It states that the FILE mode of "w+b" (for those familiar with fopen()), is equivalent to: ios::in | ios::out | ios::trunc | ios::binary I've tested it in programs, and it correctly opens files that don't exist. You were just missing the ``ios::trunc'' flag in your open() function. Additionally (at least for my tests), I've noticed two other things: 1) Reading from data that's in "the middle" of a file returns zero'd out data, on both MSVC and GCC. In other words, the following code reads 10 zeros into ``buf'': const char ach[] = "hello, world!"; cxxin.seekp (100, ios::beg); cxxin.write (ach, sizeof(ach)); // notice we're seeking prior to where we wrote. cxxin.seekg (50, ios::beg); char buf[10]; if (cxxin.read (buf, sizeof(buf))) {/* this should always work */} else {/* this shouldn't be run */} 2) Trying to read from data beyond the end of the file fails, as expected. It returns ``false'' (...eventually...) in read(): const char ach[] = "hello, world!"; cxxin.seekp (100, ios::beg); cxxin.write (ach, sizeof(ach)); // notice it's past the last point we wrote to. cxxin.seekg (150, ios::beg); char buf[10]; if (cxxin.read (buf, sizeof(buf))) {/* this shouldn't be run */} else {/* this should always be executed */} The only difference between the above code samples is the value given in ``seekg()'', and the branch of the ``if'' statement that's executed. Additionally, it appears that the "hack" previously added to the spec isn't strictly necessary, as long as you're careful with your reads and writes--even on MSVC. Comments? - Jon > -----Original Message----- > From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of > david > Sent: Thursday, March 23, 2000 6:58 PM > To: CS2604@LISTSERV.VT.EDU > Subject: binary file > > > Is there something special you have to do if you open a binary as > > binFile.open("p3bin.dat", ios::in|ios::out|ios::binary); > > and you want to read and write to it. > What I mean is, is there something you have to do "switch" between "input > mode" and "output mode"?? > > The problem I am having is this: > If I leave it like it is above, and I write to the stream, the file *will > not even be created*, and therefore contains nothing at programs end. > However, if I change it to: > > binFile.open("p3bin.dat", ios::out|ios::binary); > > Then the binary file is created, and has the proper "junk" > written to it at > programs end. > That IS the only change I made, and Im unsure as to why it doesnt work the > first way. > > Any ideas? > David ========================================================================= Date: Thu, 23 Mar 2000 23:06:28 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Ryan Turner Subject: Re: Insert taking void* In-Reply-To: <01b501bf953f$ef26a9f0$20d8c026@redrum> MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_SHRo2kq29Pqkx8qQ3u/59g)" This is a multi-part message in MIME format. --Boundary_(ID_SHRo2kq29Pqkx8qQ3u/59g) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Project 4 will not be character data. Might as well use void*. Ryan -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of David Cook Sent: Thursday, March 23, 2000 10:21 PM To: CS2604@LISTSERV.VT.EDU Subject: Insert taking void* Ok, ostream.write takes a char* and an int as it parameters, so why wouldn't the insert just take the (in this case text) data as a char* instead of a void*? If we take it as a void star we just have to cast it to back to char* (at least my compiler makes me cast it) to use in the write statement. Also, when I call my insert, which takes type void*, I have to explicitly cast from const char* to void*. I thought void* would take any type but it still makes me cast it. If someone could shed some light on this it'd appreciate it. Thanks -Dave C --Boundary_(ID_SHRo2kq29Pqkx8qQ3u/59g) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
Project 4 will not be character data.  = Might as=20 well use void*.
 
Ryan
-----Original Message-----
From: CS2604 discussion = list=20 [mailto:CS2604@listserv.vt.edu]On Behalf Of David = Cook
Sent:=20 Thursday, March 23, 2000 10:21 PM
To:=20 CS2604@LISTSERV.VT.EDU
Subject: Insert taking=20 void*

Ok, ostream.write takes a char* and = an int as it=20 parameters, so why wouldn't the insert just take the (in this case = text) data=20 as a char* instead of a void*?  If we take it as a void star we = just have=20 to cast it to back to char* (at least my compiler makes me cast it) to = use in=20 the write statement.  Also, when I call my insert, which takes = type=20 void*, I have to explicitly cast from const char* to void*.  I = thought=20 void* would take any type but it still makes me cast it.  If = someone=20 could shed some light on this it'd appreciate it.
 
Thanks
-Dave = C
--Boundary_(ID_SHRo2kq29Pqkx8qQ3u/59g)-- ========================================================================= Date: Thu, 23 Mar 2000 23:39:35 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: "get" on a NULL block MIME-version: 1.0 Content-type: text/plain; charset=us-ascii I have a question that expands on this previous question. This is about a "get" call that is to a NULL block in the binary file. > Two things... first of all, say the command get 8 is used in the sample > input file. Is this considered an error, since there was never a record 8, > or should a blank string be returned since that space should be filled with > NULLs now? The answer was this: If the "get" to 8 took place AFTER an insert to some block with a higher ID then 8, then the result is a null string. Should we print something like this: (or does it not matter to you) get 8 Block 8 contains "NULL STRING" or this: get 8 Block 8 contains "" ** ALSO ** After doing the printing, does the block with the NULL STRING get inserted into the first position of the buffer pool, like it would on a normal, non-NULL buffer access?? Or, since it was a NULL block, do you just leave it in the file and leave the existing buffer pool as it was?? ========================================================================= Date: Thu, 23 Mar 2000 23:58:38 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: Re: binary file In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=us-ascii #2 works. At 11:04 PM 03/23/2000 -0500, you wrote: >The reason is that you can't open non-existent files >for reading. > >For example: > > ifstream in ("this-does-not-exist"); > if (!in.good()) > cout << "can't open input file" << endl; > >This will never open the input file, since it doesn't >exist. > >This also happens to be the only way (using C++ iostreams) >to tell if a file exists. (At least, it's the only way >I know of that's within the confines of the language, and >not some other standard such as POSIX. ANSI C FILE >handles would also work.) > > >Extrapolating this behavior suggests that if you try to >open any non-existent file for reading, you'll get an >error. > >At least, this is the case for MSVC. GCC, on the other >hand, perfectly allows you to open a previously non-existent >file for both reading and writing. Personally, I prefer >this approach, as it allows you to open a file once, write >to it, reposition the read pointer, and read what you wrote. > >If you're using MSVC, you'll either have to: > 1) Do what David Cook suggested, and just reopen the file > each time you access it. > > 2) Open the file for writing, write some (garbage) value, > close it (so it'll exist), and re-open for reading and > writing. > >I actually haven't tried (2) yet, but I think it should work. :-) >It still seems ugly, though. I much prefer the GCC behavior. > > - Jon > >> -----Original Message----- >> From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of >> david >> Sent: Thursday, March 23, 2000 6:58 PM >> To: CS2604@LISTSERV.VT.EDU >> Subject: binary file >> >> >> Is there something special you have to do if you open a binary as >> >> binFile.open("p3bin.dat", ios::in|ios::out|ios::binary); >> >> and you want to read and write to it. >> What I mean is, is there something you have to do "switch" between "input >> mode" and "output mode"?? >> >> The problem I am having is this: >> If I leave it like it is above, and I write to the stream, the file *will >> not even be created*, and therefore contains nothing at programs end. >> However, if I change it to: >> >> binFile.open("p3bin.dat", ios::out|ios::binary); >> >> Then the binary file is created, and has the proper "junk" >> written to it at >> programs end. >> That IS the only change I made, and Im unsure as to why it doesnt work the >> first way. >> >> Any ideas? >> David > ========================================================================= Date: Fri, 24 Mar 2000 00:43:24 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: Re: binary file In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" I think this is wrong. There is an ios::nocreate flag that I have found you must include when opening an input file, even when using an ifstream, to make sure it doesn't create one. Otherwise it just makes a zero byte file and lets you try to read from it, at least under MSVC 5.0. I havn't tested this behavior under 6.0 yet, but I will be soon, since I just installed it. Anyone else have a similar experience as mine? At 11:04 PM 3/23/00 -0500, you wrote: >The reason is that you can't open non-existent files >for reading. > >For example: > > ifstream in ("this-does-not-exist"); > if (!in.good()) > cout << "can't open input file" << endl; > >This will never open the input file, since it doesn't >exist. > >This also happens to be the only way (using C++ iostreams) >to tell if a file exists. (At least, it's the only way >I know of that's within the confines of the language, and >not some other standard such as POSIX. ANSI C FILE >handles would also work.) > > >Extrapolating this behavior suggests that if you try to >open any non-existent file for reading, you'll get an >error. > >At least, this is the case for MSVC. GCC, on the other >hand, perfectly allows you to open a previously non-existent >file for both reading and writing. Personally, I prefer >this approach, as it allows you to open a file once, write >to it, reposition the read pointer, and read what you wrote. > >If you're using MSVC, you'll either have to: > 1) Do what David Cook suggested, and just reopen the file > each time you access it. > > 2) Open the file for writing, write some (garbage) value, > close it (so it'll exist), and re-open for reading and > writing. > >I actually haven't tried (2) yet, but I think it should work. :-) >It still seems ugly, though. I much prefer the GCC behavior. > > - Jon > >> -----Original Message----- >> From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of >> david >> Sent: Thursday, March 23, 2000 6:58 PM >> To: CS2604@LISTSERV.VT.EDU >> Subject: binary file >> >> >> Is there something special you have to do if you open a binary as >> >> binFile.open("p3bin.dat", ios::in|ios::out|ios::binary); >> >> and you want to read and write to it. >> What I mean is, is there something you have to do "switch" between "input >> mode" and "output mode"?? >> >> The problem I am having is this: >> If I leave it like it is above, and I write to the stream, the file *will >> not even be created*, and therefore contains nothing at programs end. >> However, if I change it to: >> >> binFile.open("p3bin.dat", ios::out|ios::binary); >> >> Then the binary file is created, and has the proper "junk" >> written to it at >> programs end. >> That IS the only change I made, and Im unsure as to why it doesnt work the >> first way. >> >> Any ideas? >> David > ========================================================================= Date: Fri, 24 Mar 2000 01:10:54 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: David Wrighton Subject: Re: binary file MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit I believe ios::nocreate is not a part of the c++ standard. In fact it is only available in vc 6 is you use the header instead of the header. The flag that is needed for this project is ios::trunc in addition to the ios::in and ios::out. David Wrighton ----- Original Message ----- From: "Jason Giglio" To: Sent: Friday, March 24, 2000 12:43 AM Subject: Re: binary file > I think this is wrong. There is an ios::nocreate flag that I have found > you must include when opening an input file, even when using an ifstream, > to make sure it doesn't create one. Otherwise it just makes a zero byte > file and lets you try to read from it, at least under MSVC 5.0. I havn't > tested this behavior under 6.0 yet, but I will be soon, since I just > installed it. Anyone else have a similar experience as mine? > > At 11:04 PM 3/23/00 -0500, you wrote: > >The reason is that you can't open non-existent files > >for reading. > > > >For example: > > > > ifstream in ("this-does-not-exist"); > > if (!in.good()) > > cout << "can't open input file" << endl; > > > >This will never open the input file, since it doesn't > >exist. > > > >This also happens to be the only way (using C++ iostreams) > >to tell if a file exists. (At least, it's the only way > >I know of that's within the confines of the language, and > >not some other standard such as POSIX. ANSI C FILE > >handles would also work.) > > > > > >Extrapolating this behavior suggests that if you try to > >open any non-existent file for reading, you'll get an > >error. > > > >At least, this is the case for MSVC. GCC, on the other > >hand, perfectly allows you to open a previously non-existent > >file for both reading and writing. Personally, I prefer > >this approach, as it allows you to open a file once, write > >to it, reposition the read pointer, and read what you wrote. > > > >If you're using MSVC, you'll either have to: > > 1) Do what David Cook suggested, and just reopen the file > > each time you access it. > > > > 2) Open the file for writing, write some (garbage) value, > > close it (so it'll exist), and re-open for reading and > > writing. > > > >I actually haven't tried (2) yet, but I think it should work. :-) > >It still seems ugly, though. I much prefer the GCC behavior. > > > > - Jon > > > >> -----Original Message----- > >> From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of > >> david > >> Sent: Thursday, March 23, 2000 6:58 PM > >> To: CS2604@LISTSERV.VT.EDU > >> Subject: binary file > >> > >> > >> Is there something special you have to do if you open a binary as > >> > >> binFile.open("p3bin.dat", ios::in|ios::out|ios::binary); > >> > >> and you want to read and write to it. > >> What I mean is, is there something you have to do "switch" between "input > >> mode" and "output mode"?? > >> > >> The problem I am having is this: > >> If I leave it like it is above, and I write to the stream, the file *will > >> not even be created*, and therefore contains nothing at programs end. > >> However, if I change it to: > >> > >> binFile.open("p3bin.dat", ios::out|ios::binary); > >> > >> Then the binary file is created, and has the proper "junk" > >> written to it at > >> programs end. > >> That IS the only change I made, and Im unsure as to why it doesnt work the > >> first way. > >> > >> Any ideas? > >> David > > ========================================================================= Date: Fri, 24 Mar 2000 01:18:06 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Curtis Berry Subject: Re: binary file In-Reply-To: <3.0.6.32.20000324004324.0082b240@mail.vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Actually i believe that the standard for input files is to default to nocreate, but if you use the trunc flag everything works like a dream. It even kills data in the file if it already existed i think. curtis -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Jason Giglio Sent: Friday, March 24, 2000 12:43 AM To: CS2604@LISTSERV.VT.EDU Subject: Re: binary file I think this is wrong. There is an ios::nocreate flag that I have found you must include when opening an input file, even when using an ifstream, to make sure it doesn't create one. Otherwise it just makes a zero byte file and lets you try to read from it, at least under MSVC 5.0. I havn't tested this behavior under 6.0 yet, but I will be soon, since I just installed it. Anyone else have a similar experience as mine? At 11:04 PM 3/23/00 -0500, you wrote: >The reason is that you can't open non-existent files >for reading. > >For example: > > ifstream in ("this-does-not-exist"); > if (!in.good()) > cout << "can't open input file" << endl; > >This will never open the input file, since it doesn't >exist. > >This also happens to be the only way (using C++ iostreams) >to tell if a file exists. (At least, it's the only way >I know of that's within the confines of the language, and >not some other standard such as POSIX. ANSI C FILE >handles would also work.) > > >Extrapolating this behavior suggests that if you try to >open any non-existent file for reading, you'll get an >error. > >At least, this is the case for MSVC. GCC, on the other >hand, perfectly allows you to open a previously non-existent >file for both reading and writing. Personally, I prefer >this approach, as it allows you to open a file once, write >to it, reposition the read pointer, and read what you wrote. > >If you're using MSVC, you'll either have to: > 1) Do what David Cook suggested, and just reopen the file > each time you access it. > > 2) Open the file for writing, write some (garbage) value, > close it (so it'll exist), and re-open for reading and > writing. > >I actually haven't tried (2) yet, but I think it should work. :-) >It still seems ugly, though. I much prefer the GCC behavior. > > - Jon > >> -----Original Message----- >> From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of >> david >> Sent: Thursday, March 23, 2000 6:58 PM >> To: CS2604@LISTSERV.VT.EDU >> Subject: binary file >> >> >> Is there something special you have to do if you open a binary as >> >> binFile.open("p3bin.dat", ios::in|ios::out|ios::binary); >> >> and you want to read and write to it. >> What I mean is, is there something you have to do "switch" between "input >> mode" and "output mode"?? >> >> The problem I am having is this: >> If I leave it like it is above, and I write to the stream, the file *will >> not even be created*, and therefore contains nothing at programs end. >> However, if I change it to: >> >> binFile.open("p3bin.dat", ios::out|ios::binary); >> >> Then the binary file is created, and has the proper "junk" >> written to it at >> programs end. >> That IS the only change I made, and Im unsure as to why it doesnt work the >> first way. >> >> Any ideas? >> David > ========================================================================= Date: Fri, 24 Mar 2000 01:31:13 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: David Cook Subject: Re: Insert taking void* MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_HHz/W1K+MGuyl1GlpWGGNQ)" This is a multi-part message in MIME format. --Boundary_(ID_HHz/W1K+MGuyl1GlpWGGNQ) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable I understand that project 4 won't take char data but the ostream.write = function takes a first parameter of char* so unless we use a different = method to write to disk in project 4 we'll still be casting our void* = data to char* to use the write function. Am I wrong in thinking this? -Dave ----- Original Message -----=20 From: Ryan Turner=20 To: CS2604@LISTSERV.VT.EDU=20 Sent: Thursday, March 23, 2000 11:06 PM Subject: Re: Insert taking void* Project 4 will not be character data. Might as well use void*. =20 Ryan -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On = Behalf Of David Cook Sent: Thursday, March 23, 2000 10:21 PM To: CS2604@LISTSERV.VT.EDU Subject: Insert taking void* Ok, ostream.write takes a char* and an int as it parameters, so why = wouldn't the insert just take the (in this case text) data as a char* = instead of a void*? If we take it as a void star we just have to cast = it to back to char* (at least my compiler makes me cast it) to use in = the write statement. Also, when I call my insert, which takes type = void*, I have to explicitly cast from const char* to void*. I thought = void* would take any type but it still makes me cast it. If someone = could shed some light on this it'd appreciate it. Thanks -Dave C --Boundary_(ID_HHz/W1K+MGuyl1GlpWGGNQ) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
I understand that project 4 won't take = char data=20 but the ostream.write function takes a first parameter of char* so = unless we use=20 a different method to write to disk in project 4 we'll still be casting = our=20 void* data to char* to use the write function.
 
Am I wrong in thinking = this?
-Dave
----- Original Message -----
From:=20 Ryan = Turner
To: CS2604@LISTSERV.VT.EDU
Sent: Thursday, March 23, 2000 = 11:06=20 PM
Subject: Re: Insert taking = void*

Project 4 will not be character data.  = Might as=20 well use void*.
 
Ryan
-----Original Message-----
From: CS2604 = discussion list [mailto:CS2604@listserv.vt.edu]= On=20 Behalf Of David Cook
Sent: Thursday, March 23, 2000 = 10:21=20 PM
To: CS2604@LISTSERV.VT.EDU
S= ubject:=20 Insert taking void*

Ok, ostream.write takes a char* and = an int as=20 it parameters, so why wouldn't the insert just take the (in this = case text)=20 data as a char* instead of a void*?  If we take it as a void = star we=20 just have to cast it to back to char* (at least my compiler makes me = cast=20 it) to use in the write statement.  Also, when I call my = insert, which=20 takes type void*, I have to explicitly cast from const char* to = void*. =20 I thought void* would take any type but it still makes me cast = it.  If=20 someone could shed some light on this it'd appreciate = it.
 
Thanks
-Dave=20 C
--Boundary_(ID_HHz/W1K+MGuyl1GlpWGGNQ)-- ========================================================================= Date: Fri, 24 Mar 2000 02:38:26 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: David Cook Subject: Re: binary file MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Truncate does in fact kill the old file. As Jonathan previously said if you want to open a file as both input and output you need ios::in | ios::out | ios::trunc | ios::binary if you include all those options it should work just fine :) Later -Dave ----- Original Message ----- From: "Curtis Berry" To: Sent: Friday, March 24, 2000 1:18 AM Subject: Re: binary file > Actually i believe that the standard for input files is to default to > nocreate, but if you use the trunc flag everything works like a dream. It > even kills data in the file if it already existed i think. > > curtis > > -----Original Message----- > From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of > Jason Giglio > Sent: Friday, March 24, 2000 12:43 AM > To: CS2604@LISTSERV.VT.EDU > Subject: Re: binary file > > > I think this is wrong. There is an ios::nocreate flag that I have found > you must include when opening an input file, even when using an ifstream, > to make sure it doesn't create one. Otherwise it just makes a zero byte > file and lets you try to read from it, at least under MSVC 5.0. I havn't > tested this behavior under 6.0 yet, but I will be soon, since I just > installed it. Anyone else have a similar experience as mine? > > At 11:04 PM 3/23/00 -0500, you wrote: > >The reason is that you can't open non-existent files > >for reading. > > > >For example: > > > > ifstream in ("this-does-not-exist"); > > if (!in.good()) > > cout << "can't open input file" << endl; > > > >This will never open the input file, since it doesn't > >exist. > > > >This also happens to be the only way (using C++ iostreams) > >to tell if a file exists. (At least, it's the only way > >I know of that's within the confines of the language, and > >not some other standard such as POSIX. ANSI C FILE > >handles would also work.) > > > > > >Extrapolating this behavior suggests that if you try to > >open any non-existent file for reading, you'll get an > >error. > > > >At least, this is the case for MSVC. GCC, on the other > >hand, perfectly allows you to open a previously non-existent > >file for both reading and writing. Personally, I prefer > >this approach, as it allows you to open a file once, write > >to it, reposition the read pointer, and read what you wrote. > > > >If you're using MSVC, you'll either have to: > > 1) Do what David Cook suggested, and just reopen the file > > each time you access it. > > > > 2) Open the file for writing, write some (garbage) value, > > close it (so it'll exist), and re-open for reading and > > writing. > > > >I actually haven't tried (2) yet, but I think it should work. :-) > >It still seems ugly, though. I much prefer the GCC behavior. > > > > - Jon > > > >> -----Original Message----- > >> From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of > >> david > >> Sent: Thursday, March 23, 2000 6:58 PM > >> To: CS2604@LISTSERV.VT.EDU > >> Subject: binary file > >> > >> > >> Is there something special you have to do if you open a binary as > >> > >> binFile.open("p3bin.dat", ios::in|ios::out|ios::binary); > >> > >> and you want to read and write to it. > >> What I mean is, is there something you have to do "switch" between "input > >> mode" and "output mode"?? > >> > >> The problem I am having is this: > >> If I leave it like it is above, and I write to the stream, the file *will > >> not even be created*, and therefore contains nothing at programs end. > >> However, if I change it to: > >> > >> binFile.open("p3bin.dat", ios::out|ios::binary); > >> > >> Then the binary file is created, and has the proper "junk" > >> written to it at > >> programs end. > >> That IS the only change I made, and Im unsure as to why it doesnt work > the > >> first way. > >> > >> Any ideas? > >> David > > ========================================================================= Date: Fri, 24 Mar 2000 03:11:21 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Ryan Turner Subject: Re: Insert taking void* In-Reply-To: <020401bf955a$8d42be20$20d8c026@redrum> MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_I91/XpMTASA2zX+zb8Tsog)" This is a multi-part message in MIME format. --Boundary_(ID_I91/XpMTASA2zX+zb8Tsog) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Your compiler must be different from mine. I don't have to cast. Ryan How come its always seg's fault? -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of David Cook Sent: Friday, March 24, 2000 1:31 AM To: CS2604@LISTSERV.VT.EDU Subject: Re: Insert taking void* I understand that project 4 won't take char data but the ostream.write function takes a first parameter of char* so unless we use a different method to write to disk in project 4 we'll still be casting our void* data to char* to use the write function. Am I wrong in thinking this? -Dave ----- Original Message ----- From: Ryan Turner To: CS2604@LISTSERV.VT.EDU Sent: Thursday, March 23, 2000 11:06 PM Subject: Re: Insert taking void* Project 4 will not be character data. Might as well use void*. Ryan -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of David Cook Sent: Thursday, March 23, 2000 10:21 PM To: CS2604@LISTSERV.VT.EDU Subject: Insert taking void* Ok, ostream.write takes a char* and an int as it parameters, so why wouldn't the insert just take the (in this case text) data as a char* instead of a void*? If we take it as a void star we just have to cast it to back to char* (at least my compiler makes me cast it) to use in the write statement. Also, when I call my insert, which takes type void*, I have to explicitly cast from const char* to void*. I thought void* would take any type but it still makes me cast it. If someone could shed some light on this it'd appreciate it. Thanks -Dave C --Boundary_(ID_I91/XpMTASA2zX+zb8Tsog) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
Your=20 compiler must be different from mine.  I don't have to=20 cast.
 
 
Ryan

How come its always seg's fault?

-----Original Message-----
From: CS2604 discussion = list=20 [mailto:CS2604@listserv.vt.edu]On Behalf Of David = Cook
Sent:=20 Friday, March 24, 2000 1:31 AM
To:=20 CS2604@LISTSERV.VT.EDU
Subject: Re: Insert taking=20 void*

I understand that project 4 won't = take char data=20 but the ostream.write function takes a first parameter of char* so = unless we=20 use a different method to write to disk in project 4 we'll still be = casting=20 our void* data to char* to use the write function.
 
Am I wrong in thinking = this?
-Dave
----- Original Message -----
From:=20 Ryan = Turner=20
To: CS2604@LISTSERV.VT.EDU
Sent: Thursday, March 23, = 2000 11:06=20 PM
Subject: Re: Insert taking = void*

Project 4 will not be character = data.  Might=20 as well use void*.
 
Ryan
-----Original Message-----
From: CS2604 = discussion list=20 [mailto:CS2604@listserv.vt.edu]= On=20 Behalf Of David Cook
Sent: Thursday, March 23, 2000 = 10:21=20 PM
To: CS2604@LISTSERV.VT.EDU
S= ubject:=20 Insert taking void*

Ok, ostream.write takes a char* = and an int as=20 it parameters, so why wouldn't the insert just take the (in this = case=20 text) data as a char* instead of a void*?  If we take it as a = void=20 star we just have to cast it to back to char* (at least my = compiler makes=20 me cast it) to use in the write statement.  Also, when I call = my=20 insert, which takes type void*, I have to explicitly cast from = const char*=20 to void*.  I thought void* would take any type but it still = makes me=20 cast it.  If someone could shed some light on this it'd = appreciate=20 it.
 
Thanks
-Dave=20 C
--Boundary_(ID_I91/XpMTASA2zX+zb8Tsog)-- ========================================================================= Date: Fri, 24 Mar 2000 07:16:41 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Dennis Kryway II Subject: Debug command MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit After the list of Block ID's is printed in order of most recently used ID to the least recently used ID will the list be reversed? Should we treat the debug command as multiple buffer accesses or should we preserve the order of recent accesses as if there has been no change? ========================================================================= Date: Fri, 24 Mar 2000 11:10:46 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: Debug command In-Reply-To: <38DB5CA9.CE10CC60@vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII The debug command should NOT otherwise affect the behavior of the bufferpool. In particular, it should NOT change the order of the buffers. It is purely to gather information about the status of the bufferpool itself -- it does not affect the "currency" of the information in the database, so it wouldn't make sense to allow a debug command to affect the order of the buffers. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- On Fri, 24 Mar 2000, Dennis Kryway II wrote: > After the list of Block ID's is printed in order of most recently used > ID to the least recently used ID will the list be reversed? Should we > treat the debug command as multiple buffer accesses or should we > preserve the order of recent accesses as if there has been no change? > ========================================================================= Date: Fri, 24 Mar 2000 11:14:06 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: "get" on a NULL block In-Reply-To: <3.0.6.32.20000323233935.00916c60@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Thu, 23 Mar 2000, david wrote: > I have a question that expands on this previous question. This is about a > "get" call that is to a NULL block in the binary file. > > > Two things... first of all, say the command get 8 is used in the sample > > input file. Is this considered an error, since there was never a record 8, > > or should a blank string be returned since that space should be filled with > > NULLs now? > > The answer was this: > If the "get" to 8 took place AFTER an insert to some block with a higher ID > then 8, then the result is a null string. > > Should we print something like this: (or does it not matter to you) > get 8 > Block 8 contains "NULL STRING" > > or this: > get 8 > Block 8 contains "" Whatever you prefer. > ** ALSO ** > After doing the printing, does the block with the NULL STRING get inserted > into the first position of the buffer pool, like it would on a normal, > non-NULL buffer access?? Or, since it was a NULL block, do you just leave > it in the file and leave the existing buffer pool as it was?? Well, how can you know that the block contains a NULL string unless/until you read it in and look at it? No different or special behavior need or should take place for "null" blocks (aside from any necessary initialization). You want to simply read them in like any other block. The only exception is for blocks beyond the end of the file. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Fri, 24 Mar 2000 12:19:10 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Homework assignment 2 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Homework assignment 2 (due 4/5) has now been posted to the class website. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Fri, 24 Mar 2000 15:16:54 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: file size MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Im having a lot of trouble with finding the size of the file. I made a function which returns an int, and contains this: if(stat("p3bin.dat", &results) == 0) return results.st_size; else return 0; It keeps returning 0, and I cant figure out why. Yes the file is open, and yes there is data written to it. I had problems yesterday, with it being "one insert behind" on the file size (as far as the value it returns), and could not figure that out either. Any suggestions would help, or if there is another way to figure out the file size, let me know. ========================================================================= Date: Fri, 24 Mar 2000 15:43:20 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Webb Pinner Subject: last accessed buffer and the get command?? MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit When the get command is called on a valid buffer, does that buffer now become the most recently accessed buffer in the pool? ========================================================================= Date: Fri, 24 Mar 2000 16:17:03 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: Re: last accessed buffer and the get command?? In-Reply-To: <002a01bf95d1$abf61d40$b631ad80@portarthur> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Yes, this can be deduced from the sample given in the spec. At 03:43 PM 3/24/00 -0500, you wrote: >When the get command is called on a valid buffer, does that buffer now >become the most recently accessed buffer in the pool? > ========================================================================= Date: Fri, 24 Mar 2000 16:25:49 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jonathan Pryor Subject: Re: file size In-Reply-To: <3.0.6.32.20000324151654.009187f0@mail.vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit Have you flushed the file? Most libraries tend to buffer their output (C FILE handles, C++ iostreams, etc.), so even if you've written to the file, it might not have been written to disk. To do so, call ostream::flush(). - Jon > -----Original Message----- > From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of > david > Sent: Friday, March 24, 2000 3:17 PM > To: CS2604@LISTSERV.VT.EDU > Subject: file size > > > Im having a lot of trouble with finding the size of the file. > I made a function which returns an int, and contains this: > > if(stat("p3bin.dat", &results) == 0) > return results.st_size; > else > return 0; > > It keeps returning 0, and I cant figure out why. > Yes the file is open, and yes there is data written to it. > I had problems yesterday, with it being "one insert behind" on the file > size (as far as the value it returns), and could not figure that > out either. > > Any suggestions would help, or if there is another way to figure out the > file size, let me know. ========================================================================= Date: Fri, 24 Mar 2000 17:10:06 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: Re: file size In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=us-ascii no but Ill try. I found a different way to check, which I will probably use. But Im still curious. At 04:25 PM 03/24/2000 -0500, you wrote: >Have you flushed the file? > >Most libraries tend to buffer their output (C FILE handles, >C++ iostreams, etc.), so even if you've written to the file, >it might not have been written to disk. > >To do so, call ostream::flush(). > > - Jon > >> -----Original Message----- >> From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of >> david >> Sent: Friday, March 24, 2000 3:17 PM >> To: CS2604@LISTSERV.VT.EDU >> Subject: file size >> >> >> Im having a lot of trouble with finding the size of the file. >> I made a function which returns an int, and contains this: >> >> if(stat("p3bin.dat", &results) == 0) >> return results.st_size; >> else >> return 0; >> >> It keeps returning 0, and I cant figure out why. >> Yes the file is open, and yes there is data written to it. >> I had problems yesterday, with it being "one insert behind" on the file >> size (as far as the value it returns), and could not figure that >> out either. >> >> Any suggestions would help, or if there is another way to figure out the >> file size, let me know. > ========================================================================= Date: Fri, 24 Mar 2000 23:50:17 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: "Jason C. Gladden" Subject: binary output MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=us-ascii Does anyone know why the file pointer would not move during a write call ? //code sample printf("Current location of file pointer: %ld\n", myFile->tellp()); myFile->seekp(blocksize*ID); printf("New location of file pointer: %ld\n", myFile->tellp()); myFile->write(tmpSpace,blocksize); printf("location of file pointer after write: %ld\n", myFile->tellp()); //generated output Current location of file pointer: 255 New location of file pointer: 180 location of file pointer after write: 180 ????? The code works the first time it is called, but any additional calls don't move the pointer during the write. ========================================================================= Date: Sat, 25 Mar 2000 11:45:51 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Fang Huang Subject: buffer problem MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi, I have a very strange problem with the buffers, everything works well when I do insert, a input string is inserted into a buffer. But when I want to get a string from a buffer, the buffer contents became something like ЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭ§§§§нннннA. can somebody help? Thanks a lot! Fang ========================================================================= Date: Fri, 24 Mar 2000 11:55:05 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Scott Walker Subject: Missing Something? MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Just out of curiosity, why do the suggested function headers in the spec take a size parameter? If the blockSize get's passed into the contructor for the bufferpool and stored, why is that parameter needed? Is there some special case I'm forgetting to think about? ========================================================================= Date: Sat, 25 Mar 2000 13:38:01 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: Re: Missing Something? In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" I asked Dr. Shaffer this during spring break, here is what he said: > 2. If the client doesn't remember how long the strings were, how can the > getbytes method of the sample bufferpool object take a size parameter? > Shouldn't the client know the blocksize and allocate that amount of bytes > to the char*/void* passed to the getbytes function, and then the Bufferpool > should just copy the whole block to that memory? Exactly. The client knows how big the buffers are, because that parameter is specified when the buffer pool is created. The "messages" passed between the client and the buffer pool can just the size of an entire buffer. Actually, when writing the string to the pool, you could stick to string length. But when "reading" from the pool, you just get the whole buffer. Then, just use "cout" to dump the string (since it is null terminated). At 11:55 AM 3/24/00 -0500, you wrote: >Just out of curiosity, why do the suggested function >headers in the spec take a size parameter? If the blockSize >get's passed into the contructor for the bufferpool and >stored, why is that parameter needed? Is there some >special case I'm forgetting to think about? > ========================================================================= Date: Sat, 25 Mar 2000 15:35:55 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jonathan Pryor Subject: Re: buffer problem In-Reply-To: <0FRZ005ACL8E0T@gkar.cc.vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 8BIT Probably because you're allocating memory with ``new'' under MSVC. As a debugging aid, when you allocate memory with ``new'', MSVC fills that memory with values. The ``Э'' can be ignored (they correspond to the actual memory you requested); the ``§'' (and other characters) are used by ``delete'' to see if you have a buffer overflow, in which case it throws up a message dialog (for DEBUG builds; release builds don't do this). So, when you do a ``get'', you allocate a buffer for the requested block--which is correct--but you never read the file to actually fill in the buffer. Solution: make sure you read from the file on a ``get''. At least, that's my best guess. - Jon > -----Original Message----- > From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of > Fang Huang > Sent: Saturday, March 25, 2000 11:46 AM > To: CS2604@LISTSERV.VT.EDU > Subject: buffer problem > > > Hi, > I have a very strange problem with the buffers, everything works > well when I do insert, a input string is inserted into a buffer. > But when I > want to get a string from a buffer, the buffer contents became something > like ЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭ§§§§нннннA. > can somebody help? > Thanks a lot! > > Fang ========================================================================= Date: Sat, 25 Mar 2000 16:47:40 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Shalaka Tendulkar Subject: P2 grades: 1368 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Hi, The P2 grades for section 1368 have been updated. All the students who had lost points for inheritance and non-empty internal nodes have been given back those points. Shalaka ========================================================================= Date: Sat, 25 Mar 2000 16:52:37 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Josh Armentrout Subject: Replacing Blocks MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Quick question: if an insert is called for a block, say block 2, and block 2 exsists on the file, that is block 2 was once on the buffer and has be flushed, is the block in the file just overwritten eventually (ie at the end of the program or when the new block 2 is flushed) or should we remove it from the file right away. Or, does it get pulled out of the file, placed into the buffer and then checked and replaced? thanks. Josh. ========================================================================= Date: Sat, 25 Mar 2000 16:56:12 +0000 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Chris Tjoumas Subject: Re: writing to disk In-Reply-To: <3.0.6.32.20000320160045.0081ac70@mail.vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii At 04:00 PM 3/20/00 -0500, you wrote: >A buffer is dirty if it has been modified *since the last time it was >written to disk*. A buffer is 'born dirty' when you first put data into >it, since it isn't on disk yet. It can become clean by being pushed off >the end of the buffer pool, but then it isn't a buffer anymore, it is just >the data on disk. >The only time you have a clean buffer is after the data >is written to disk, and then you read it back into the buffer pool. The only time you write to disk is when the entire buffer pool is full. So, each time data is written to the buffer, it is taken from the tail of the list, the LRU buffer. What do you mean you read it back into the buffer pool? I thought that the data is written to the disk so that the new data can be written into that buffer at the tail, which is then moved to the head of the list. >Unless it is overwritten, it stays clean, and if it is pushed off the end of the >bufferpool when it is clean, you just junk it, it is still on the disk. How would the data in the buffer NOT be overwritten? I thought the idea of writing the information to disk was so that the buffer the data was in would become clean and the new infromation could then be written into that buffer, moving it to the head of the list and causing that buffer to become dirty. If I am thinking of this wrong, please correct me. >You only write to the disk when all your buffers are full, and you need to >insert another one. To make a free space, the Least Recently Used buffer >is flushed. This means, if it is dirty you write it on disk, expanding the >file if necessary, if it is clean you just replace it. Again, how can the buffer ever be clean if the buffer pool is full? I think this is my main question. Thanks, Chris Tjoumas ========================================================================= Date: Sat, 25 Mar 2000 17:28:45 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: Re: writing to disk In-Reply-To: <3.0.5.32.20000325165612.00909e00@mail.vt.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" I think the main thing you are not getting is that we are not just making a write buffer, it is also a read buffer. We buffer the get requests also. If a get request comes along, the data is read back out of the file and put back into the buffer pool as a clean buffer. At 04:56 PM 3/25/00 +0000, you wrote: >At 04:00 PM 3/20/00 -0500, you wrote: >What do you mean you read it back into the buffer pool? I thought that the >data >is written to the disk so that the new data can be written into that buffer >at the >tail, which is then moved to the head of the list. > ========================================================================= Date: Sat, 25 Mar 2000 20:33:15 -0500 Reply-To: wrathos@vt.edu Sender: CS2604 discussion list From: "Michael J. Bennett" Subject: Re: writing to disk MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit > >Unless it is overwritten, it stays clean, and if it is pushed off the end > of the > >bufferpool when it is clean, you just junk it, it is still on the disk. > > How would the data in the buffer NOT be overwritten? I thought the idea of > writing the information to disk was so that the buffer the data was in would > become clean and the new infromation could then be written into that buffer, > moving it to the head of the list and causing that buffer to become dirty. When the client requests a string with the get command, and that information is not already in the buffer pool, it must be read from disk and inserted into a buffer. If no subsequent requests write to that same block before the buffer is reused, then the information it holds is the same as that in the disk file, so it doesn't need to be rewritten. ========================================================================= Date: Sat, 25 Mar 2000 21:58:13 +0000 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: John Gordon Subject: HELP! IM stupid and i Cant get up MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_f22vdi8OI4rxIxp+HR8ctQ)" This is a multi-part message in MIME format. --Boundary_(ID_f22vdi8OI4rxIxp+HR8ctQ) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable ok, i know this seems like a really stupid question, but here goes. My compiler keeps making whoopie eyes at me and saying "User breakpoint called from code" the weird message is coming out of my class deconstructor during a = free() at first i thought i was deleting a null pointer, but then i looked a = little closer, and low and behold i was not. any suggestions as to how to remove the "user breakpoint called from = code"? here it is in case you wanted to know how terribly screwed up this is... buffer_list::~buffer_list() { buffptr temp =3D head; #checking for a null list if (head=3D=3DNULL){return;} #looping through and deleting the buffer while (head!=3DNULL) { head =3D head->next; delete temp; temp =3D head; } } ] (had to replace the // with # symbols because of cut and paste = complications...) please help if at all possible thenks john "and now for something we hope you'll really like" rocky -- the rocky and bullwinkle show --Boundary_(ID_f22vdi8OI4rxIxp+HR8ctQ) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
ok, i know this seems like a really = stupid=20 question,
but here goes.
My compiler keeps making whoopie eyes = at me and=20 saying
"User breakpoint called from = code"
 
the weird message is coming out of my = class=20 deconstructor during a free()
at first i thought i was deleting a = null pointer,=20 but then i looked a little closer, and low and behold i was = not.
 
any suggestions as to how to remove the = "user=20 breakpoint called from code"?
 
here it is in case you wanted to know = how terribly=20 screwed up this is...
 
buffer_list::~buffer_list()
{
 buffptr=20 temp =3D head;
  #checking for a null list
 if=20 (head=3D=3DNULL){return;}
 #looping through and deleting the=20 buffer
 while (head!=3DNULL)
 {
  head =3D=20 head->next;
  delete temp;
  temp =3D=20 head;
 }
}
]
(had to replace the // with # symbols = because of=20 cut and paste complications...)
 
 
please help if at all = possible
thenks
john
"and now for something we hope you'll = really=20 like"
rocky -- the rocky and bullwinkle=20 show
--Boundary_(ID_f22vdi8OI4rxIxp+HR8ctQ)-- ========================================================================= Date: Sun, 26 Mar 2000 01:40:12 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jonathan Pryor Subject: Re: HELP! IM stupid and i Cant get up In-Reply-To: <004e01bf96a5$379ba260$7d6d52c6@pooky> MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_2ZFm9HVVl4Q1T0hoUmDFuw)" This is a multi-part message in MIME format. --Boundary_(ID_2ZFm9HVVl4Q1T0hoUmDFuw) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Err.... Look very carefully at your loop. How often do you delete ``temp''? How many times do you actually assign an object to ``temp''? Are these numbers the same? - Jon -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of John Gordon Sent: Saturday, March 25, 2000 4:58 PM To: CS2604@LISTSERV.VT.EDU Subject: HELP! IM stupid and i Cant get up ok, i know this seems like a really stupid question, but here goes. My compiler keeps making whoopie eyes at me and saying "User breakpoint called from code" the weird message is coming out of my class deconstructor during a free() at first i thought i was deleting a null pointer, but then i looked a little closer, and low and behold i was not. any suggestions as to how to remove the "user breakpoint called from code"? here it is in case you wanted to know how terribly screwed up this is... buffer_list::~buffer_list() { buffptr temp = head; #checking for a null list if (head==NULL){return;} #looping through and deleting the buffer while (head!=NULL) { head = head->next; delete temp; temp = head; } } ] (had to replace the // with # symbols because of cut and paste complications...) please help if at all possible thenks john "and now for something we hope you'll really like" rocky -- the rocky and bullwinkle show --Boundary_(ID_2ZFm9HVVl4Q1T0hoUmDFuw) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
Err....
 
Look=20 very carefully at your loop.  How often do you delete=20 ``temp''?
How=20 many times do you actually assign an object to = ``temp''?
Are=20 these numbers the same?
 
 - Jon
-----Original Message-----
From: CS2604 discussion = list=20 [mailto:CS2604@listserv.vt.edu]On Behalf Of John = Gordon
Sent:=20 Saturday, March 25, 2000 4:58 PM
To:=20 CS2604@LISTSERV.VT.EDU
Subject: HELP! IM stupid and i Cant = get=20 up

ok, i know this seems like a really = stupid=20 question,
but here goes.
My compiler keeps making whoopie eyes = at me and=20 saying
"User breakpoint called from = code"
 
the weird message is coming out of my = class=20 deconstructor during a free()
at first i thought i was deleting a = null pointer,=20 but then i looked a little closer, and low and behold i was = not.
 
any suggestions as to how to remove = the "user=20 breakpoint called from code"?
 
here it is in case you wanted to know = how=20 terribly screwed up this is...
 
buffer_list::~buffer_list()
{
 buffptr=20 temp =3D head;
  #checking for a null list
 if=20 (head=3D=3DNULL){return;}
 #looping through and deleting the=20 buffer
 while (head!=3DNULL)
 {
  head = =3D=20 head->next;
  delete temp;
  temp =3D=20 head;
 }
}
]
(had to replace the // with # symbols = because of=20 cut and paste complications...)
 
 
please help if at all = possible
thenks
john
"and now for something we hope you'll = really=20 like"
rocky -- the rocky and bullwinkle=20 show
--Boundary_(ID_2ZFm9HVVl4Q1T0hoUmDFuw)-- ========================================================================= Date: Sun, 26 Mar 2000 02:11:23 +0000 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: John Gordon Subject: Re: HELP! IM stupid and i Cant get up MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_/+VA44XbSYADpfmmvYcu9g)" This is a multi-part message in MIME format. --Boundary_(ID_/+VA44XbSYADpfmmvYcu9g) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable yes, in fact, this problem has mutated into an ever greater problem = through some stupid work of my own, now the same code as well as any = attempted returns gives me this: Debug Assertion Failed! =20 Program ...es\Microsoft Visual Studio\MyProjects\buffer\buffer.exe File: dbgheap.c Line: 1017 Expression: _BLOCK_TYPE_IS_VALID[pHead->nBlockUse] For information on how your program can cause an assertion = failure... etc. either this assertion fails when i create a block and try to delete it, = or when i try to return a block type from a function... any help would = be nice on this one, it has me stumped. ----- Original Message -----=20 From: Jonathan Pryor=20 To: CS2604@LISTSERV.VT.EDU=20 Sent: Sunday, March 26, 2000 6:40 AM Subject: Re: HELP! IM stupid and i Cant get up Err.... =20 Look very carefully at your loop. How often do you delete ``temp''? How many times do you actually assign an object to ``temp''? Are these numbers the same? =20 - Jon -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On = Behalf Of John Gordon Sent: Saturday, March 25, 2000 4:58 PM To: CS2604@LISTSERV.VT.EDU Subject: HELP! IM stupid and i Cant get up ok, i know this seems like a really stupid question, but here goes. My compiler keeps making whoopie eyes at me and saying "User breakpoint called from code" the weird message is coming out of my class deconstructor during a = free() at first i thought i was deleting a null pointer, but then i looked = a little closer, and low and behold i was not. any suggestions as to how to remove the "user breakpoint called from = code"? here it is in case you wanted to know how terribly screwed up this = is... buffer_list::~buffer_list() { buffptr temp =3D head; #checking for a null list if (head=3D=3DNULL){return;} #looping through and deleting the buffer while (head!=3DNULL) { head =3D head->next; delete temp; temp =3D head; } } ] (had to replace the // with # symbols because of cut and paste = complications...) please help if at all possible thenks john "and now for something we hope you'll really like" rocky -- the rocky and bullwinkle show --Boundary_(ID_/+VA44XbSYADpfmmvYcu9g) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
yes, in fact, this problem has mutated = into an ever=20 greater problem through some stupid work of my own, now the same code as = well as=20 any attempted returns gives me this:
    Debug Assertion=20 Failed!
   
    Program = ...es\Microsoft Visual=20 Studio\MyProjects\buffer\buffer.exe
    File: = dbgheap.c
    Line: = 1017
 
    Expression:=20 _BLOCK_TYPE_IS_VALID[pHead->nBlockUse]
 
    For information on = how your=20 program can cause an assertion failure...
 
    etc.
 
either this assertion fails when i = create a block=20 and try to delete it, or when i try to return a block type from a = function...=20 any help would be nice on this one, it has me stumped.
----- Original Message -----
From:=20 Jonathan = Pryor
To: CS2604@LISTSERV.VT.EDU
Sent: Sunday, March 26, 2000 = 6:40=20 AM
Subject: Re: HELP! IM stupid = and i Cant=20 get up

Err....
 
Look=20 very carefully at your loop.  How often do you delete=20 ``temp''?
How=20 many times do you actually assign an object to = ``temp''?
Are=20 these numbers the same?
 
 - Jon
-----Original Message-----
From: CS2604 = discussion list [mailto:CS2604@listserv.vt.edu]= On=20 Behalf Of John Gordon
Sent: Saturday, March 25, 2000 = 4:58=20 PM
To: CS2604@LISTSERV.VT.EDU
Subject: HELP! IM = stupid=20 and i Cant get up

ok, i know this seems like a really = stupid=20 question,
but here goes.
My compiler keeps making whoopie = eyes at me and=20 saying
"User breakpoint called from = code"
 
the weird message is coming out of = my class=20 deconstructor during a free()
at first i thought i was deleting a = null=20 pointer, but then i looked a little closer, and low and behold i was = not.
 
any suggestions as to how to remove = the "user=20 breakpoint called from code"?
 
here it is in case you wanted to = know how=20 terribly screwed up this is...
 
buffer_list::~buffer_list()
{
 buffptr temp =3D=20 head;
  #checking for a null list
 if=20 (head=3D=3DNULL){return;}
 #looping through and deleting the = buffer
 while (head!=3DNULL)
 {
  head = =3D=20 head->next;
  delete temp;
  temp =3D=20 head;
 }
}
]
(had to replace the // with # = symbols because=20 of cut and paste complications...)
 
 
please help if at all = possible
thenks
john
"and now for something we hope = you'll really=20 like"
rocky -- the rocky and bullwinkle=20 show
--Boundary_(ID_/+VA44XbSYADpfmmvYcu9g)-- ========================================================================= Date: Sun, 26 Mar 2000 02:20:13 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jonathan Pryor Subject: Re: HELP! IM stupid and i Cant get up In-Reply-To: <001901bf96c8$95afb850$7d6d52c6@pooky> MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_sfuoNzgVfl1yQ9exc/4luQ)" This is a multi-part message in MIME format. --Boundary_(ID_sfuoNzgVfl1yQ9exc/4luQ) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit OK, I was apparently on something when I wrote the last message. (sleep depravation? short attention span?) Perhaps I need more caffeine... (I'd thought that ``temp'' wasn't being correctly incremented, but a second reading of the code proves me to be wrong...) My next guess is: - Are you sure that your linked list has been terminated correctly (with a NULL)? If you haven't, you'd be trying to delete random garbage, which would probably cause the problem you're seeing. - Are you sure that all elements in the linked list were allocated via ``new''? If not, then you're trying to delete a stack based object, which won't work. An example of this would be: node n; node* pn = new node(); pn->next = &n; // no-no Beyond those, I can't think of anything... - Jon -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of John Gordon Sent: Saturday, March 25, 2000 9:11 PM To: CS2604@LISTSERV.VT.EDU Subject: Re: HELP! IM stupid and i Cant get up yes, in fact, this problem has mutated into an ever greater problem through some stupid work of my own, now the same code as well as any attempted returns gives me this: Debug Assertion Failed! Program ...es\Microsoft Visual Studio\MyProjects\buffer\buffer.exe File: dbgheap.c Line: 1017 Expression: _BLOCK_TYPE_IS_VALID[pHead->nBlockUse] For information on how your program can cause an assertion failure... etc. either this assertion fails when i create a block and try to delete it, or when i try to return a block type from a function... any help would be nice on this one, it has me stumped. ----- Original Message ----- From: Jonathan Pryor To: CS2604@LISTSERV.VT.EDU Sent: Sunday, March 26, 2000 6:40 AM Subject: Re: HELP! IM stupid and i Cant get up Err.... Look very carefully at your loop. How often do you delete ``temp''? How many times do you actually assign an object to ``temp''? Are these numbers the same? - Jon -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of John Gordon Sent: Saturday, March 25, 2000 4:58 PM To: CS2604@LISTSERV.VT.EDU Subject: HELP! IM stupid and i Cant get up ok, i know this seems like a really stupid question, but here goes. My compiler keeps making whoopie eyes at me and saying "User breakpoint called from code" the weird message is coming out of my class deconstructor during a free() at first i thought i was deleting a null pointer, but then i looked a little closer, and low and behold i was not. any suggestions as to how to remove the "user breakpoint called from code"? here it is in case you wanted to know how terribly screwed up this is... buffer_list::~buffer_list() { buffptr temp = head; #checking for a null list if (head==NULL){return;} #looping through and deleting the buffer while (head!=NULL) { head = head->next; delete temp; temp = head; } } ] (had to replace the // with # symbols because of cut and paste complications...) please help if at all possible thenks john "and now for something we hope you'll really like" rocky -- the rocky and bullwinkle show --Boundary_(ID_sfuoNzgVfl1yQ9exc/4luQ) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
OK, I=20 was apparently on something when I wrote the last message.  (sleep=20 depravation?  short attention span?)  Perhaps I need more=20 caffeine...
(I'd=20 thought that ``temp'' wasn't being correctly incremented, but a second = reading=20 of the code proves me to be wrong...)
 
My=20 next guess is:
 - Are you sure that your linked list = has been=20 terminated correctly (with a NULL)?
   If you haven't, you'd be trying = to delete=20 random garbage, which would probably cause the problem you're=20 seeing.
 - Are you sure that all elements in the = linked=20 list were allocated via ``new''?
   If not, then you're trying to = delete a=20 stack based object, which won't work.
   An example of this would=20 be:
        = node=20 n;
        = node* pn =3D=20 new node();
        = pn->next=20 =3D &n;    // no-no
 
Beyond=20 those, I can't think of anything...
 
 - Jon
-----Original Message-----
From: CS2604 discussion = list=20 [mailto:CS2604@listserv.vt.edu]On Behalf Of John = Gordon
Sent:=20 Saturday, March 25, 2000 9:11 PM
To:=20 CS2604@LISTSERV.VT.EDU
Subject: Re: HELP! IM stupid and i = Cant get=20 up

yes, in fact, this problem has = mutated into an=20 ever greater problem through some stupid work of my own, now the same = code as=20 well as any attempted returns gives me this:
    Debug Assertion=20 Failed!
   
    Program = ...es\Microsoft Visual=20 Studio\MyProjects\buffer\buffer.exe
    File: = dbgheap.c
    Line: = 1017
 
    Expression:=20 _BLOCK_TYPE_IS_VALID[pHead->nBlockUse]
 
    For information on = how your=20 program can cause an assertion failure...
 
    etc.
 
either this assertion fails when i = create a block=20 and try to delete it, or when i try to return a block type from a = function...=20 any help would be nice on this one, it has me stumped.
----- Original Message -----
From:=20 Jonathan = Pryor=20
To: CS2604@LISTSERV.VT.EDU
Sent: Sunday, March 26, 2000 = 6:40=20 AM
Subject: Re: HELP! IM stupid = and i Cant=20 get up

Err....
 
Look very carefully at your loop.  = How often=20 do you delete ``temp''?
How many times do you actually assign an = object to=20 ``temp''?
Are these numbers the = same?
 
 - Jon
-----Original Message-----
From: CS2604 = discussion list=20 [mailto:CS2604@listserv.vt.edu]= On=20 Behalf Of John Gordon
Sent: Saturday, March 25, 2000 = 4:58=20 PM
To: CS2604@LISTSERV.VT.EDU
Subject: HELP! = IM stupid=20 and i Cant get up

ok, i know this seems like a = really stupid=20 question,
but here goes.
My compiler keeps making whoopie = eyes at me=20 and saying
"User breakpoint called from=20 code"
 
the weird message is coming out = of my class=20 deconstructor during a free()
at first i thought i was deleting = a null=20 pointer, but then i looked a little closer, and low and behold i = was=20 not.
 
any suggestions as to how to = remove the "user=20 breakpoint called from code"?
 
here it is in case you wanted to = know how=20 terribly screwed up this is...
 
buffer_list::~buffer_list()
{
 buffptr temp = =3D=20 head;
  #checking for a null list
 if=20 (head=3D=3DNULL){return;}
 #looping through and deleting = the=20 buffer
 while = (head!=3DNULL)
 {
  head =3D=20 head->next;
  delete temp;
  temp =3D = head;
 }
}
]
(had to replace the // with # = symbols because=20 of cut and paste complications...)
 
 
please help if at all = possible
thenks
john
"and now for something we hope = you'll really=20 like"
rocky -- the rocky and bullwinkle = = show
--Boundary_(ID_sfuoNzgVfl1yQ9exc/4luQ)-- ========================================================================= Date: Sun, 26 Mar 2000 04:51:40 +0000 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: John Gordon Subject: Re: HELP! IM stupid and i Cant get up MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_noPP0ZQJ8kcCgP5JaQAxsw)" This is a multi-part message in MIME format. --Boundary_(ID_noPP0ZQJ8kcCgP5JaQAxsw) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable Jonathan Pryor, you are the man. it was the pn =3D &n problem ive never run into it before thank you very much for your help "the man" from now on, let it be decreed that Jonathan Pryor is to be addressed as "the man". thanks again john "Creativity comes from small groups. Small groups gave us the electric light, the automobile, the personal computer.=20 Beurocracies gave us the nuclear power plant, traffic jams, and network television." --Bruce Sterling (Islands In The Net) ----- Original Message -----=20 From: Jonathan Pryor=20 To: CS2604@LISTSERV.VT.EDU=20 Sent: Sunday, March 26, 2000 7:20 AM Subject: Re: HELP! IM stupid and i Cant get up OK, I was apparently on something when I wrote the last message. = (sleep depravation? short attention span?) Perhaps I need more = caffeine... (I'd thought that ``temp'' wasn't being correctly incremented, but a = second reading of the code proves me to be wrong...) =20 My next guess is: - Are you sure that your linked list has been terminated correctly = (with a NULL)? If you haven't, you'd be trying to delete random garbage, which = would probably cause the problem you're seeing. - Are you sure that all elements in the linked list were allocated = via ``new''? If not, then you're trying to delete a stack based object, which = won't work. An example of this would be: node n; node* pn =3D new node(); pn->next =3D &n; // no-no =20 Beyond those, I can't think of anything... =20 - Jon -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On = Behalf Of John Gordon Sent: Saturday, March 25, 2000 9:11 PM To: CS2604@LISTSERV.VT.EDU Subject: Re: HELP! IM stupid and i Cant get up yes, in fact, this problem has mutated into an ever greater problem = through some stupid work of my own, now the same code as well as any = attempted returns gives me this: Debug Assertion Failed! =20 Program ...es\Microsoft Visual = Studio\MyProjects\buffer\buffer.exe File: dbgheap.c Line: 1017 Expression: _BLOCK_TYPE_IS_VALID[pHead->nBlockUse] For information on how your program can cause an assertion = failure... etc. either this assertion fails when i create a block and try to delete = it, or when i try to return a block type from a function... any help = would be nice on this one, it has me stumped. ----- Original Message -----=20 From: Jonathan Pryor=20 To: CS2604@LISTSERV.VT.EDU=20 Sent: Sunday, March 26, 2000 6:40 AM Subject: Re: HELP! IM stupid and i Cant get up Err.... =20 Look very carefully at your loop. How often do you delete = ``temp''? How many times do you actually assign an object to ``temp''? Are these numbers the same? =20 - Jon -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On = Behalf Of John Gordon Sent: Saturday, March 25, 2000 4:58 PM To: CS2604@LISTSERV.VT.EDU Subject: HELP! IM stupid and i Cant get up ok, i know this seems like a really stupid question, but here goes. My compiler keeps making whoopie eyes at me and saying "User breakpoint called from code" the weird message is coming out of my class deconstructor during = a free() at first i thought i was deleting a null pointer, but then i = looked a little closer, and low and behold i was not. any suggestions as to how to remove the "user breakpoint called = from code"? here it is in case you wanted to know how terribly screwed up = this is... buffer_list::~buffer_list() { buffptr temp =3D head; #checking for a null list if (head=3D=3DNULL){return;} #looping through and deleting the buffer while (head!=3DNULL) { head =3D head->next; delete temp; temp =3D head; } } ] (had to replace the // with # symbols because of cut and paste = complications...) please help if at all possible thenks john "and now for something we hope you'll really like" rocky -- the rocky and bullwinkle show --Boundary_(ID_noPP0ZQJ8kcCgP5JaQAxsw) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
Jonathan Pryor, you are the = man.
it was the pn =3D &n = problem
ive never run into it = before
thank you very much for your help "the=20 man"
from now on, let it be decreed that = Jonathan Pryor=20 is to be addressed
as "the man".
 
thanks again
john
"Creativity comes from small = groups.
Small groups gave us the electric=20 light,
the automobile, the personal computer.=20
Beurocracies gave us the nuclear power=20 plant,
traffic jams, and network = television."
--Bruce Sterling (Islands In The = Net)
----- Original Message -----
From:=20 Jonathan = Pryor
To: CS2604@LISTSERV.VT.EDU
Sent: Sunday, March 26, 2000 = 7:20=20 AM
Subject: Re: HELP! IM stupid = and i Cant=20 get up

OK,=20 I was apparently on something when I wrote the last message.  = (sleep=20 depravation?  short attention span?)  Perhaps I need more=20 caffeine...
(I'd=20 thought that ``temp'' wasn't being correctly incremented, but a second = reading=20 of the code proves me to be wrong...)
 
My=20 next guess is:
 - Are you sure that your linked list = has been=20 terminated correctly (with a NULL)?
   If you haven't, you'd be = trying to=20 delete random garbage, which would probably cause the problem you're=20 seeing.
 - Are you sure that all elements in = the linked=20 list were allocated via ``new''?
   If not, then you're trying to = delete a=20 stack based object, which won't work.
   An example of this would=20 be:
        = node=20 n;
        = node* pn =3D=20 new node();
       =20 pn->next =3D &n;    // no-no
 
Beyond those, I can't think of=20 anything...
 
 - Jon
-----Original Message-----
From: CS2604 = discussion list=20 [mailto:CS2604@listserv.vt.edu]On Behalf Of John=20 Gordon
Sent: Saturday, March 25, 2000 9:11 = PM
To:=20 CS2604@LISTSERV.VT.EDU
Subject: Re: HELP! IM stupid and i = Cant get=20 up

yes, in fact, this problem has = mutated into an=20 ever greater problem through some stupid work of my own, now the = same code=20 as well as any attempted returns gives me this:
    Debug Assertion=20 Failed!
   
    Program = ...es\Microsoft=20 Visual Studio\MyProjects\buffer\buffer.exe
    File: = dbgheap.c
    Line: = 1017
 
    Expression:=20 _BLOCK_TYPE_IS_VALID[pHead->nBlockUse]
 
    For information = on how your=20 program can cause an assertion failure...
 
    = etc.
 
either this assertion fails when i = create a=20 block and try to delete it, or when i try to return a block type = from a=20 function... any help would be nice on this one, it has me=20 stumped.
----- Original Message ----- =
From:=20 Jonathan = Pryor=20
To: CS2604@LISTSERV.VT.EDU
Sent: Sunday, March 26, = 2000 6:40=20 AM
Subject: Re: HELP! IM = stupid and i=20 Cant get up

Err....
 
Look very carefully at your loop.  = How often=20 do you delete ``temp''?
How many times do you actually assign = an object=20 to ``temp''?
Are these numbers the = same?
 
 - Jon
-----Original Message-----
From: CS2604 = discussion list=20 [mailto:CS2604@listserv.vt.edu]= On=20 Behalf Of John Gordon
Sent: Saturday, March 25, = 2000 4:58=20 PM
To: CS2604@LISTSERV.VT.EDU
Subject: HELP! = IM=20 stupid and i Cant get up

ok, i know this seems like a = really stupid=20 question,
but here goes.
My compiler keeps making = whoopie eyes at me=20 and saying
"User breakpoint called from=20 code"
 
the weird message is coming out = of my class=20 deconstructor during a free()
at first i thought i was = deleting a null=20 pointer, but then i looked a little closer, and low and behold i = was=20 not.
 
any suggestions as to how to = remove the=20 "user breakpoint called from code"?
 
here it is in case you wanted = to know how=20 terribly screwed up this is...
 
buffer_list::~buffer_list()
{
 buffptr temp = =3D=20 head;
  #checking for a null list
 if=20 (head=3D=3DNULL){return;}
 #looping through and deleting = the=20 buffer
 while = (head!=3DNULL)
 {
  head =3D=20 head->next;
  delete temp;
  temp = =3D=20 head;
 }
}
]
(had to replace the // with # = symbols=20 because of cut and paste complications...)
 
 
please help if at all = possible
thenks
john
"and now for something we hope = you'll=20 really like"
rocky -- the rocky and = bullwinkle=20 = show
--Boundary_(ID_noPP0ZQJ8kcCgP5JaQAxsw)-- ========================================================================= Date: Sun, 26 Mar 2000 10:18:53 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Joel Eiholzer Subject: hmmmmm Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" I have read the specs and I have all the emails but there is something I am just not quite getting. (It may be a personal mind block.) Basically my question comes down to this. Can the first block of a buffer equate to any block in the file or does it always equal 0 or a multiple of the buffer size. For example if the buffers are ten blocks in length and we have a file 100 blocks long. Can the first block of any given buffer equate to file block values 0-90, or do they have to be in the set {0,10,20,30,...,80,90}? ========================================================================= Date: Sun, 26 Mar 2000 10:42:42 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: "Bryan R. Deehring" Subject: Re: hmmmmm MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit -----Original Message----- From: Joel Eiholzer [SMTP:jeiholze@VT.EDU] Sent: Sunday, March 26, 2000 10:19 AM To: CS2604@LISTSERV.VT.EDU Subject: hmmmmm I have read the specs and I have all the emails but there is something I am just not quite getting. (It may be a personal mind block.) Basically my question comes down to this. Can the first block of a buffer equate to any block in the file? yes or does it always equal 0 or a multiple of the buffer size. For example if the buffers are ten blocks in length and we have a file 100 blocks long. Can the first block of any given buffer equate to file block values 0-90, or do they have to be in the set {0,10,20,30,...,80,90}? no ========================================================================= Date: Sun, 26 Mar 2000 11:21:26 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Chris Kelly Subject: problems with namespace and fstream? MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit working on the code and I came along this problem: my code compiles, and runs, but it doesn't create a binary file. after a bit of poking around, i found that if I use (using a test project): #include instead of: #include using namespace std; the file IO works. anyone know of a workaround to this problem (other than the "don't use namespace" :) )? I'd like to use namespace if possible, but having my binary IO work is pretty important to this project. -Chris ========================================================================= Date: Sun, 26 Mar 2000 11:30:43 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Joel Eiholzer Subject: hmmmm part 2 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Ok so assuming that the first block of a buffer can equate to any block in the file. Again assume buffers are the size of 10 blocks. What happens when I write a 9 block whatever to block 0 (Yes I realize it fills blocks 0-8 with the information and block 9 gets a null). Now what happens when I write that same set of information to block 5? So now blocks 5-13 have the info and 14 has a null. Ok here is the problem/question. What happens when I get block zero back out to write?? The buffer only holds ten blocks and the first null is not until block 14. ========================================================================= Date: Sun, 26 Mar 2000 12:18:28 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jonathan Pryor Subject: Re: problems with namespace and fstream? In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Can you post sample code? I'm using std::fstream (the namespace version), and I'm not having any problems with it. Are you sure you're doing: using namespace std; fstream buffer ("p3bin.dat", ios::in | ios::out | ios::binary | ios::trunc); Leaving off ``ios::trunc'' would cause problems with creating the file; it might be responsible for what you're seeing as well. - Jon > -----Original Message----- > From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of > Chris Kelly > Sent: Sunday, March 26, 2000 11:21 AM > To: CS2604@LISTSERV.VT.EDU > Subject: problems with namespace and fstream? > > > working on the code and I came along this problem: > > my code compiles, and runs, but it doesn't create a binary file. > after a bit > of poking around, i found that if I use (using a test project): > > #include > > instead of: > > #include > using namespace std; > > the file IO works. anyone know of a workaround to this problem (other than > the "don't use namespace" :) )? I'd like to use namespace if possible, but > having my binary IO work is pretty important to this project. > > -Chris ========================================================================= Date: Sun, 26 Mar 2000 13:02:03 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jeremy Lerner Subject: Re: hmmmm part 2 In-Reply-To: <3.0.5.32.20000326113043.009d1150@192.168.0.1> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=us-ascii I think your problem may be that you're confusing the concept of a block with the concept of a byte. I you have a file that's 100 bytes long and a maximum block size of 10 bytes, you've got a file with 10 blocks in it. If you code things right, there shouldn't be any way for you to insert something starting in the middle of another block, because you use blockID * blockSize to figure out the starting point for a block before you insert anything. So following your example, if you insert something 9 bytes long into block 0, that info will fill bytes 0 through 8 and byte 9 will get a null. So far so good. Now, you want to insert the same 9 bytes into block 5. You don't want to start writing at byte 5, because that is a part of the first block. You want to write to *block* 5, which starts at 5 * 10 = byte 50, so you fill bytes 50 through 58 with the data and put the null terminator in byte 59. If you use this scheme, you shouldn't have any problems with overwriting data in neighboring blocks. At 11:30 AM 3/26/2000 -0500, you wrote: > Ok so assuming that the first block of a buffer can equate to any > block in >the file. Again assume buffers are the size of 10 blocks. What happens >when I write a 9 block whatever to block 0 (Yes I realize it fills blocks >0-8 with the information and block 9 gets a null). Now what happens when I >write that same set of information to block 5? So now blocks 5-13 have the >info and 14 has a null. > Ok here is the problem/question. What happens when I get block > zero back >out to write?? The buffer only holds ten blocks and the first null is not >until block 14. -- Jeremy Lerner - jlerner@vt.edu I'm going to live forever or die trying. ========================================================================= Date: Sun, 26 Mar 2000 13:04:42 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jason Giglio Subject: Re: hmmmm part 2 In-Reply-To: <3.0.5.32.20000326113043.009d1150@192.168.0.1> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" I'm assuming you are meaning characters in a single record. If you overwrite a string with a shorter string, you simply overwrite it, you don't do any sort of insert like it seems you are doing. If this isn't what you are talking about, you need to clarify your terminology. At 11:30 AM 3/26/00 -0500, you wrote: > Ok so assuming that the first block of a buffer can equate to any block in >the file. Again assume buffers are the size of 10 blocks. What happens >when I write a 9 block whatever to block 0 (Yes I realize it fills blocks >0-8 with the information and block 9 gets a null). Now what happens when I >write that same set of information to block 5? So now blocks 5-13 have the >info and 14 has a null. > Ok here is the problem/question. What happens when I get block zero back >out to write?? The buffer only holds ten blocks and the first null is not >until block 14. > ========================================================================= Date: Sun, 26 Mar 2000 13:41:15 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Joel Eiholzer Subject: Re: hmmmm part 2 In-Reply-To: <4.3.0.20000326125205.00b46e10@mail.vt.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Ok, so each buffer is one block in length however many bytes that may be as defined in the constructor. So if each block/buffer is ten bytes long then a buffer containing block 1 starts are byte 0 in the file and block 2 starts at byte 10 in the file, etc... (I do realize that the buffer don't actually point to or share the same memory as the file.) Sound right? Thank you. At 01:02 PM 3/26/00 -0500, you wrote: >I think your problem may be that you're confusing the concept of a block >with the concept of a byte. I you have a file that's 100 bytes long and a >maximum block size of 10 bytes, you've got a file with 10 blocks in it. If >you code things right, there shouldn't be any way for you to insert >something starting in the middle of another block, because you use blockID >* blockSize to figure out the starting point for a block before you insert >anything. So following your example, if you insert something 9 bytes long >into block 0, that info will fill bytes 0 through 8 and byte 9 will get a >null. So far so good. Now, you want to insert the same 9 bytes into block >5. You don't want to start writing at byte 5, because that is a part of >the first block. You want to write to *block* 5, which starts at 5 * 10 = >byte 50, so you fill bytes 50 through 58 with the data and put the null >terminator in byte 59. If you use this scheme, you shouldn't have any >problems with overwriting data in neighboring blocks. > >At 11:30 AM 3/26/2000 -0500, you wrote: >> Ok so assuming that the first block of a buffer can equate to any >> block in >>the file. Again assume buffers are the size of 10 blocks. What happens >>when I write a 9 block whatever to block 0 (Yes I realize it fills blocks >>0-8 with the information and block 9 gets a null). Now what happens when I >>write that same set of information to block 5? So now blocks 5-13 have the >>info and 14 has a null. >> Ok here is the problem/question. What happens when I get block >> zero back >>out to write?? The buffer only holds ten blocks and the first null is not >>until block 14. > >-- >Jeremy Lerner - jlerner@vt.edu > >I'm going to live forever or die trying. > ========================================================================= Date: Sun, 26 Mar 2000 14:07:14 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jeremy Lerner Subject: Re: hmmmm part 2 In-Reply-To: <3.0.5.32.20000326134115.009cbdc0@192.168.0.1> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=us-ascii Sounds like you've got the right idea now, but it's probably easier to start numbering at block 0. That way you can use blockID * blockSize to get to the beginning of blocks directly (0 * 10 = 0, 1 * 10 = 10, 2 * 10 =20, etcetera). You could number starting at 1 if you want to, but then you have to use (blockID * blockSize) - blockSize to get to the right starting position in the file, which is slightly inefficient. At 01:41 PM 3/26/2000 -0500, you wrote: > Ok, so each buffer is one block in length however many bytes that > may be >as defined in the constructor. So if each block/buffer is ten bytes long >then a buffer containing block 1 starts are byte 0 in the file and block 2 >starts at byte 10 in the file, etc... (I do realize that the buffer don't >actually point to or share the same memory as the file.) > Sound right? Thank you. > > > > > >At 01:02 PM 3/26/00 -0500, you wrote: > >I think your problem may be that you're confusing the concept of a block > >with the concept of a byte. I you have a file that's 100 bytes long and a > >maximum block size of 10 bytes, you've got a file with 10 blocks in it. If > >you code things right, there shouldn't be any way for you to insert > >something starting in the middle of another block, because you use blockID > >* blockSize to figure out the starting point for a block before you insert > >anything. So following your example, if you insert something 9 bytes long > >into block 0, that info will fill bytes 0 through 8 and byte 9 will get a > >null. So far so good. Now, you want to insert the same 9 bytes into block > >5. You don't want to start writing at byte 5, because that is a part of > >the first block. You want to write to *block* 5, which starts at 5 * 10 = > >byte 50, so you fill bytes 50 through 58 with the data and put the null > >terminator in byte 59. If you use this scheme, you shouldn't have any > >problems with overwriting data in neighboring blocks. > > > >At 11:30 AM 3/26/2000 -0500, you wrote: > >> Ok so assuming that the first block of a buffer can equate to any > >> block in > >>the file. Again assume buffers are the size of 10 blocks. What happens > >>when I write a 9 block whatever to block 0 (Yes I realize it fills blocks > >>0-8 with the information and block 9 gets a null). Now what happens when I > >>write that same set of information to block 5? So now blocks 5-13 have the > >>info and 14 has a null. > >> Ok here is the problem/question. What happens when I get block > >> zero back > >>out to write?? The buffer only holds ten blocks and the first null is not > >>until block 14. > > > >-- > >Jeremy Lerner - jlerner@vt.edu > > > >I'm going to live forever or die trying. > > -- Jeremy Lerner - jlerner@vt.edu I'm going to live forever or die trying. ========================================================================= Date: Sun, 26 Mar 2000 14:13:13 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: r duffy Subject: Re: problems with namespace and fstream? In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit i think what you need to do is #include when you are using the c code from the notes and use #include using namespace std; when you use the c++ style for the file (ie. from the web page) an option is to write a container class for your binary file, and in the source file for that class, dont include namespace. -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Chris Kelly Sent: 26 March, 2000 11:21 AM To: CS2604@LISTSERV.VT.EDU Subject: problems with namespace and fstream? working on the code and I came along this problem: my code compiles, and runs, but it doesn't create a binary file. after a bit of poking around, i found that if I use (using a test project): #include instead of: #include using namespace std; the file IO works. anyone know of a workaround to this problem (other than the "don't use namespace" :) )? I'd like to use namespace if possible, but having my binary IO work is pretty important to this project. -Chris ========================================================================= Date: Sun, 26 Mar 2000 15:15:48 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: "Jeffrey T. Haug" Subject: parameter sz MIME-version: 1.0 Content-type: text/plain; charset=us-ascii >At 11:55 AM 3/24/00 -0500, you wrote: >>Just out of curiosity, why do the suggested function >>headers in the spec take a size parameter? If the blockSize >>get's passed into the contructor for the bufferpool and >>stored, why is that parameter needed? Is there some >>special case I'm forgetting to think about? >> > At 01:38 PM 3/25/00 , you wrote: >I asked Dr. Shaffer this during spring break, here is what he said: > >> 2. If the client doesn't remember how long the strings were, how can the >> getbytes method of the sample bufferpool object take a size parameter? >> Shouldn't the client know the blocksize and allocate that amount of bytes >> to the char*/void* passed to the getbytes function, and then the Bufferpool >> should just copy the whole block to that memory? > >Exactly. The client knows how big the buffers are, because that parameter >is specified when the buffer pool is created. The "messages" passed >between the client and the buffer pool can just the size of an entire >buffer. Actually, when writing the string to the pool, you could stick to >string length. But when "reading" from the pool, you just get the whole >buffer. Then, just use "cout" to dump the string (since it is null >terminated). > i am still confused by this response..... so that parameter isn't needed? we should pass in the blocksize every time along wiht the truncated string? we should pass in the string length with the full string to later be cut down to blocksize by the buffer pool? is that parameter going to be essential in the next project?? confused jeff ========================================================================= Date: Mon, 8 Mar 0100 19:23:04 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brian Wagner Subject: Suggested CASE tool for debugging File Access In-Reply-To: <3.0.6.32.20000323233935.00916c60@mail.vt.edu> from "david" at Mar 23, 0 11:39:35 pm Content-Type: text I suggest anyone who has not finished their File access routines see: http://www.gnome.org/mc/download.html And download this "Midnight Commander" tool advertised there -It allows you to view the file in Hex -and is available in Linux (`mc`), DOS, and Windows (USAGE DIRECTIONS: press "F3" to "View" selected file -> "F4" to see file in "Hex") -- // *Brian Wagner, CpE My Homepage: http://www.bigfoot.com/~datatroi // The VT Heavy "Metal Club" page: http://www.bigfoot.com/~vtmetal "How do most men define marriage? A very expensive way to get your laundry done free." (Please note, I don't agree w/ this; it's just funny as heck. :-) -BW) ------------------------------------------------------------------------- ========================================================================= Date: Sun, 26 Mar 2000 21:34:58 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Saam Tariverdi Subject: Input question MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Got a quick question -- do we use an input/output file (like project 2), or do we input in commands by hand (typing them in)? I'm thinking that we do it by hand, but then my question is: how is it possible redirect the input to a file and do a cin.eof() command to check whether or not there are no more commands to run? Thanks in advance. Saam Tariverdi ========================================================================= Date: Sun, 26 Mar 2000 22:02:33 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Michael Leatherman Subject: Re: Input question In-Reply-To: <008001bf9795$0b4907c0$124723d0@saam> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit the spec says to use standard i/o. so use redirection: for example, buffer < in.txt > out.txt 5 15 at the command line. in main (or whatever your controlling function is): do{ ... stuff ... }while(!cin.eof()) -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Saam Tariverdi Sent: Sunday, March 26, 2000 9:35 PM To: CS2604@LISTSERV.VT.EDU Subject: Input question Got a quick question -- do we use an input/output file (like project 2), or do we input in commands by hand (typing them in)? I'm thinking that we do it by hand, but then my question is: how is it possible redirect the input to a file and do a cin.eof() command to check whether or not there are no more commands to run? Thanks in advance. Saam Tariverdi ========================================================================= Date: Sun, 26 Mar 2000 22:05:47 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Saam Tariverdi Subject: MSVC 6.0 w/Win2k question MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit I know this is slightly off-topic, but here goes -- I installed Visual C++ 6.0 in Windows 2000, but when I try to run the debugger, it gives me all these weird prompts. I remember seeing something when I installed C++ 6.0 about how I should install the Windows NT Symbols or something, do I need to do that though? Basically, has anyone gotten MSVC 6.0 to work in Windows 2000 properly? Let me know asap, thanks! Saam Tariverdi ========================================================================= Date: Sun, 26 Mar 2000 22:22:57 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: r duffy Subject: Re: Input question In-Reply-To: <008001bf9795$0b4907c0$124723d0@saam> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit you can pipe a file to std input ( Sender: CS2604 discussion list From: Saam Tariverdi Subject: own problem fixed MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Sorry to keep flooding the listserv, I figured out what the problem was with MSVC and Win2k (it was my own mistake). My apologies. Saam Tariverdi ========================================================================= Date: Sun, 26 Mar 2000 22:40:07 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Sidney Bennett Subject: Re: Input question MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit commands come from standard input and results go to standard output. If you are trying to type commands in manually, I believe represents the end of file character. We did the exact same thing back in Project 1. ========================================================================= Date: Sun, 26 Mar 2000 22:46:18 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Tanner Bonig Subject: does this look familiar? MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit warning LNK4019: corrupt string table (table end); new end assumed LIBCD.lib(xtoa.obj) : fatal error LNK1143: invalid or corrupt file: no symbol for comdat section 0x4 thanks.. tanner ========================================================================= Date: Sun, 26 Mar 2000 22:54:29 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Saam Tariverdi Subject: Re: does this look familiar? MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit No, actually, I got my problem fixed (it was my own mistake I made). I've never seen your error message before. Perhaps you need to reinstall MSVC? ----- Original Message ----- From: "Tanner Bonig" To: Sent: Sunday, March 26, 2000 10:46 PM Subject: does this look familiar? > warning LNK4019: corrupt string table (table end); new end assumed > LIBCD.lib(xtoa.obj) : fatal error LNK1143: invalid or corrupt file: no > symbol for comdat section 0x4 > > thanks.. > tanner ========================================================================= Date: Sun, 26 Mar 2000 23:05:04 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Josh Armentrout Subject: help with odd string MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 8BIT i know i'm getting the string of §§§нннннннннннннннннннннннннннннннннннннннннн because of the new operator, but is there anyway to avoid it or remove it from a character pointer? Josh ========================================================================= Date: Sun, 26 Mar 2000 23:38:13 -0500 Reply-To: smirman@vt.edu Sender: CS2604 discussion list From: Steve Mirman Subject: Re: MSVC 6.0 w/Win2k question In-Reply-To: <00a401bf9799$5ae3eb20$124723d0@saam> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit It works fine on mine and I've installed it on Win 2k server and Pro many times -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Saam Tariverdi Sent: Sunday, March 26, 2000 10:06 PM To: CS2604@LISTSERV.VT.EDU Subject: MSVC 6.0 w/Win2k question I know this is slightly off-topic, but here goes -- I installed Visual C++ 6.0 in Windows 2000, but when I try to run the debugger, it gives me all these weird prompts. I remember seeing something when I installed C++ 6.0 about how I should install the Windows NT Symbols or something, do I need to do that though? Basically, has anyone gotten MSVC 6.0 to work in Windows 2000 properly? Let me know asap, thanks! Saam Tariverdi ========================================================================= Date: Mon, 27 Mar 2000 00:24:47 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: David Cook Subject: access violation on program exit MIME-version: 1.0 Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_D1QseIiBjQR0Kym46RbE7A)" This is a multi-part message in MIME format. --Boundary_(ID_D1QseIiBjQR0Kym46RbE7A) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable Ok, my program runs and does what it's supposed to but when my program = exits I get an access violation in SBHEAP.C. The lines preceding the = access violation are: // add previous entry size to sizeEntry and determine // its new index sizeEntry +=3D sizePrev; indEntry =3D (sizeEntry >> 4) - 1; if (indEntry > 63) indEntry =3D 63; -> The -> is where the debugger says the access violation occurred. I've = commented out ALL deletes in my destructors for now, but it still gives = me an access violation. Does anyone have any ideas about where to start = looking for the problem? Thanks -Dave C --Boundary_(ID_D1QseIiBjQR0Kym46RbE7A) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
Ok, my program runs and does what it's = supposed to=20 but when my program exits I get an access violation in SBHEAP.C.  = The lines=20 preceding the access violation are:
        // =20 add previous entry size to sizeEntry and=20 determine
        //  its new = index
        sizeEntry +=3D=20 sizePrev;
        indEntry =3D = (sizeEntry=20 >> 4) - 1;
        if = (indEntry >=20 63)
           = =20 indEntry =3D 63;
->
 
 
The -> is where the debugger says = the access=20 violation occurred.  I've commented out ALL deletes in my = destructors for=20 now, but it still gives me an access violation.  Does anyone have = any ideas=20 about where to start looking for the problem?
 
Thanks
-Dave C
--Boundary_(ID_D1QseIiBjQR0Kym46RbE7A)-- ========================================================================= Date: Mon, 27 Mar 2000 12:10:43 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Josh Armentrout Subject: output stream in binary MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Question.. why might my output stream be in binary. i've set my fstream to binary, but should that effect "cout"? if so.. how might i go about keeping the i/o stream in plain text? Josh. ========================================================================= Date: Mon, 27 Mar 2000 14:47:06 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: Missing Something? In-Reply-To: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Fri, 24 Mar 2000, Scott Walker wrote: > Just out of curiosity, why do the suggested function > headers in the spec take a size parameter? If the blockSize > get's passed into the contructor for the bufferpool and > stored, why is that parameter needed? Is there some > special case I'm forgetting to think about? Within the context of Project 3, the size parameter is unnecessary, because the "messages" are always one buffer long. And, the position parameter might well be confused with the block ID. However, in P4, you will use the buffer pool in a more general way. Then, the "message" might be of any length, and might go to any place (not just be always one block long beginning at a block start location). -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Mon, 27 Mar 2000 14:50:25 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: last question, unused buffers MIME-version: 1.0 Content-type: text/plain; charset=us-ascii In the spec it says after completing all commands in the input file, all unwritten blocks in the buffer pool should be written to disk. What if all the buffers were not used. Say you ran buffer 5 15 and the input file contained only 1 line. insert 3 something then should the binary look like: ?????????????? ?????????????? ?????????????? something or ?????????????? ?????????????? ?????????????? something ?????????????? ?????????????? Or in a more general case, what if the input file only contained a "debug" command? Then should the buffers (which may contain default values from the constructor) be printed to the file?? The first version would make more sense to me. How can you flush the unused buffers if you dont know where to put them? ========================================================================= Date: Mon, 27 Mar 2000 15:04:48 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Ali Asghar Zafer Subject: 1371 spreadsheet of points In-Reply-To: <3.0.6.32.20000327145025.0090a530@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII The updated spreadsheet with points of Q1-Q4 and p2 is on the web. Thanks Ali Asghar Zafer ========================================================================= Date: Mon, 27 Mar 2000 16:42:02 -0500 Reply-To: jcovin@vt.edu Sender: CS2604 discussion list From: Jon Covin Subject: Re: last question, unused buffers In-Reply-To: <3.0.6.32.20000327145025.0090a530@mail.vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT > In the spec it says after completing all commands in the input file, all > unwritten blocks in the buffer pool should be written to disk. What if all > the buffers were not used. Say you ran buffer 5 15 and the input file > contained only 1 line. > > insert 3 something > > then should the binary look like: > > ?????????????? > ?????????????? > ?????????????? > something > > or > > ?????????????? > ?????????????? > ?????????????? > something > ?????????????? > ?????????????? > The first one > Or in a more general case, what if the input file only contained a "debug" > command? Then should the buffers (which may contain default values from the > constructor) be printed to the file?? > The first version would make more sense to me. How can you flush the unused > buffers if you dont know where to put them? You only write dirty buffers to the file, so this shouldn't be a problem. -Jon ========================================================================= Date: Mon, 27 Mar 2000 18:08:26 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: last question, unused buffers In-Reply-To: <3.0.6.32.20000327145025.0090a530@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Mon, 27 Mar 2000, david wrote: > In the spec it says after completing all commands in the input file, all > unwritten blocks in the buffer pool should be written to disk. What if all > the buffers were not used. Say you ran buffer 5 15 and the input file > contained only 1 line. > > insert 3 something > > then should the binary look like: > > ?????????????? > ?????????????? > ?????????????? > something > > or > > ?????????????? > ?????????????? > ?????????????? > something > ?????????????? > ?????????????? > > Or in a more general case, what if the input file only contained a "debug" > command? Then should the buffers (which may contain default values from the > constructor) be printed to the file?? > The first version would make more sense to me. How can you flush the unused > buffers if you dont know where to put them? It would be the first. Note that the number of buffers in the bufferpool has NOTHING to do with the size of the file. The size of the file would be determined by the highest block ID referenced by an insert command. In the interesting example of an input file with nothing but a debug command, a reasonable interpretation is that the file itself has size 0 (and, of course, none of the buffers have yet been associated with file blocks). -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Mon, 27 Mar 2000 17:00:54 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Matt Stec Subject: binary file In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Ok...I think my program is working correctly, but I've got a question about the binary file. I'm probably just thinking about it too much. //file open command Out.open("p3bin.dat", ios::out | ios::in | ios::trunc | ios::binary); //file write command //space is a void* Out.write((char*)space, buffSize); Which works...now I come to the dumb question: am I supposed to be able to read the binary file in a text editor? I think I am...the editor is just reading the bytes and converting them to their ASCII equivalents, which would match what is originally read in to the program. So right now, I'm able to open the file in Notepad, for example, and I can read "GOOD_START" followed by some whitespace, then the next entry. Is this right? am I thinking about this too much? thanks, matt ========================================================================= Date: Mon, 27 Mar 2000 18:46:32 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Tanner Bonig Subject: little off subject MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit so I was puking tonight during the registration meeting, anyone have a make-up date? Tanner ========================================================================= Date: Mon, 27 Mar 2000 19:05:48 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: "Dzung T. Dang" Subject: Re: little off subject MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Make-up session for all students who cannot make the Monday meetings: Tuesday, March 28, McB129, 6 p.m. ----- Original Message ----- From: "Tanner Bonig" To: Sent: Monday, March 27, 2000 6:46 PM Subject: little off subject > so I was puking tonight during the registration meeting, anyone have a > make-up date? > > Tanner ========================================================================= Date: Mon, 27 Mar 2000 19:19:59 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: r duffy Subject: Re: little off subject In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Make-up session for all students who cannot make the Monday meetings: Tuesday, March 28, McB129, 6 p.m. -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Tanner Bonig Sent: 27 March, 2000 6:47 PM To: CS2604@LISTSERV.VT.EDU Subject: little off subject so I was puking tonight during the registration meeting, anyone have a make-up date? Tanner ========================================================================= Date: Mon, 27 Mar 2000 22:05:13 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Ali Asghar Zafer Subject: p2 grade changes In-Reply-To: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII All those who had lost points for not using inheritance and using a single node type for both internal and leaf nodes have now got those points added to their score. The updated spreadsheet indicating this change is on the web. Also you will be receiving the updated gradesheets soon. Thanks, Ali Asghar Zafer ========================================================================= Date: Mon, 27 Mar 2000 22:04:29 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Jonathan Pryor Subject: ``get'' on unfilled block MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Consider the following input: get 0 debug Should block ``0'' be placed on the most recently used list? I would think so, as it simplifies the program logic, and frees you from needing to worry about "Gee, what if someone really *did* insert NULL's into the file?"--which is about the only way I can think of to tell if a block is "valid" if it's currently in the middle of the file, such as for: insert 5 hello, world. get 0 debug However, if I insert blocks into the MRU list that were only for ``get'' requests (even to nonexistent blocks), my output differs from the posted sample. So, which should the proper behavior be? Thanks, - Jon ========================================================================= Date: Mon, 27 Mar 2000 22:37:34 -0500 Reply-To: joowens@vt.edu Sender: CS2604 discussion list From: John Owens Subject: Re: ``get'' on unfilled block In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit No, it is invalid. you have not inserted block 0 yet, so therefore there should be an error messasage saying it is out of range. -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of Jonathan Pryor Sent: Monday, March 27, 2000 10:04 PM To: CS2604@LISTSERV.VT.EDU Subject: ``get'' on unfilled block Consider the following input: get 0 debug Should block ``0'' be placed on the most recently used list? I would think so, as it simplifies the program logic, and frees you from needing to worry about "Gee, what if someone really *did* insert NULL's into the file?"--which is about the only way I can think of to tell if a block is "valid" if it's currently in the middle of the file, such as for: insert 5 hello, world. get 0 debug However, if I insert blocks into the MRU list that were only for ``get'' requests (even to nonexistent blocks), my output differs from the posted sample. So, which should the proper behavior be? Thanks, - Jon ========================================================================= Date: Mon, 27 Mar 2000 23:00:54 -0800 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Stephen Hoskins Subject: sample input file MIME-version: 1.0 Content-type: MULTIPART/MIXED; BOUNDARY="Boundary_(ID_0VFo5bP71HgwgE7VQ/duMA)" This is a multi-part message in MIME format. --Boundary_(ID_0VFo5bP71HgwgE7VQ/duMA) Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_Ky3GyHu+3NON9qTOddUWtw)" --Boundary_(ID_Ky3GyHu+3NON9qTOddUWtw) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit I have attached here a sample input file with matching output. This helped me in debugging my program. The program arguments are buffer 1 11. If any of you get the same results (or possibly even different) the feedback would be very much appreciated. Thanks! -Stephen Hoskins --Boundary_(ID_Ky3GyHu+3NON9qTOddUWtw) Content-type: text/html; charset=us-ascii Content-transfer-encoding: 7bit I have attached here a sample input file with matching output.  This helped me in debugging my program.  The program arguments are buffer 1 11.  If any of you get the same results (or possibly even different) the feedback would be very much appreciated.  Thanks!
-Stephen Hoskins
--Boundary_(ID_Ky3GyHu+3NON9qTOddUWtw)-- --Boundary_(ID_0VFo5bP71HgwgE7VQ/duMA) Content-type: text/plain; name=input.txt; charset=us-ascii Content-disposition: inline; filename=input.txt Content-transfer-encoding: 7bit get 1 debug insert 0 I'm REally TiRED!!! debug get 0 debug insert 2 but it's just from cOding debug insert 1 In my HEad I Ache debug insert 3 NOT me!!! debug get 1 debug get 3 debug insert 0 SomeOne's ReAlly Long sTring debug get 2 debug get 0 debug get 45 debug --Boundary_(ID_0VFo5bP71HgwgE7VQ/duMA) Content-type: text/plain; name=output.txt; charset=us-ascii Content-disposition: inline; filename=output.txt Content-transfer-encoding: 7bit buffer 1 11 get 1 Block 1 does not exist debug The buffer pool is empty insert 0 I'm REally TiRED!!! I'm REally(at block 0 inserted successfully) debug The order is 0 get 0 Block 0 contains "I'm REally" debug The order is 0 insert 2 but it's just from cOding but it's (at block 2 inserted successfully) debug The order is 2 insert 1 In my HEad I Ache In my HEad(at block 1 inserted successfully) debug The order is 1 insert 3 NOT me!!! NOT me!!!(at block 3 inserted successfully) debug The order is 3 get 1 Block 1 contains "In my HEad" debug The order is 1 get 3 Block 3 contains "NOT me!!!" debug The order is 3 insert 0 SomeOne's ReAlly Long sTring SomeOne's (at block 0 inserted successfully) debug The order is 0 get 2 Block 2 contains "but it's " debug The order is 2 get 0 Block 0 contains "SomeOne's " debug The order is 0 get 45 Block 45 does not exist Press any key to continue --Boundary_(ID_0VFo5bP71HgwgE7VQ/duMA)-- ========================================================================= Date: Mon, 27 Mar 2000 23:05:18 -0800 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Stephen Hoskins Subject: Re: binary file MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Matt Stec wrote: > Ok...I think my program is working correctly, but I've got a question about > the binary file. I'm probably just thinking about it too much. > > //file open command > Out.open("p3bin.dat", ios::out | ios::in | ios::trunc | ios::binary); > > //file write command > //space is a void* > Out.write((char*)space, buffSize); > > Which works...now I come to the dumb question: am I supposed to be able to > read the binary file in a text editor? yes. > I think I am...the editor is just > reading the bytes and converting them to their ASCII equivalents, which > would match what is originally read in to the program. So right now, I'm > able to open the file in Notepad, for example, and I can read "GOOD_START" > followed by some whitespace, then the next entry. Is this right? yes, yes it is. > am I > thinking about this too much? > yes, yes you are. (just joking) =D > > thanks, matt ========================================================================= Date: Tue, 28 Mar 2000 00:26:51 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Patrick O'day Subject: input format MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit which happens first, concatenating the string to blocksize or finding the last char? ex with blocksize = 5 "insert 0 A B" should "A" or "A " be the data that is put into the buffer? when a get is called on an invalid blockID that is less then the largest one called does that blockID get stored in the buffer? ex: "insert 55 GOOD_START" "get 10" should debug include the 10 even though it returned a null string? I know this has been answer before, but I've seen different answers since then and I was wondering if it had been revised again. I believe that 10 should be in the debug statement because the buffer class would have to check to see if it is a valid string and this would break the portability to anything besides strings. ========================================================================= Date: Tue, 28 Mar 2000 00:31:48 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: "J.p. Lien" Subject: Re: ``get'' on unfilled block In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=us-ascii I think the way Dr. Schaeffer said (or implied) to do this was: If the block is lower than the highest written block value (i.e., if it is in the file), then we print NULLs, which would mean adding it to the list. If it is higher than the highest block written (a la get 36 in the sample input), then we print an error, which means not inserting it. This seems to result in the simplest code. How to extend this to empty files is something of a dillemma. If you haven't filled up your buffer array yet (meaning that you haven't written anything to the disk), and someone calls get on a block that's not in memory, then it's obviously not on the disk, since your file is still empty. I think this falls into case two above, and since it's greater than the highest block written to disk, it qualifies as an error. That's the way I wrote my program anyway, and it saves the hassle of trying to read from an empty file. J.p. >Consider the following input: > > get 0 > debug > >Should block ``0'' be placed on the most recently used list? > >I would think so, as it simplifies the program logic, and >frees you from needing to worry about "Gee, what if someone >really *did* insert NULL's into the file?"--which is about >the only way I can think of to tell if a block is "valid" >if it's currently in the middle of the file, such as for: > > insert 5 hello, world. > get 0 > debug > >However, if I insert blocks into the MRU list that were only >for ``get'' requests (even to nonexistent blocks), my output >differs from the posted sample. > >So, which should the proper behavior be? > >Thanks, > - Jon > ========================================================================= Date: Tue, 28 Mar 2000 00:57:43 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: Re: ``get'' on unfilled block In-Reply-To: <3.0.1.32.20000328003148.00846460@mail.vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii >>Consider the following input: >> >> get 0 >> debug >> An error should be returned: 0 is not in the file or buffer pool. (Actually, *nothing* is in the buffer pool or file) >>Should block ``0'' be placed on the most recently used list? >> >>I would think so, as it simplifies the program logic, and >>frees you from needing to worry about "Gee, what if someone >>really *did* insert NULL's into the file?"--which is about >>the only way I can think of to tell if a block is "valid" >>if it's currently in the middle of the file, such as for: >> >> insert 5 hello, world. >> get 0 >> debug >> >>However, if I insert blocks into the MRU list that were only >>for ``get'' requests (even to nonexistent blocks), my output >>differs from the posted sample. >> >>So, which should the proper behavior be? An error should *also* be returned by the above fragment (GET 0) because nothing has been written to the file yet, AND the buffer pool only contains block 5. Since nothing has been pushed off the pool, nothing is in the file. If 5 had been written to the file, get 0 would be valid, and would return a NULL string. ========================================================================= Date: Tue, 28 Mar 2000 01:21:15 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Dennis Kryway II Subject: Command Line Parameters MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Should we allow the user to run the program with 0 buffers? Should we allow the user to run the program with a buffer length of 0? Thanks. ========================================================================= Date: Tue, 28 Mar 2000 01:35:08 -0800 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: John Subject: Re: Command Line Parameters MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit ----- Original Message ----- From: Dennis Kryway II To: Sent: Monday, March 27, 2000 10:21 PM Subject: Command Line Parameters > Should we allow the user to run the program with 0 buffers? > > Should we allow the user to run the program with a buffer length of 0? > > Thanks. I asked Dr. Shaffer this in class on Friday and he replied no to this question. John ========================================================================= Date: Tue, 28 Mar 2000 03:35:15 -0500 Reply-To: csharp@vt.edu Sender: CS2604 discussion list From: Chris Sharp Subject: insert string question and whitespace MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit I believe I already know the answer to this question after reading in the spec...but I just want to make sure my interpretation of it is correct. For the string parameter of the insert command the spec mentions "Note that string is defined to be a series of characters beginning with the first non-space and terminating with the last non-space that occurs prior to the newline character." Now in the sample input file there were no instances where whitespace existed between the last non-space character and the newline character. But because of this possibility we are suppose to essentially chop off all whitespace before the first non-space character AND all the whitespace after the last non-space character correct? Thanks for your help, Chris ========================================================================= Date: Tue, 28 Mar 2000 07:52:38 -0500 Reply-To: joowens@vt.edu Sender: CS2604 discussion list From: John Owens Subject: Re: ``get'' on unfilled block In-Reply-To: <3.0.6.32.20000328005743.0090e100@mail.vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of david Sent: Tuesday, March 28, 2000 12:58 AM To: CS2604@LISTSERV.VT.EDU Subject: Re: ``get'' on unfilled block >>Consider the following input: >> >> get 0 >> debug >> An error should be returned: 0 is not in the file or buffer pool. (Actually, *nothing* is in the buffer pool or file) THIS IS TRUE >>Should block ``0'' be placed on the most recently used list? >> >>I would think so, as it simplifies the program logic, and >>frees you from needing to worry about "Gee, what if someone >>really *did* insert NULL's into the file?"--which is about >>the only way I can think of to tell if a block is "valid" >>if it's currently in the middle of the file, such as for: >> >> insert 5 hello, world. >> get 0 >> debug >> >>However, if I insert blocks into the MRU list that were only >>for ``get'' requests (even to nonexistent blocks), my output >>differs from the posted sample. >> >>So, which should the proper behavior be? An error should *also* be returned by the above fragment (GET 0) because nothing has been written to the file yet, AND the buffer pool only contains block 5. Since nothing has been pushed off the pool, nothing is in the file. If 5 had been written to the file, get 0 would be valid, and would return a NULL string. THIS COULD BE FALSE.. if you recall, Dr Shaffer stated that on the event that your highwater mark is raised, you have the option to initialize the buffer with that WRITE_NULL_BLOCK immediately. Therefore, no error message would be displayed because you have already written the null blocks to disk. ========================================================================= Date: Tue, 28 Mar 2000 12:00:05 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: ``get'' on unfilled block In-Reply-To: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Mon, 27 Mar 2000, Jonathan Pryor wrote: > Consider the following input: > > get 0 > debug > > Should block ``0'' be placed on the most recently used list? The answer would have been "yes", except that this block is out of the range of the file at this point. > I would think so, as it simplifies the program logic, and > frees you from needing to worry about "Gee, what if someone > really *did* insert NULL's into the file?"--which is about > the only way I can think of to tell if a block is "valid" > if it's currently in the middle of the file, such as for: > > insert 5 hello, world. > get 0 > debug In this example, the order of the blocks in the bufferpool should be 0 then 5. > However, if I insert blocks into the MRU list that were only > for ``get'' requests (even to nonexistent blocks), my output > differs from the posted sample. If I understand what you say here, and if you are correct, then the sample is wrong. However, I went through the sample output, and it looks correct to me as it stands. The only request to a block not previously inserted to is one past the high water mark of the file (the request for 36) which does not count. Note that if that same line had been to 3 instead of 36 it WOULD have been read in and affected the order of the buffers in the buffer pool. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Tue, 28 Mar 2000 12:03:47 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: input format In-Reply-To: <38E0429B.38CC7792@vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 28 Mar 2000, Patrick O'day wrote: > which happens first, concatenating the string to blocksize or finding the last > char? > ex with blocksize = 5 > "insert 0 A B" > should "A" or "A " be the data that is put into the buffer? It doesn't matter much either way, but "A " seems more natural to me. > when a get is called on an invalid blockID that is less then the largest one > called does that blockID get stored in the buffer? > ex: > "insert 55 GOOD_START" > "get 10" Yes. The model you want is that there is nothing special about this get request -- at least, not so far as the buffer pool is concerned. > should debug include the 10 even though it returned a null string? I know this > has been answer before, but I've seen different answers since then and I was > wondering if it had been revised again. I believe that 10 should be in the debug > statement because the buffer class would have to check to see if it is a valid > string and this would break the portability to anything besides strings. Yes. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Tue, 28 Mar 2000 12:10:19 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: ``get'' on unfilled block In-Reply-To: <3.0.6.32.20000328005743.0090e100@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 28 Mar 2000, david wrote: > >> insert 5 hello, world. > >> get 0 > >> debug > > An error should *also* be returned by the above fragment (GET 0) because > nothing has been written to the file yet, AND the buffer pool only contains > block 5. Since nothing has been pushed off the pool, nothing is in the > file. If 5 had been written to the file, get 0 would be valid, and would > return a NULL string. No, this is not reasonable, because the consequence is that the user would get different results depending on the size of the bufferpool. To see this, consider what would happen if you turned off buffering. Suddenly, the access to block 0 becomes legal under your interpretation, whereas it was illegal before. This is NOT behavior that you want. Regardless of buffering, logically the file is 6 blocks long after the initial insert, so logically, block 0 is legal. Who has actually written what to the file is irrelevent from a logical point of view. Now the question is what to do physically so that the correct logical behavior results in the easiest way. That is why I suggested that you (physically) null-fill blocks 0 to 4 when the "insert 5" command is processed. In that way, just letting the bufferpool operate naturally will give the desired result. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Tue, 28 Mar 2000 12:11:55 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: Command Line Parameters In-Reply-To: <38E04F5B.568B2714@vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 28 Mar 2000, Dennis Kryway II wrote: > Should we allow the user to run the program with 0 buffers? No. You could make this work, but it would require special-purpose code (in essence, turn off buffing). Don't bother -- just reject it. > Should we allow the user to run the program with a buffer length of 0? I don't see how this could even work. Reject it. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Tue, 28 Mar 2000 12:12:41 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: insert string question and whitespace In-Reply-To: <000001bf9890$8b323820$92d5c026@dogbert> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 28 Mar 2000, Chris Sharp wrote: > I believe I already know the answer to this question after reading in the > spec...but I just want to make sure my interpretation of it is correct. > > For the string parameter of the insert command the spec mentions "Note that > string is defined to be a series of characters beginning with the first > non-space and terminating with the last non-space that occurs prior to the > newline character." > > Now in the sample input file there were no instances where whitespace > existed between the last non-space character and the newline character. But > because of this possibility we are suppose to essentially chop off all > whitespace before the first non-space character AND all the whitespace after > the last non-space character correct? Correct. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Tue, 28 Mar 2000 13:36:16 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Brandon McKelvey Subject: Re: ``get'' on unfilled block MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit So lets Clear this up. If you get 0 then it gets up at the start of the LRU list. Is this correct? I think this is ridiculous to make this point a day before the project is due and when some people have already submitted there project. example get 36 get 0 insert 1 sure get 0 debug order 0 1? I am sure almost everyone wrote it so that get 0 returned an error. It was the only thing that made sense. Brandon ----- Original Message ----- From: Cliff Shaffer To: Sent: Tuesday, March 28, 2000 12:00 PM Subject: Re: ``get'' on unfilled block > On Mon, 27 Mar 2000, Jonathan Pryor wrote: > > > Consider the following input: > > > > get 0 > > debug > > > > Should block ``0'' be placed on the most recently used list? > > The answer would have been "yes", except that this block is out of the > range of the file at this point. > > > I would think so, as it simplifies the program logic, and > > frees you from needing to worry about "Gee, what if someone > > really *did* insert NULL's into the file?"--which is about > > the only way I can think of to tell if a block is "valid" > > if it's currently in the middle of the file, such as for: > > > > insert 5 hello, world. > > get 0 > > debug > > In this example, the order of the blocks in the bufferpool should be 0 > then 5. > > > However, if I insert blocks into the MRU list that were only > > for ``get'' requests (even to nonexistent blocks), my output > > differs from the posted sample. > > If I understand what you say here, and if you are correct, then the sample > is wrong. However, I went through the sample output, and it looks correct > to me as it stands. The only request to a block not previously inserted > to is one past the high water mark of the file (the request for 36) which > does not count. Note that if that same line had been to 3 instead of 36 > it WOULD have been read in and affected the order of the buffers in the > buffer pool. > > -- > Cliff Shaffer, Associate Professor Phone: (540) 231-4354 > Department of Computer Science Email: shaffer@cs.vt.edu > Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer > ------------------------------------------------------------------------- ========================================================================= Date: Tue, 28 Mar 2000 15:15:06 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: ``get'' on unfilled block In-Reply-To: <001501bf98e4$81604a40$ebd8c026@parklink.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 28 Mar 2000, Brandon McKelvey wrote: > So lets Clear this up. If you get 0 then it gets up at the start of the LRU > list. Is this correct? I think this is ridiculous to make this point a day > before the project is due and when some people have already submitted there > project. > > example > get 36 > get 0 > insert 1 sure > get 0 > debug > > order 0 1? > I am sure almost everyone wrote it so that get 0 returned an error. It was > the only thing that made sense. You were told on Wednesday, March 22, in a message entitled "CHANGE TO SPEC" under what conditions an error should be returned. Following that spec definition, if your example represents the entire input file, the first 2 "get" requests generate errors, and the third one generates some indication that the block is null-filled. Nothing has changed since then. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Tue, 28 Mar 2000 14:25:09 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: Re: ``get'' on unfilled block In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=us-ascii so you are saying that we should "NULL fill" the file *as soon* as the hi-mark is made higher, and not when that higher buffer gets pushed off the buffer pool?? At 12:10 PM 03/28/2000 -0500, you wrote: >On Tue, 28 Mar 2000, david wrote: > >> >> insert 5 hello, world. >> >> get 0 >> >> debug >> >> An error should *also* be returned by the above fragment (GET 0) because >> nothing has been written to the file yet, AND the buffer pool only contains >> block 5. Since nothing has been pushed off the pool, nothing is in the >> file. If 5 had been written to the file, get 0 would be valid, and would >> return a NULL string. > >No, this is not reasonable, because the consequence is that the user would >get different results depending on the size of the bufferpool. To see >this, consider what would happen if you turned off buffering. Suddenly, >the access to block 0 becomes legal under your interpretation, whereas it >was illegal before. This is NOT behavior that you want. > >Regardless of buffering, logically the file is 6 blocks long after the >initial insert, so logically, block 0 is legal. Who has actually written >what to the file is irrelevent from a logical point of view. Now the >question is what to do physically so that the correct logical behavior >results in the easiest way. That is why I suggested that you (physically) >null-fill blocks 0 to 4 when the "insert 5" command is processed. In that >way, just letting the bufferpool operate naturally will give the desired >result. > >-- >Cliff Shaffer, Associate Professor Phone: (540) 231-4354 >Department of Computer Science Email: shaffer@cs.vt.edu >Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer >------------------------------------------------------------------------- > ========================================================================= Date: Tue, 28 Mar 2000 14:29:33 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: Re: ``get'' on unfilled block In-Reply-To: <001501bf98e4$81604a40$ebd8c026@parklink.net> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii I totally agree- *nothing* was *supposed* to be written to the file until a dirty buffer got pushed off the buffer pool! At 01:36 PM 03/28/2000 -0500, you wrote: >So lets Clear this up. If you get 0 then it gets up at the start of the LRU >list. Is this correct? I think this is ridiculous to make this point a day >before the project is due and when some people have already submitted there >project. > >example >get 36 >get 0 >insert 1 sure >get 0 >debug > >order 0 1? >I am sure almost everyone wrote it so that get 0 returned an error. It was >the only thing that made sense. > > > >Brandon >----- Original Message ----- >From: Cliff Shaffer >To: >Sent: Tuesday, March 28, 2000 12:00 PM >Subject: Re: ``get'' on unfilled block > > >> On Mon, 27 Mar 2000, Jonathan Pryor wrote: >> >> > Consider the following input: >> > >> > get 0 >> > debug >> > >> > Should block ``0'' be placed on the most recently used list? >> >> The answer would have been "yes", except that this block is out of the >> range of the file at this point. >> >> > I would think so, as it simplifies the program logic, and >> > frees you from needing to worry about "Gee, what if someone >> > really *did* insert NULL's into the file?"--which is about >> > the only way I can think of to tell if a block is "valid" >> > if it's currently in the middle of the file, such as for: >> > >> > insert 5 hello, world. >> > get 0 >> > debug >> >> In this example, the order of the blocks in the bufferpool should be 0 >> then 5. >> >> > However, if I insert blocks into the MRU list that were only >> > for ``get'' requests (even to nonexistent blocks), my output >> > differs from the posted sample. >> >> If I understand what you say here, and if you are correct, then the sample >> is wrong. However, I went through the sample output, and it looks correct >> to me as it stands. The only request to a block not previously inserted >> to is one past the high water mark of the file (the request for 36) which >> does not count. Note that if that same line had been to 3 instead of 36 >> it WOULD have been read in and affected the order of the buffers in the >> buffer pool. >> >> -- >> Cliff Shaffer, Associate Professor Phone: (540) 231-4354 >> Department of Computer Science Email: shaffer@cs.vt.edu >> Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer >> ------------------------------------------------------------------------- > ========================================================================= Date: Tue, 28 Mar 2000 15:52:24 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: Cliff Shaffer Subject: Re: ``get'' on unfilled block In-Reply-To: <3.0.6.32.20000328142509.00918ac0@mail.vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 28 Mar 2000, david wrote: > so you are saying that we should "NULL fill" the file *as soon* as the > hi-mark is made higher, and not when that higher buffer gets pushed off the > buffer pool?? Yes. When the insert takes place is the time that the bufferpool knows that the file size has changed. You want to treat this event as the single exception, so that everything else works naturally. By adding a few lines of code at the right point in the "insert" routine for the bufferpool, this entire issue goes away. There is another alternative that would be equally easy to implement, but which would give inconsistent results to the user depending on the size of the buffer pool. This would be to not grow the file until the new high-water-mark buffer has been written to disk. At the time of the write, the intervening blocks would null-fill. A request to one of the intervening blocks would be an error until such time as the high-water-mark block is written. The problem with this is that a smaller buffer pool will cause the high-water-mark to change earlier than a larger buffer pool. The validity of a "get" to a block between the old and new high-water-marks will depend on the activity of the buffer pool. This is *not* the behavior that you want, since the logical validity of a command should have nothing to do with the physical implementation. -- Cliff Shaffer, Associate Professor Phone: (540) 231-4354 Department of Computer Science Email: shaffer@cs.vt.edu Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer ------------------------------------------------------------------------- ========================================================================= Date: Tue, 28 Mar 2000 15:02:21 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: John Costigan Subject: Re: ``get'' on unfilled block In-Reply-To: <3.0.6.32.20000328142933.00917ec0@mail.vt.edu> MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit On March 22, the spec was changed, specifically so that you would HAVE to write to the file if the high-water-mark was surpassed by more than 1 block. That is, if the high water mark was set at 15, and you received an insert for block 16, you wouldn't need to write anything to the file, only if the insert were to at least block 17. This was a change to the spec, so it is *supposed* to be written to the file. As of March 22, the spec reads: "If a new 'insert' command writes beyond that, then the file should grow in size accordingly. Any intervening blocks should be filled with null values to insure that future 'get' requests will work properly. For example, if the highest-numbered block so far written had been 10, and an 'insert' command is given for block 13, then blocks 11 and 12 should be filled with nulls." From anybody's interpretation, "Any intervening blocks should be filled with null values to insure that future 'get' requests will work properly" means writing to the file as soon as the insert is made. No *new* point was made "a day before the project is due". -- JC -----Original Message----- From: CS2604 discussion list [mailto:CS2604@listserv.vt.edu]On Behalf Of david Sent: Tuesday, March 28, 2000 2:30 PM To: CS2604@LISTSERV.VT.EDU Subject: Re: ``get'' on unfilled block I totally agree- *nothing* was *supposed* to be written to the file until a dirty buffer got pushed off the buffer pool! At 01:36 PM 03/28/2000 -0500, you wrote: >So lets Clear this up. If you get 0 then it gets up at the start of the LRU >list. Is this correct? I think this is ridiculous to make this point a day >before the project is due and when some people have already submitted there >project. > >example >get 36 >get 0 >insert 1 sure >get 0 >debug > >order 0 1? >I am sure almost everyone wrote it so that get 0 returned an error. It was >the only thing that made sense. > > > >Brandon >----- Original Message ----- >From: Cliff Shaffer >To: >Sent: Tuesday, March 28, 2000 12:00 PM >Subject: Re: ``get'' on unfilled block > > >> On Mon, 27 Mar 2000, Jonathan Pryor wrote: >> >> > Consider the following input: >> > >> > get 0 >> > debug >> > >> > Should block ``0'' be placed on the most recently used list? >> >> The answer would have been "yes", except that this block is out of the >> range of the file at this point. >> >> > I would think so, as it simplifies the program logic, and >> > frees you from needing to worry about "Gee, what if someone >> > really *did* insert NULL's into the file?"--which is about >> > the only way I can think of to tell if a block is "valid" >> > if it's currently in the middle of the file, such as for: >> > >> > insert 5 hello, world. >> > get 0 >> > debug >> >> In this example, the order of the blocks in the bufferpool should be 0 >> then 5. >> >> > However, if I insert blocks into the MRU list that were only >> > for ``get'' requests (even to nonexistent blocks), my output >> > differs from the posted sample. >> >> If I understand what you say here, and if you are correct, then the sample >> is wrong. However, I went through the sample output, and it looks correct >> to me as it stands. The only request to a block not previously inserted >> to is one past the high water mark of the file (the request for 36) which >> does not count. Note that if that same line had been to 3 instead of 36 >> it WOULD have been read in and affected the order of the buffers in the >> buffer pool. >> >> -- >> Cliff Shaffer, Associate Professor Phone: (540) 231-4354 >> Department of Computer Science Email: shaffer@cs.vt.edu >> Virginia Tech, Blacksburg, VA 24061-0106 WWW: www.cs.vt.edu/~shaffer >> ------------------------------------------------------------------------- > ========================================================================= Date: Tue, 28 Mar 2000 15:04:47 -0500 Reply-To: CS2604 discussion list Sender: CS2604 discussion list From: david Subject: Re: ``get'' on unfilled block In-Reply-To: MIME-version: 1.0 Content-type: text/plain; charset=us-ascii So are you saying that either way is acceptable for the submission of this project? I have coded mine as the alternative version, and although it should be a simple change, I would rather not make the change if I dont have to. Not that Im lazy, but I have a couple more tests this week, and I would rather study then re-code, re-test, etc. At 03:52 PM 03/28/2000 -0500, you wrote: >On Tue, 28 Mar 2000, david wrote: > >> so you are saying that we should "NULL fill" the file *as soon* as the >> hi-