23_Slides-Editorbuffer

23_Slides-Editorbuffer - EfficiencyandADTs YinglinWang...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
CS112 Fundamentals of  Programming Abstractions Efficiency and ADTs Yinglin Wang CS Dept., SJTU
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS112 Fundamentals of  Programming Abstractions Our website moved to 202.120.1.155/wang-yl/index.htm ftp site remains 202.120.7.244
Background image of page 2
CS112 Fundamentals of  Programming Abstractions Solution to exercise 1 Main() {      stackADT integerStack;      int integer;      integerStack=NewStack();      printf(”enter a list of integers, ending with 0:”);      while(TRUE){           printf(“>”);           scanf(“%d”; &integer);           if(integer!=0) Push(integerStack, integer);           else break;      }          printf(“Those integers in reverse order are:”) ;      while(!StackIsEmpty){           pringtf(“\n %d”, Pop(integerStack));      }      }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS112 Fundamentals of  Programming Abstractions Solution to exercise 2 Main() {      printf(”enter a list of integers, ending with 0:”);      reverseIntegers(); } void reverseIntegers(void){        int integer;          printf(“>”);        scanf(“%d”; &integer);        if(integer==0) { printf(“Those integers in reverse order are:”) ;                  return;            }        else  {reverseIntegers()};        printf(“\n%d”, integer); }
Background image of page 4
CS112 Fundamentals of  Programming Abstractions Different strategies for  representing data  can have a  significant effect on the efficiency of yr code. linked list  is a useful data structure for insertion and  deletion operations. Main points:
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS112 Fundamentals of  Programming Abstractions Today we will discuss the  implementation of an  Editor Buffer, which is the  topic of your next  assignment.  An Editor Buffer is the  data structure that  underlies text editing  programs like Notepad.  The first implementation  we will consider is based  on arrays. The picture  here is the demonstration  of program.
Background image of page 6
CS112 Fundamentals of  Programming Abstractions Buffer.h:    see textbook 375-378 Typedef struct bufferCDT *bufferADT bufferADT NewBuffer(void) Void Freebuffer(bufferADT buffer) MoveCursorForward(bufferADT buffer) MoveCursorBackward(bufferADT buffer) MoveCursorToStart(bufferADT buffer) MoveCursorToEnd(bufferADT buffer) void InsertCharacter(bufferADT buffer,char ch) void DeleteCharacter(bufferADT buffer) void DisplayBuffer(bufferADT buffer)
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS112 Fundamentals of  Programming Abstractions Array Implementation of Editor Buffer
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/06/2010 for the course CS 112 taught by Professor Yinlinwang during the Spring '08 term at Shanghai Jiao Tong University.

Page1 / 31

23_Slides-Editorbuffer - EfficiencyandADTs YinglinWang...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online