2006 Nov 02 8:27 AM
I try to implement in ABAP a heap. I created an class which simulate this heap but I'm interesting that in ABAP is an ready implementation of heap class?
My definition of class have methods:
- GET_LAST_TOKEN
- ADD_TOKEN
- RELEASE_TOKEN
- CHECK_IS_EMPTY
- FLIP_HEAP
Attibutes:
- HEAP //table
- TOTAL //counter
- C_FALSE //boolean false
- C_TRUE //bolean true
Implementation (only overall view)
method ADD_TOKEN .
APPEND i_token to heap.
IF sy-subrc = 0.
total = total + 1.
ENDIF.
endmethod.
METHOD release_token .
IF total > 0.
DELETE heap INDEX total.
IF sy-subrc = 0.
total = total - 1.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD get_last_token .
DATA: l_token LIKE LINE OF heap.
IF total is not INITIAL.
READ TABLE heap
INDEX total
INTO e_token.
ENDIF.
ENDMETHOD.
Is this good idea?
2006 Nov 02 8:38 AM
Hello,
I think is fine, the only thing that is missing is to have a method with the number of elements, I mean something to return the counter.
Its just fine.
Gabriel.
I try to implement in ABAP a heap. I created an class which simulate this heap but I'm interesting that in ABAP is an ready implementation of heap class?
My definition of class have methods:
- GET_LAST_TOKEN
- ADD_TOKEN
- RELEASE_TOKEN
- CHECK_IS_EMPTY
- FLIP_HEAP
Attibutes:
- HEAP //table
- TOTAL //counter
- C_FALSE //boolean false
- C_TRUE //bolean true
Implementation (only overall view)
method ADD_TOKEN .
APPEND i_token to heap.
IF sy-subrc = 0.
total = total + 1.
ENDIF.
endmethod.
METHOD release_token .
IF total > 0.
DELETE heap INDEX total.
IF sy-subrc = 0.
total = total - 1.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD get_last_token .
DATA: l_token LIKE LINE OF heap.
IF total is not INITIAL.
READ TABLE heap
INDEX total
INTO e_token.
ENDIF.
ENDMETHOD.
Is this good idea?
2006 Nov 02 8:38 AM
Hello,
I think is fine, the only thing that is missing is to have a method with the number of elements, I mean something to return the counter.
Its just fine.
Gabriel.
2006 Nov 02 9:04 AM
hi
good
go through this link about heap , i hope this ll help you to solve your problem
http://www.redbooks.ibm.com/redbooks/pdfs/sg246291.pdf
thanks
mrutyun^
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |