Programming MethodologyLecture15Word文档下载推荐.docx
- 文档编号:20180650
- 上传时间:2023-01-17
- 格式:DOCX
- 页数:17
- 大小:33.65KB
Programming MethodologyLecture15Word文档下载推荐.docx
《Programming MethodologyLecture15Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《Programming MethodologyLecture15Word文档下载推荐.docx(17页珍藏版)》请在冰豆网上搜索。
thisistheturningpointofthequarter.Thisislikethepivotofthequarter.Aftertoday,it抯alldownhill,becausewe抳egonethroughjustasmanydaysaswehaveleft.Fairlyexciting.Asamatteroffact,theyactuallyhavefewerdaysleft,becausewehavelikethelastclassisnothappeningandstuff.
Butafewannouncementsbeforewedelveintothingstoday.Thehandoutsfromlasttime,ifyoudidn抰getthehandoutsfromlasttime,namely,especiallythepracticemidtermandsolutionstothepracticemidtermaswellasassignmentNo.4,ifyoudidn抰getthose,they抮eavailableinthebacktoday.Ifyoualreadygotthem,youdon抰needtopickupadditionalcopies.There抯noadditionalhandoutsfortoday,buttherearejustcopiesoftheonesfromlastweek.
So,again,withthepracticemidterm,Iwouldveryhighlyencourageyoutotakeitand,ifyouwant,also,forthefulleffect,actuallytimeyourselfdoingitsoyougetsomenotionofwhat抯takingyoulongerorwhat抯takinglesstime.Thatwillgiveyouadiagnosticofthekindofthingsyouneedtobrushupon,so?
andit抣lalsogiveyouachancetoseewhatwe抮ereallykindofexpectingforthemidterm,andtherewasabunchofstuffontherewhereitexplainsthatthemidtermisopenbookandopennote,butclosedcomputer,andalltheguidelinesforthemidtermareallexplainedonthefirstpageofthathandout.
Sothemidtermiscomingup.It抯nextweek,justafewdaysaway.Tuesday,October30th,7:
00p.m.to8:
30p.m.inKresgeAuditorium.Ifyoudon抰knowwhereKresgeAuditoriumis,findoutwhereKresgeAuditoriumis.It抯yourfriend,it抯big,it抯bad,it抯Kresge.It抯justahugeauditorium.Ifyou抳eneverbeentherebefore,it抯kindofcavernous.Yougointhereandyougo,myGod,Ididn抰knowtherewasanauditoriumthisbiginStanford,butthereis,andit抯oursforthatshortperiodoftime.
Ifyouhaveamidtermconflictandyoualreadysentmeemail?
ifyouhaven抰alreadysentmeemail,youcangoaheadandtry,butIcan抰accommodateanymorerequests.Icanhopefullyjusttellyouwhenthealternatemidtermis,butyouwillgetanemailfrommethisweekendlettingyouknowwhenandwherethealternatemidtermis,soreadyouremailthisweekend.It抣lprobablycomesometimeintheweehoursofthenighteitheronSaturdayorSunday,whichwouldbetheweekend,strangelyenough.Sowatchyouremailforthealternatemidterm.
Ifyou抮eanSAPDstudent,SAPDstudentshavetwooptions.Ifyou抮ealocalSAPDstudent,youcancomeinfortheexam,sojustcomeondown,7:
30p.m.,KresgeAuditorium,October30th.Takeitalongwitheveryoneelse,introduceyourself,comeby,sayhi.IalwaysliketomeettheSAPDstudents.
Ifyou抮eremote,becauseIknowsomeofyouaresaying,notinthestateofCalifornia,anditwouldkindofbeastretchtoaskyoutoflyherejusttotakethemidtermexam,youmaytaketheexamremotelyatyoursite.Ifyouplanontakingtheexamremotelyatyoursite,youneedtosendmeemail,andinthatemailyouneedtoletmeknowyournameaswellasyoursiteadministrator.Findoutwhoyoursiteadministratorisifyoudonotknow,becauseyoursiteadministratorwillbeadministeringtheexamtoyou,andIneedtoknowtheiremailaddress.
Sosendmeyournameandemail,whichI抣lgetwhenyousendmeemail,butyoursiteadministrator抯nameandemailsoIcanemailthemtheexamandtheycanadministerittoyou.Andifyou抮ealocalstudent,goaheadandsendmeemail,andjustsayyou抮ecominginlocally,justsoIknowthatyou抮ecominginlocallyandthatwayIcankeeptrackofeveryone.
Butextremelyimportantformoststudents,ifyou抮earemotestudentandyoudon抰sendmeemail,soIhavenowayofcontactingyoursiteadministrator,Ican抰giveyouthemidterm,andthat抯realbadtimesforjustmorereasonsthanyoucanshakeastickat,butyou抮ecertainlywelcometotry.
Andlastbutnotleast,sameannouncementaslasttime.Thereisasyllabuschange,averyminorsyllabuschange,basedonjustmovingthediscussionofarraysupbyoneday.Soifyou抮esortofreadingalonginthebookandyouwannaknowwhattoreadforMonday,Chapter11onarraysiswhatwe抣lbecoveringonMonday,andifyou抮enotfollowingalonginthebook,youshouldbefollowingalonginthebook,butnowyouknow.
Allright,sowiththatsaid,Iwannadojustatinylittlebitofwrapuponwhatwetalkedabout,memoryandthiswholenotionofpointerslasttime,andgointoournextgreattopic.Allright?
Sotimeforournextgreattopic.
Wellweneedtodoalittlebitofpointersfirst.Sothefirstexampleissomethingthatwetalkedaboutverybrieflylasttime,butIwannamakesureeveryone抯sortofonboardwiththis.SoifIhaveourfriend,thepoint,thatwetalkedaboutlasttime,whichisjustaclassthatstorestwovalues,anxandaythatwepassintotheconstructor,whenwedosomethinglikethis?
I抣ldrawitsortofoveronthisboard.
NowI抦gonnadrawitina?
actually,I抣ldrawitoverhere,andI抣ldrawitinawaythatwedon抰needtoworryaboutallthememoryaddressesandoverheadandallthatstuff,becausethatsometimesmakesthediagramsalittlebitugly,andsoI抣lshowyoutheverysimple,stylizedversionofkeepingtrackofthestackandtheheap.
Sooverhereistheheap,overhereisthestack,andwhatwe抮egonnadoissay,hey,whenwedeclarepointponebeforewehavedonethisnew,whatwegetispone,whichisbasicallyjustsomeboxonthestack.Whatdoesitholdrightnow?
Well,untilwedothisline,itholdsnothing.Itholdsnothingthatweknowabout,okay?
Whenwecallthisnew,itsays,hey,heap,getmesomenewmemoryforapoint,andsotheheapkindofgoesoverandgoes,boink,here抯somememoryforapoint,anditcallstheconstructorandsays,hey,constructor,putinthevaluesoneone.Soifsomewhereontheheapwehavethevaluesoneandoneforourlittleprivatexandourprivateysomewhereontheheap,andthevaluethatnewgivesback,thatweassignedtopone,istheaddressofthisthing.
Remember,wedon抰reallycareaboutwhereinmemorythisthing抯actuallystored,andsosometimes,whatweliketodoisjustkeeptrackofaddressesbypointer.Soweknowthatthisisjustsomememoryaddressoverhere,wherethisparticularlyobjectisactuallystoredontheheap.Okay?
Sonow,ifwedopointptwo?
actually,letmenotlet?
putthesemicolononyet.Ifwedopointptwo,whatwegetis,onthestack,wegetsomenewspacesetasideforptwoand,again,itsbeginningvalueisunknown.
Nowwehaveacoupleoptions.Onethingwecoulddoissaynewpoint,andgiveitsomexylocation,inwhichcasewe抣lgetanewpointontheheapandptwowillpointtothatnewpoint.Wecoulddosomethingfunkylikesay,hey,ptwoequalspone.Wellallthat抯happenedthereissaying,takethevaluethat抯inpone,whichisapointerovertothislocationontheheap,andsetptwoequaltothat.SoifthishappenstobeamemorylocationAAAE,thisguygetsAAAE,whichmeans,inoursortofstylisticrepresentation,it抯pointingtothesameplace.Okay?
Arewesortofonboardwiththat?
Ifyou抮eonboardwiththat,nodyourhead.Excellente.
Allright.Sonowifwedoptwodotmove,andwetellittomovebyanamountlikethreecommafour,itsays,well,inordertocallthemovemethod,Ineedtocallthemovemethodusingtheobjectptwo.Wheredoestheobjectptwolive?
Itlooksitupthroughthepointerandsays,here,thisiswhereyoulive.Callthemovemethodwiththisparticularobject.Soapathtothispointertothislocationinmemory,anditsays,movethreefour,andasyousawwithmovelasttime,allmovedoesisaddthosevaluestotherespectivexandy.Sopxbecomesfour,pybecomesfive,andnowthatmovemethodisdone.And,interestinglyenough,whatI抳edoneischangenotonlyptwo,butalsopone,becausetheywerepointingtothesameplaceinmemory.Theywerethesameactuallypoint,andthat抯theimportantthingtokeepinmind.
IfIsetanobjectequaltoanotherobjectlikethis,theyarethesameactualobject.There抯onlyoneofthoseobjectsthatlivessomewhere,andIreallyhavetwothingsthatarepointing,orwhatwereallyliketorefertoasreferring,tothatobject.Sooftentimeswerefertothesethingsasreferences,okay?
NowwhathappensifIcomealongandsay,pointpthree.Igetpthreeoverhereonthestack,right?
Andagain?
I抣lwritethepthreeoverheresoasnottointerferewiththelines,andI抣ldrawthislinealittlebitaroundpthreesoitkindofgoeslikethat.Itsays,pthree,Idon抰wannainterferewithyou,I抦justgonnazigzagaround.
Pthree,whatvaluedoesitstartwith?
Idon抰know.It抯notpointingtoanobjectyet,becauseithasn抰beeninitializedtopointtoanobject.Ithasn抰beeninitializedtopointtoanewobject.AndsoifIcomealongandsay,hey,youknowwhatpthree?
Ijustwannamoveyou.Movetofourcommafive,becausethat抯whereIheartheparty抯at.That抯whereponeandptwoare.Canyoumoveyourselftofourcommafive?
WhathappenswhenIdothis?
Badtimes,that抯whathappens.WhatIget?
wellfirstofall,Igetasocial,becauseawholebunchofpeoplesaidit.ButwhatIgetisthisthing.Whoknowswhereit抯pointing?
Asamatterofafact,thispointercould,oftentimes,besomethingwerefertoasanull,whichmeansit抯notpointingtoanyparticularobject,inwhichcase,whenItrytodothis,Igetwhat抯calledanulldreference.Anyonehappentoseesomethingcalledanull
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Programming MethodologyLecture15