MCPcopy Create free account
hub / github.com/SR-Sunny-Raj/Hacktoberfest2021-DSA / push

Method push

11. Stack/Stack Using Array.cpp:21–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19 return this->size;
20 }
21 void push(int element)
22 {
23 if(this->size == this->capacity)
24 {
25 capacity *= 2 ;
26 int *a = new int[capacity] ;
27 for(int i=0;i<this->size;i++)
28 a[i+1] = this->a[i] ;
29 //delete this->[]a ;
30 this->a = a ;
31 delete a ;
32 this->a[0] = element ;
33 size++ ;
34 }
35 else
36 {
37 for(int i=size;i>0;i--)
38 this->a[i] = this->a[i-1] ;
39 this->a[0] = element ;
40 size++ ;
41 }
42 }
43 int top()
44 {
45 if(this->size == 0)

Callers 11

mainMethod · 0.95
constructMethod · 0.95
constructMethod · 0.95
constructMethod · 0.95
constructMethod · 0.95
constructMethod · 0.95
constructMethod · 0.95
reversMethod · 0.95
minAddToMakeValidMethod · 0.95
lexoSubseqKMethod · 0.95
mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected